:root {
  /* Colors */
  --bg-main: #090d16;
  --bg-sidebar: #0f1524;
  --bg-card: rgba(21, 30, 52, 0.5);
  --bg-card-hover: rgba(30, 41, 69, 0.7);
  --border-color: rgba(255, 255, 255, 0.06);
  --border-focus: rgba(99, 102, 241, 0.4);
  
  --primary: #6366f1; /* Indigo */
  --primary-glow: rgba(99, 102, 241, 0.15);
  --primary-hover: #4f46e5;
  --accent-town: #3b82f6; /* Blue */
  --accent-ep: #10b981; /* Emerald */
  --accent-time: #f59e0b; /* Amber */
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dark: #64748b;
  
  /* Layout */
  --sidebar-width: 380px;
  --header-height: 70px;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  
  /* Font */
  --font-family: 'Outfit', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Reset & Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-family);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

/* Warning banner */
.protocol-warning-banner {
  background: linear-gradient(135deg, #7f1d1d 0%, #991b1b 100%);
  border-bottom: 1px solid rgba(220, 38, 38, 0.3);
  color: #fca5a5;
  padding: 10px 24px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 100;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.protocol-warning-banner a {
  color: #ffffff;
  font-weight: 700;
  text-decoration: underline;
  transition: color 0.2s;
}

.protocol-warning-banner a:hover {
  color: #fecaca;
}

/* App Container Layout */
.app-container {
  display: flex;
  flex-grow: 1;
  width: 100vw;
  height: 0;
  position: relative;
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
  overflow: hidden;
  z-index: 10;
  transition: all 0.3s ease;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 28px;
  height: 28px;
  color: var(--primary);
  filter: drop-shadow(0 0 8px var(--primary));
}

.logo-text {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* Search & Filters */
.search-filter-section {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 14px;
  transition: all 0.25s ease;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  background-color: rgba(99, 102, 241, 0.03);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.clear-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.clear-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.clear-btn svg {
  width: 14px;
  height: 14px;
}

.filter-controls {
  display: flex;
  align-items: center;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.filter-group label {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.custom-select {
  flex-grow: 1;
  padding: 8px 12px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.custom-select:focus {
  border-color: var(--primary);
}

.custom-select option {
  background-color: var(--bg-sidebar);
  color: var(--text-main);
}

/* Video List Area */
.video-list-container {
  flex-grow: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Custom Scrollbar for list and pages */
.video-list-container::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 6px;
}
.video-list-container::-webkit-scrollbar-track,
body::-webkit-scrollbar-track {
  background: transparent;
}
.video-list-container::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
.video-list-container::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.list-stats {
  font-size: 12px;
  color: var(--text-dark);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.video-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Video Item Card */
.video-item {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.video-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background-color: var(--primary);
  opacity: 0;
  transition: opacity 0.2s;
}

.video-item:hover {
  background-color: var(--bg-card-hover);
  transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.25);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.video-item.active {
  background-color: rgba(99, 102, 241, 0.08);
  border-color: var(--primary);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.1);
}

.video-item.active::before {
  opacity: 1;
}

.item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  word-break: break-all;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.badge-town {
  background-color: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.badge-episode {
  background-color: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-time {
  background-color: rgba(245, 158, 11, 0.15);
  color: #fde047;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
}

.item-size {
  font-family: monospace;
}

/* Skeletons */
.skeleton-card {
  height: 90px;
  background: linear-gradient(90deg, rgba(255,255,255,0.02) 25%, rgba(255,255,255,0.05) 50%, rgba(255,255,255,0.02) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Empty State */
.no-results {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Main Content Area */
.main-content {
  flex-grow: 1;
  height: 100%;
  overflow-y: auto;
  padding: 32px 40px;
  display: flex;
  flex-direction: column;
}

/* Empty/Select State */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-grow: 1;
  min-height: 400px;
}

.empty-state-content {
  text-align: center;
  max-width: 400px;
}

.empty-icon-wrap {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  color: var(--text-dark);
}

.empty-icon-wrap svg {
  width: 36px;
  height: 36px;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-main);
}

.empty-state p {
  font-size: 14px;
  color: var(--text-muted);
}

/* Active Player Layout */
.player-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.player-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tag-row {
  display: flex;
  gap: 8px;
}

.player-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

/* Video Player Wrapper */
.video-player-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background-color: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  group-hover: pointer;
}

.video-player-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Spinner Overlay */
.video-spinner {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none;
}

.spinner-dot {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  border-top-color: var(--primary);
  animation: spin 1s ease-in-out infinite;
}

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

/* Play button overlay */
.video-overlay-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0,0,0,0.2);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
  z-index: 4;
}

.video-overlay-play svg {
  width: 72px;
  height: 72px;
  color: #fff;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
  transform: scale(0.8);
  transition: transform 0.3s;
}

.video-player-wrapper:hover .video-overlay-play {
  opacity: 1;
  visibility: visible;
}

.video-overlay-play:hover svg {
  transform: scale(1);
}

/* Custom Controls styling */
.custom-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 60%, rgba(0,0,0,0) 100%);
  padding: 20px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 6;
}

.video-player-wrapper:hover .custom-controls,
.video-player-wrapper:focus-within .custom-controls {
  opacity: 1;
  transform: translateY(0);
}

/* Custom progress bar */
.progress-container {
  position: relative;
  height: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.progress-bar-hover-zone {
  position: absolute;
  top: -6px;
  left: 0;
  right: 0;
  bottom: -6px;
  z-index: 1;
}

.progress-slider-bg {
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  transition: height 0.15s;
}

.buffer-bar {
  position: absolute;
  left: 0;
  width: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.progress-bar-active {
  position: absolute;
  left: 0;
  width: 0;
  height: 4px;
  background: var(--primary);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.progress-scrubber {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  transform: scale(0);
  transition: transform 0.15s;
  position: absolute;
  right: -6px;
  z-index: 2;
}

.progress-container:hover .progress-slider-bg,
.progress-container:hover .buffer-bar,
.progress-container:hover .progress-bar-active {
  height: 6px;
}

.progress-container:hover .progress-scrubber {
  transform: scale(1);
}

/* Tooltip */
.progress-tooltip {
  position: absolute;
  bottom: 16px;
  transform: translateX(-50%);
  background: rgba(15, 21, 36, 0.9);
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-family: monospace;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  color: #fff;
}

.progress-container:hover .progress-tooltip {
  opacity: 1;
}

/* Controls Buttons Row */
.controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.controls-left, .controls-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.control-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.control-btn:hover {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.1);
  transform: scale(1.05);
}

.control-btn svg {
  width: 20px;
  height: 20px;
}

.time-display {
  font-family: monospace;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
  user-select: none;
}

.time-separator {
  color: rgba(255, 255, 255, 0.4);
  margin: 0 4px;
}

/* Volume Control */
.volume-container {
  display: flex;
  align-items: center;
  gap: 4px;
}

.volume-slider-wrap {
  width: 0;
  overflow: hidden;
  transition: width 0.25s ease;
  display: flex;
  align-items: center;
}

.volume-container:hover .volume-slider-wrap,
.volume-slider-wrap:focus-within {
  width: 80px;
}

.volume-slider {
  -webkit-appearance: none;
  width: 70px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  outline: none;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* Speed control menu */
.speed-control {
  position: relative;
}

#speedDisplay {
  font-size: 13px;
  font-weight: 700;
  font-family: monospace;
}

.speed-menu {
  position: absolute;
  bottom: 40px;
  right: 0;
  background: rgba(15, 21, 36, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px;
  display: flex;
  flex-direction: column;
  min-width: 80px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  opacity: 0;
  visibility: hidden;
  transform: translateY(5px);
  transition: all 0.2s;
  z-index: 10;
}

.speed-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.speed-option {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  text-align: center;
  transition: background-color 0.15s;
}

.speed-option:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.speed-option.active {
  background-color: var(--primary);
  color: #fff;
}

/* Metadata panels grid */
.metadata-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.metadata-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.metadata-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 18px;
  letter-spacing: -0.2px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}

/* Basic Info List */
.detail-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.04);
}

.detail-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.detail-label {
  font-size: 13px;
  color: var(--text-muted);
}

.detail-value {
  font-size: 13px;
  font-weight: 600;
  font-family: monospace;
}

.text-copyable {
  cursor: pointer;
  position: relative;
}

.text-copyable:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* Parsed details */
.tag-details {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.parsed-param {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.param-title {
  font-size: 13px;
  color: var(--text-muted);
}

.param-badge {
  font-size: 14px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 8px;
  font-family: monospace;
}

.parsed-note {
  display: flex;
  gap: 10px;
  background-color: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-top: 18px;
}

.note-icon {
  font-size: 16px;
}

.parsed-note p {
  font-size: 12px;
  color: var(--text-muted);
}

/* Responsive adjustment */
@media (max-width: 1024px) {
  .metadata-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: 400px;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  
  .main-content {
    padding: 20px;
  }
}

/* Video Error Overlay */
.video-error-overlay {
  position: absolute;
  inset: 0;
  background: rgba(9, 13, 22, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 8;
  color: #ef4444;
  text-align: center;
  padding: 24px;
  backdrop-filter: blur(8px);
}

.error-msg-content {
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Google Drive Link Button */
.drive-link-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  padding: 10px 16px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0.05) 100%);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-md);
  color: #a5b4fc;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.25s ease;
  width: 100%;
}

.drive-link-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 12px var(--primary-glow);
  transform: translateY(-1px);
}

.drive-link-btn .btn-icon {
  width: 16px;
  height: 16px;
}
