:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #252525;
  --text: #ffffff;
  --muted: #aaaaaa;
  --line: #333333;
  --accent: #ff0000;
  --accent2: #cc0000;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --surface2: #f0f0f0;
    --text: #1a1a1a;
    --muted: #666666;
    --line: #dddddd;
    --accent: #ff0000;
    --accent2: #cc0000;
    color-scheme: light;
  }
}

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

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: 240px;
  padding-bottom: 80px;
}

.content-wrapper {
  max-width: 100%;
  margin: 0 auto;
  padding: 16px 24px;
}

/* Header */
.top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 100;
  gap: 16px;
}

.hamburger {
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  padding: 8px;
  background: none;
  border: none;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.logo span { color: var(--text); }

.search-bar {
  flex: 1;
  max-width: 560px;
  margin: 0 16px;
  display: flex;
}

.search-bar input {
  flex: 1;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-right: none;
  border-radius: 20px 0 0 20px;
  background: var(--surface2);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.search-bar input:focus { border-color: var(--accent); }

.search-btn {
  padding: 8px 20px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 0 20px 20px 0;
  cursor: pointer;
  color: var(--text);
}

.search-btn:hover { background: var(--line); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover { background: var(--surface2); }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 56px;
  left: 0;
  width: 240px;
  height: calc(100vh - 56px);
  background: var(--surface);
  overflow-y: auto;
  z-index: 90;
  transition: transform 0.3s ease;
}

.sidebar.collapsed { transform: translateX(-240px); }

.sidebar-section { padding: 12px 0; }

.sidebar-section + .sidebar-section { border-top: 1px solid var(--line); }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 24px;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 0;
}

.sidebar-item:hover { background: var(--surface2); }

.sidebar-item.active { background: var(--surface2); font-weight: 600; }

.sidebar-item svg { width: 22px; height: 22px; flex-shrink: 0; }

.sidebar-label { font-size: 14px; }

/* Page content */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title { font-size: 22px; font-weight: 700; }

.tabs { display: flex; gap: 4px; }

.tab-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
}

.tab-btn:hover { background: var(--surface2); }

.tab-btn.active { color: var(--text); background: var(--surface2); }

/* Video player */
.video-player-container {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}

.video-player-container video {
  width: 100%;
  display: block;
  aspect-ratio: 16/9;
  background: #000;
}

.player-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  display: flex;
  align-items: center;
  gap: 12px;
}

.play-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.play-btn:hover { color: var(--accent); }

.time-display { font-size: 13px; color: #fff; }

.progress-bar {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}

.progress-bar:hover { height: 6px; }

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 35%;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

/* Video info */
.video-info { margin-bottom: 24px; }

.video-title { font-size: 20px; font-weight: 600; line-height: 1.3; margin-bottom: 12px; }

.video-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.video-stats { color: var(--muted); font-size: 14px; }

.video-actions-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
}

.action-btn:hover { background: var(--surface2); }

.action-btn.liked { color: var(--accent); border-color: var(--accent); }

/* Channel info */
.channel-info {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.channel-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 16px;
}

.channel-details { flex: 1; }

.channel-name { font-weight: 600; font-size: 14px; }

.channel-subscribers { color: var(--muted); font-size: 13px; }

.subscribe-btn {
  padding: 8px 20px;
  background: #fff;
  color: #000;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}

.subscribe-btn.subscribed { background: transparent; border: 1px solid var(--line); color: var(--text); }

/* Comments */
.comments-section { margin-top: 24px; }

.comments-header { font-size: 18px; font-weight: 600; margin-bottom: 16px; }

.comment-input-area {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.comment-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}

.comment-form { flex: 1; }

.comment-form textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  resize: none;
  outline: none;
  min-height: 60px;
}

.comment-form textarea:focus { border-color: var(--accent); }

.comment-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.comment-submit {
  padding: 8px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
}

.comment-submit:disabled { opacity: 0.5; cursor: not-allowed; }

.comment-list { display: flex; flex-direction: column; gap: 16px; }

.comment-item { display: flex; gap: 12px; }

.comment-body { flex: 1; }

.comment-author { font-weight: 600; font-size: 14px; }

.comment-text { font-size: 14px; margin-top: 4px; }

.comment-actions { display: flex; gap: 16px; margin-top: 8px; }

.comment-action-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.comment-action-btn:hover { color: var(--text); }

.comment-action-btn.liked { color: var(--accent); }

/* Related videos */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.related-card {
  cursor: pointer;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  transition: transform 0.15s;
}

.related-card:hover { transform: scale(1.02); }

.related-thumbnail {
  position: relative;
  aspect-ratio: 16/9;
  background: var(--surface2);
  overflow: hidden;
}

.related-thumbnail img { width: 100%; height: 100%; object-fit: cover; }

.duration-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.related-info { padding: 12px; }

.related-title { font-size: 14px; font-weight: 500; line-height: 1.4; margin-bottom: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.related-channel { font-size: 13px; color: var(--muted); }

.related-stats { font-size: 12px; color: var(--muted); }

/* Mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 80;
}

.sidebar-overlay.visible { display: block; }

/* Responsive */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-240px); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.visible { display: block; }
  .main-content { margin-left: 0; }
  .related-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

@media (max-width: 600px) {
  .search-bar { max-width: 120px; }
  .video-title { font-size: 16px; }
  .related-grid { grid-template-columns: 1fr; }
  .channel-info { flex-wrap: wrap; }
}
