:root {
  --bg-dark: #0f0f0f;
  --bg-card: #181818;
  --bg-hover: #272727;
  --bg-sidebar: #030303;
  --accent-red: #ff0000;
  --accent-red-hover: #cc0000;
  --text-main: #ffffff;
  --text-muted: #aaaaaa;
  --text-dim: #717171;
  --border-color: rgba(255, 255, 255, 0.1);
  --player-height: 72px;
  --header-height: 64px;
  --sidebar-width: 240px;
  --radius-card: 12px;
  --radius-btn: 20px;
}

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  user-select: none;
}

/* App Flex Layout */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Toast Notifications (Non-blocking floating banner) */
.toast-notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background-color: #212121;
  color: #ffffff;
  padding: 12px 24px;
  border-radius: 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
  border: 1px solid var(--accent-red);
  font-size: 14px;
  font-weight: 500;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.1, 0.9, 0.2, 1), transform 0.3s cubic-bezier(0.1, 0.9, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 90vw;
  text-align: center;
}

.toast-notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Top Header */
.top-header {
  height: var(--header-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background-color: var(--bg-dark);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
}

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

.brand-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 700;
  font-size: 20px;
}

.logo-icon {
  color: var(--accent-red);
  font-size: 32px;
}

.logo-sub {
  font-weight: 300;
  font-size: 14px;
  margin-left: 2px;
  color: var(--text-muted);
}

.header-center {
  flex: 1;
  max-width: 540px;
  margin: 0 20px;
}

.search-box {
  display: flex;
  align-items: center;
  background-color: #212121;
  border-radius: 8px;
  padding: 6px 12px;
  border: 1px solid transparent;
  transition: border-color 0.2s, background-color 0.2s;
}

.search-box:focus-within {
  background-color: #000;
  border-color: rgba(255, 255, 255, 0.3);
}

.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 15px;
  width: 100%;
  margin: 0 8px;
}

.search-icon {
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.profile-widget {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Sidebar Backdrop on Mobile */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 7500;
}

/* Main Container (Sidebar + Content) */
.main-container {
  flex: 1;
  display: flex;
  min-height: 0;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  transition: width 0.3s ease, left 0.3s ease;
}

.sidebar.collapsed {
  width: 72px;
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-footer,
.sidebar.collapsed .sidebar-divider {
  display: none;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 16px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.2s, color 0.2s;
}

.nav-item:hover a {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.nav-item.active a {
  background-color: #272727;
  color: var(--text-main);
}

.nav-item.active a .material-symbols-outlined {
  color: var(--accent-red);
}

.sidebar-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 16px 8px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px;
  font-size: 11px;
  color: var(--text-dim);
}

/* Dynamic Content Area (Desktop & PC Scroll Container) */
.content-view {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  padding: 24px 32px 140px 32px !important;
  background-color: var(--bg-dark);
}

.content-view::-webkit-scrollbar {
  width: 8px;
}
.content-view::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 4px;
}

/* Mood & Activity Filter Chips Container */
.mood-chips-container {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 0 16px 0;
  margin-bottom: 20px;
  -webkit-overflow-scrolling: touch;
}

.mood-chips-container::-webkit-scrollbar {
  display: none;
}

.mood-chip {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 18px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.2s, border-color 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.mood-chip:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.mood-chip.active {
  background-color: var(--text-main);
  color: #000;
  border-color: var(--text-main);
  font-weight: 700;
}

/* Shelves and Grids */
.section-shelf {
  margin-bottom: 40px;
}

.shelf-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

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

.shelf-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}

.music-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 12px;
  cursor: pointer;
  transition: transform 0.2s, background-color 0.2s;
  position: relative;
  overflow: hidden;
}

.music-card:hover {
  background-color: var(--bg-hover);
  transform: translateY(-4px);
}

.card-thumb-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 10px;
}

.card-thumb-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-playlist-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
  transition: opacity 0.2s, transform 0.2s, background-color 0.2s;
  z-index: 10;
  border: none;
  cursor: pointer;
}

.card-playlist-btn:hover {
  opacity: 1;
  background-color: var(--accent-red);
  transform: scale(1.1);
}

.card-edit-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
  transition: opacity 0.2s, transform 0.2s, background-color 0.2s;
  z-index: 10;
  border: none;
  cursor: pointer;
}

.card-edit-btn:hover {
  opacity: 1;
  background-color: var(--accent-red);
  transform: scale(1.1);
}

.card-delete-btn {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background-color: rgba(0, 0, 0, 0.7);
  color: #ff5252;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
  transition: opacity 0.2s, transform 0.2s, background-color 0.2s, color 0.2s;
  z-index: 10;
  border: none;
  cursor: pointer;
}

.card-delete-btn:hover {
  opacity: 1;
  background-color: var(--accent-red);
  color: white;
  transform: scale(1.1);
}

.card-play-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.music-card:hover .card-play-overlay {
  opacity: 1;
}

.card-play-btn {
  background-color: var(--accent-red);
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.card-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.card-sub {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Track List View (Table / Rows) */
.track-row-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.track-row {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s;
  gap: 16px;
}

.track-row:hover {
  background-color: var(--bg-hover);
}

.track-row.playing {
  background-color: rgba(255, 0, 0, 0.15);
}

.track-row-thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
}

.track-row-info {
  flex: 1;
  overflow: hidden;
  min-width: 0;
}

.track-row-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-row-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.track-row-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Persistent Player Bar */
.player-bar {
  background-color: #212121;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1000;
  height: var(--player-height);
  overflow: hidden;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
}

.player-left {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 320px;
  flex-shrink: 0;
}

.track-thumb-container {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
}

.track-thumb-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-hover-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.track-thumb-container:hover .thumb-hover-overlay {
  opacity: 1;
}

.track-meta {
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.track-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-center {
  flex: 1;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-play-main {
  background-color: var(--text-main);
  color: #000;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-play-main:hover {
  transform: scale(1.05);
  background-color: #fff;
}

.player-progress-container {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
}

.time-label {
  font-size: 11px;
  color: var(--text-dim);
  width: 36px;
  text-align: center;
}

.progress-bar-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

input[type="range"] {
  accent-color: var(--accent-red);
  width: 100%;
  height: 4px;
  border-radius: 2px;
  cursor: pointer;
}

.player-right {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 280px;
  justify-content: flex-end;
  flex-shrink: 0;
}

.volume-container {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 120px;
}

/* Buttons & Icons */
.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background-color 0.2s;
  flex-shrink: 0;
}

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

.btn-icon.active {
  color: var(--accent-red);
}

.btn-primary {
  background-color: var(--accent-red);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-btn);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary:hover {
  background-color: var(--accent-red-hover);
}

/* Full Screen Player Modal */
.full-player-modal {
  position: fixed;
  inset: 0;
  background-color: #0b0b0b;
  z-index: 9500;
  display: flex;
  flex-direction: column;
  padding: 24px 32px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition: transform 0.3s cubic-bezier(0.1, 0.9, 0.2, 1);
}

.btn-close-full {
  position: absolute;
  top: 24px;
  left: 24px;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  z-index: 10;
}

.full-player-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  padding-top: 20px;
}

.album-art-container {
  position: relative;
  width: 420px;
  height: 420px;
  max-width: 90vw;
  max-height: 90vw;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.9);
  flex-shrink: 0;
}

.album-art-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#visualizer-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.full-player-details {
  text-align: center;
  width: 100%;
  margin-top: 4px;
}

.full-track-info h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 4px;
}

.full-track-info h3 {
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 400;
}

.full-album-name {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
}

.full-player-tabs {
  display: flex;
  justify-content: center;
  gap: 24px;
  border-bottom: 1px solid var(--border-color);
  margin: 16px 0 12px;
  width: 100%;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 500;
  padding: 8px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab-btn.active {
  color: white;
  border-bottom-color: var(--accent-red);
}

.full-tab-content {
  width: 100%;
  min-height: 0;
}

.track-queue-list {
  overflow-y: auto !important;
  max-height: 280px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
  -webkit-overflow-scrolling: touch;
}

.track-queue-list::-webkit-scrollbar {
  width: 6px;
}
.track-queue-list::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 3px;
}

/* Modals & Forms */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  background-color: #212121;
  border-radius: 16px;
  padding: 24px;
  width: 92%;
  max-width: 420px;
  position: relative;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.6);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

.auth-tabs {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
}

.auth-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 500;
  padding: 8px 0;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.auth-tab.active {
  color: white;
  border-bottom-color: var(--accent-red);
}

.input-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 12px;
  color: var(--text-muted);
}

.input-group input, .input-group select {
  background-color: #121212;
  border: 1px solid #333;
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.input-group input:focus {
  border-color: var(--accent-red);
}

.auth-error {
  color: #ff5252;
  font-size: 13px;
  margin-bottom: 12px;
  line-height: 1.4;
  text-align: center;
}

/* Taste Profile Analytics */
.taste-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 20px;
  margin-bottom: 24px;
}

.taste-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.taste-label {
  width: 100px;
  font-size: 13px;
}

.taste-track-bar {
  flex: 1;
  height: 8px;
  background-color: #333;
  border-radius: 4px;
  overflow: hidden;
}

.taste-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-red), #ff6b6b);
  border-radius: 4px;
}

.hidden {
  display: none !important;
}

/* Mobile Responsive Design (Screens <= 768px) */
@media (max-width: 768px) {
  html, body {
    overflow: hidden !important;
    height: 100vh !important;
  }

  .app-layout {
    display: flex !important;
    flex-direction: column !important;
    height: 100vh !important;
    width: 100vw !important;
  }

  .top-header {
    padding: 0 10px;
    height: 56px !important;
    flex-shrink: 0;
  }

  .header-left {
    gap: 8px;
  }

  .header-center {
    margin: 0 4px;
    flex: 1;
    min-width: 0;
  }

  .header-right {
    display: flex !important;
    flex-shrink: 0 !important;
    gap: 6px !important;
  }

  .search-box {
    padding: 4px 6px;
  }

  .search-box input {
    font-size: 12px;
  }

  .logo-text {
    font-size: 15px;
  }

  .logo-sub {
    display: none;
  }

  .modal-card {
    width: 92% !important;
    padding: 20px 16px !important;
    max-width: 360px !important;
  }

  .main-container {
    flex: 1;
    display: flex !important;
    min-height: 0 !important;
    height: calc(100vh - 56px) !important;
    overflow: hidden !important;
  }

  /* Slide-out Sidebar Drawer on Mobile */
  .sidebar {
    position: fixed;
    top: 0;
    left: -260px;
    bottom: 0;
    z-index: 8000;
    box-shadow: 6px 0 20px rgba(0, 0, 0, 0.9);
    width: 240px !important;
    padding-top: 60px !important;
  }

  .sidebar.open {
    left: 0 !important;
  }

  .sidebar.open .nav-label,
  .sidebar.open .sidebar-footer,
  .sidebar.open .sidebar-divider {
    display: block !important;
  }

  .content-view {
    padding: 16px 12px 140px 12px !important;
    overflow-y: auto !important;
    min-height: 0 !important;
    height: 100% !important;
    -webkit-overflow-scrolling: touch;
  }

  .shelf-title {
    font-size: 18px;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
  }

  /* Fixed Bottom Player Bar on Mobile Screens */
  .player-bar {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    height: 64px !important;
    z-index: 4000 !important;
    background-color: #1c1c1c !important;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.8);
    padding: 0 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
  }

  .player-bar.hidden {
    display: none !important;
  }

  .player-left {
    width: auto;
    flex: 1;
    min-width: 0;
    gap: 8px;
  }

  .track-thumb-container {
    width: 40px;
    height: 40px;
  }

  .track-title {
    font-size: 13px;
  }

  .track-artist {
    font-size: 11px;
  }

  .player-center {
    flex: none;
    max-width: none;
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  .player-controls {
    display: flex !important;
    align-items: center;
    gap: 4px;
  }

  .btn-play-main {
    width: 34px;
    height: 34px;
  }

  #btn-prev, #btn-next, #btn-play-pause {
    display: flex !important;
  }

  #btn-shuffle, #btn-repeat, .player-progress-container {
    display: none !important;
  }

  .player-right {
    width: auto;
    gap: 2px;
    display: flex !important;
  }

  .volume-container {
    display: none !important;
  }

  .full-player-modal {
    padding: 16px 12px;
  }

  .album-art-container {
    width: 280px;
    height: 280px;
  }
}
