:root {
  --bg-app: #0f0f13;
  --bg-panel: #161619;
  --bg-panel-2: #1c1c21;
  --bg-hover: #26262c;
  --border: #2a2a30;
  --text-primary: #f1f1f3;
  --text-secondary: #a3a3ab;
  --accent-video: #ff3d3d;
  --accent-music: #1db954;
  --accent-purple: #7c3aed;
}

* {
  box-sizing: border-box;
}

html, body {
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  margin: 0;
  padding: 0;
  height: 100%;
}

#app {
  min-height: 100vh;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #3a3a42;
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background: #4a4a54;
}

.hide-scrollbar::-webkit-scrollbar {
  display: none;
}
.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

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

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.main-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-app);
  border-right: 1px solid var(--border);
  padding: 12px 8px 90px 8px;
  overflow-y: auto;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
}

.sidebar.collapsed {
  width: 0;
  padding: 0;
  overflow: hidden;
  border-right: none;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.sidebar-link:hover {
  background: var(--bg-hover);
}
.sidebar-link.active {
  background: var(--bg-panel-2);
}
.sidebar-link i {
  width: 20px;
  text-align: center;
  font-size: 16px;
}
.sidebar-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  padding: 16px 12px 6px 12px;
  font-weight: 600;
}
.sidebar-divider {
  border-top: 1px solid var(--border);
  margin: 8px 4px;
}

.content-area {
  flex: 1;
  min-width: 0;
  padding-bottom: 96px;
}

/* Cards */
.video-card {
  cursor: pointer;
}
.video-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}
.video-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
}
.video-card:hover .video-thumb-wrap img {
  transform: scale(1.03);
}
.video-duration-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,0.8);
  color: #fff;
  font-size: 11px;
  padding: 2px 5px;
  border-radius: 4px;
  font-weight: 600;
}

.track-card {
  background: var(--bg-panel);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}
.track-card:hover {
  background: var(--bg-panel-2);
}
.track-card:hover .track-play-overlay {
  opacity: 1;
  transform: translateY(0);
}
.track-cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1/1;
  border-radius: 6px;
  overflow: hidden;
  background: #333;
  margin-bottom: 10px;
}
.track-cover-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.track-play-overlay {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-music);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(6px);
  transition: all 0.2s;
  box-shadow: 0 8px 16px rgba(0,0,0,0.4);
}

.chip {
  padding: 7px 14px;
  border-radius: 8px;
  background: var(--bg-panel);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
}
.chip:hover {
  background: var(--bg-hover);
}
.chip.active {
  background: var(--text-primary);
  color: #000;
}

.btn-primary {
  background: var(--text-primary);
  color: #0f0f13;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.85; }

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 14px;
}
.btn-outline:hover { background: var(--bg-hover); }

.btn-music {
  background: var(--accent-music);
  color: #000;
  font-weight: 700;
  padding: 10px 24px;
  border-radius: 24px;
  border: none;
  cursor: pointer;
}
.btn-music:hover { transform: scale(1.03); }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  border: none;
  font-size: 16px;
}
.icon-btn:hover {
  background: var(--bg-hover);
}
.icon-btn.liked {
  color: var(--accent-video);
}

/* Search bar */
.search-bar {
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 640px;
  border: 1px solid var(--border);
  border-radius: 24px;
  overflow: hidden;
  background: var(--bg-panel);
}
.search-bar input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  padding: 9px 16px;
  font-size: 14px;
}
.search-bar button {
  background: var(--bg-panel-2);
  border: none;
  color: var(--text-primary);
  padding: 9px 18px;
  cursor: pointer;
  border-left: 1px solid var(--border);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-box {
  background: var(--bg-panel);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 400px;
  border: 1px solid var(--border);
}
.form-input {
  width: 100%;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  margin-bottom: 12px;
}
.form-input:focus {
  border-color: var(--accent-purple);
}

/* Bottom music player */
.player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 84px;
  background: #101012;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  z-index: 50;
  transform: translateY(100%);
  transition: transform 0.25s ease;
}
.player-bar.visible {
  transform: translateY(0);
}
.player-track-info {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 260px;
  min-width: 0;
}
.player-track-info img {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
}
.player-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  gap: 6px;
}
.player-buttons {
  display: flex;
  align-items: center;
  gap: 18px;
}
.player-embed-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.spinner {
  border: 3px solid var(--border);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  animation: spin 0.8s linear infinite;
  margin: 60px auto;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.grid-videos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px 16px;
}
.grid-tracks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
}

.avatar-circle {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}

.comment-row {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.badge-live {
  background: var(--accent-video);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
}

.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: #212126;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  border: 1px solid var(--border);
}

@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 56px; z-index: 45; }
  .sidebar:not(.mobile-open) { display: none; }
  .player-track-info { width: 160px; }
}
