* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #333;
  --text: #e8e8e8;
  --text2: #aaa;
  --accent: #3ea6ff;
  --red: #ff4444;
  --green: #4caf50;
  --yellow: #ffb300;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: wrap;
  gap: 10px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

h1 {
  font-size: 20px;
  color: var(--accent);
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 4px;
}

.tab {
  background: none;
  border: none;
  color: var(--text2);
  padding: 6px 14px;
  cursor: pointer;
  border-radius: 20px;
  font-size: 13px;
  transition: all 0.2s;
}

.tab:hover { background: var(--surface2); color: var(--text); }
.tab.active { background: var(--surface2); color: var(--text); font-weight: 600; }

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#search {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 20px;
  width: 220px;
  font-size: 13px;
  outline: none;
}
#search:focus { border-color: var(--accent); }

select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
}

#syncBtn {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: opacity 0.2s;
}
#syncBtn:hover { opacity: 0.85; }
#syncBtn:disabled { opacity: 0.5; cursor: not-allowed; }

.layout {
  display: flex;
  min-height: calc(100vh - 60px);
}

aside {
  width: 240px;
  min-width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

.sidebar-section { margin-bottom: 24px; }
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.sidebar-header h3 { font-size: 14px; color: var(--text2); }
#newPlaylistBtn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--accent);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#playlistList {
  list-style: none;
}
#playlistList li {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s;
}
#playlistList li:hover { background: var(--surface2); }
#playlistList li.active { background: var(--surface2); color: var(--accent); }
#playlistList li .count {
  font-size: 11px;
  color: var(--text2);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 10px;
}
#playlistList li .pl-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
  transition: opacity 0.15s;
}
#playlistList li:hover .pl-delete { opacity: 1; }

#stats {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.8;
}

main {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.video-card {
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.video-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.video-card.watched { opacity: 0.6; }

.thumb-wrap {
  position: relative;
  padding-top: 56.25%;
  background: var(--surface2);
}
.thumb-wrap img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb-wrap .duration-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
}

.video-info {
  padding: 12px;
}
.video-title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.video-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text2);
}
.video-channel {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}
.video-date { white-space: nowrap; }

.video-actions {
  display: flex;
  gap: 4px;
  padding: 0 12px 10px;
}
.video-actions button {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}
.video-actions button:hover { color: var(--text); border-color: var(--accent); }
.video-actions button.active { color: var(--yellow); border-color: var(--yellow); }
.video-actions button.hide-btn:hover { color: var(--red); border-color: var(--red); }

.load-more {
  text-align: center;
  padding: 20px;
}
.load-more button {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 10px 30px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  min-width: 280px;
  max-width: 400px;
}
.modal-content h3 { margin-bottom: 12px; }
.modal-content ul { list-style: none; margin-bottom: 12px; }
.modal-content li {
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
}
.modal-content li:hover { background: var(--surface2); }
.modal-close {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
}

@media (max-width: 768px) {
  .header-left { flex-direction: column; align-items: flex-start; gap: 8px; }
  aside { display: none; }
  .video-grid { grid-template-columns: 1fr; }
  #search { width: 160px; }
}
