:root {
  --bg-main: #121212;
  --bg-sidebar: #181818;
  --bg-topbar: #181818;
  --bg-card: #242424;
  --bg-card-hover: #2a2a2a;
  --text-primary: #ffffff;
  --text-secondary: #a7a7a7;
  --accent: #fa243c; /* Apple Music Red */
  --border: #282828;
  --slider-bg: #404040;
  --nav-hover: rgba(255, 255, 255, 0.05);
  --nav-active: rgba(255, 255, 255, 0.1);
  --np-bg: rgba(255, 255, 255, 0.05);
  --bg-sidebar-translucent: rgba(24, 24, 24, 0.85);
}

body.light-mode {
  --bg-main: #ffffff;
  --bg-sidebar: #f3f3f3;
  --bg-topbar: #f3f3f3;
  --bg-card: #ffffff;
  --bg-card-hover: #f5f5f5;
  --text-primary: #111111;
  --text-secondary: #666666;
  --border: #e5e5e5;
  --slider-bg: #d4d4d4;
  --nav-hover: rgba(0, 0, 0, 0.05);
  --nav-active: rgba(0, 0, 0, 0.1);
  --np-bg: rgba(0, 0, 0, 0.05);
  --bg-sidebar-translucent: rgba(243, 243, 243, 0.85);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  transition: background-color 0.3s, color 0.3s;
}

.app-container {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s, border-color 0.3s;
}

.sidebar-header {
  padding: 20px;
}

.mac-dots {
  display: flex;
  gap: 8px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.dot.red { background-color: #ff5f56; }
.dot.yellow { background-color: #ffbd2e; }
.dot.green { background-color: #27c93f; }

.sidebar-nav {
  padding: 10px 16px;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding-left: 8px;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 6px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.95rem;
  transition: background 0.2s;
  margin-bottom: 4px;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.nav-item:hover {
  background-color: var(--nav-hover);
}

.nav-item.active {
  background-color: var(--nav-active);
}

/* Main Wrapper */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Top Bar */
.top-bar {
  height: 60px;
  background-color: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  -webkit-app-region: drag;
  transition: background-color 0.3s, border-color 0.3s;
}

.playback-controls {
  display: flex;
  align-items: center;
  gap: 20px;
  width: 200px;
}

.control-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.control-btn:hover {
  color: var(--text-primary);
}

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

.control-btn.play-btn svg {
  width: 28px;
  height: 28px;
  color: var(--text-primary);
}

.now-playing {
  flex: 1;
  display: flex;
  justify-content: center;
}

.np-logo {
  width: 300px;
  height: 30px;
  background: var(--np-bg);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.np-logo svg {
  width: 16px;
  height: 16px;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 200px;
  justify-content: flex-end;
}

.theme-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
  padding: 4px;
}

.theme-toggle:hover {
  color: var(--text-primary);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
}

.volume-control svg {
  width: 16px;
  height: 16px;
}

.volume-slider {
  width: 100px;
  height: 4px;
  background: var(--slider-bg);
  border-radius: 2px;
  position: relative;
}

.volume-level {
  width: 60%;
  height: 100%;
  background: var(--text-secondary);
  border-radius: 2px;
}

/* Content */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 40px;
}

.page-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 32px;
}

.section-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 24px;
}

.album-card {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.2s;
}

.album-card:hover {
  transform: translateY(-4px);
}

.album-cover {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  background: #333;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.album-cover > svg {
  width: 64px;
  height: 64px;
  color: rgba(255,255,255,0.5);
}

.cover-f1 {
  background: linear-gradient(135deg, #e10600, #ff4b4b);
}

.cover-bg3 {
  background: linear-gradient(135deg, #4a3020, #c19976);
}

.cover-other {
  background: linear-gradient(135deg, #2c3e50, #3498db);
}

.play-overlay {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.play-overlay svg {
  width: 20px;
  height: 20px;
  color: white;
  margin-left: 2px;
}

.album-card:hover .play-overlay {
  opacity: 1;
  transform: translateY(0);
}

.album-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.album-title {
  font-size: 1rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.album-artist {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Sidebar Sub-items */
.nav-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 4px;
}
.nav-item-wrapper {
  display: flex;
  align-items: center;
  position: relative;
}
.nav-item-wrapper .nav-item {
  flex: 1;
  margin-bottom: 0;
}
.toggle-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2;
}
.toggle-btn:hover {
  color: var(--text-primary);
}
.toggle-btn svg {
  width: 16px !important;
  height: 16px !important;
  color: inherit !important;
}
.nav-group.collapsed .nav-sub-items {
  grid-template-rows: 0fr;
  margin-top: 0;
  margin-bottom: 0;
  opacity: 0;
  border-color: transparent;
}
.nav-group.collapsed .toggle-btn {
  transform: rotate(-90deg);
}
.nav-sub-items {
  display: grid;
  grid-template-rows: 1fr;
  margin-left: 34px;
  border-left: 1px solid var(--border);
  padding-left: 8px;
  margin-bottom: 4px;
  margin-top: 4px;
  transition: grid-template-rows 0.5s cubic-bezier(0.16, 1, 0.3, 1), margin 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 1;
}
.nav-sub-items-inner {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.nav-item.sub-item {
  font-size: 0.85rem;
  padding: 6px 8px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}
.nav-item.sub-item:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.05);
}
.nav-item.sub-item.active {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.1);
}

/* Album Page */
.album-page-header {
  display: flex;
  gap: 32px;
  margin-bottom: 40px;
  align-items: flex-end;
}
.album-cover-large {
  width: 240px;
  height: 240px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}
.album-cover-large > svg {
  width: 100px;
  height: 100px;
  color: rgba(255,255,255,0.5);
}
.album-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 8px;
}
.album-type {
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 1px;
}
.album-title-large {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 4px;
}
.album-artist-large {
  font-size: 1.1rem;
  color: var(--accent);
  font-weight: 500;
}
.album-meta {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.album-actions {
  display: flex;
  gap: 12px;
}
.btn-play-large, .btn-shuffle-large {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: filter 0.2s;
}
.btn-play-large:hover, .btn-shuffle-large:hover {
  filter: brightness(1.1);
}
.btn-shuffle-large {
  background: var(--bg-card);
  color: var(--accent);
}

/* Tracklist */
.tracklist {
  display: flex;
  flex-direction: column;
}
.track-header {
  display: grid;
  grid-template-columns: 40px 1fr 120px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.track-row {
  display: grid;
  grid-template-columns: 40px 1fr 120px;
  padding: 12px 16px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary);
  align-items: center;
  transition: background-color 0.2s, color 0.3s;
}
.track-row:hover {
  background: var(--nav-hover);
}
.track-col-index {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
.track-col-title {
  font-weight: 500;
}
.track-col-meta {
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-align: right;
}

.play-icon {
  display: none;
  width: 16px;
  height: 16px;
  fill: var(--text-primary);
}
.meta-words {
  display: none;
}
.track-row:hover .index-num {
  display: none;
}
.track-row:hover .play-icon {
  display: block;
}
.track-row:hover .meta-chapters {
  display: none;
}
.track-row:hover .meta-words {
  display: block;
}

.hamburger {
  display: none;
}

.mobile-player {
  display: none;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    bottom: 0;
    z-index: 1000;
    transform: translateY(-100%);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    padding-top: 50px;
    border-right: none;
    background-color: var(--bg-sidebar-translucent);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }
  
  .sidebar.open {
    transform: translateY(0);
  }
  
  .sidebar-header {
    display: none;
  }
  
  .hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    position: relative;
    z-index: 1002;
    margin-right: 16px;
  }
  
  .hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background-color: var(--text-primary);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    position: absolute;
  }
  
  .hamburger span:nth-child(1) { transform: translateY(-4px); }
  .hamburger span:nth-child(2) { transform: translateY(4px); }
  .hamburger.open span:nth-child(1) { transform: translateY(0) rotate(45deg); }
  .hamburger.open span:nth-child(2) { transform: translateY(0) rotate(-45deg); }
  
  .mobile-player {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 32px;
    background-color: var(--bg-sidebar-translucent);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(80px + env(safe-area-inset-bottom));
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  .mobile-player button {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .mobile-player .play-pause-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--text-primary);
    color: var(--bg-main);
  }
  
  .mobile-player .play-pause-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
  }
  
  .mobile-player .skip-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
  }
  
  .main-wrapper {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }

  .top-bar {
    padding: 0 16px;
    height: 50px;
    position: relative;
    z-index: 1001;
    background-color: var(--bg-topbar);
  }
  
  .now-playing {
    display: none;
  }
  
  .playback-controls {
    display: none;
  }
  
  .top-bar-right {
    margin-left: auto;
  }
  
  .volume-control {
    display: none;
  }
  
  .content {
    padding: 20px 16px;
  }
  
  .page-title {
    font-size: 2rem;
    margin-bottom: 24px;
  }
  
  .album-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  
  .album-page-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 20px;
  }
  
  .album-cover-large {
    width: 200px;
    height: 200px;
  }
  
  .album-actions {
    justify-content: center;
  }
  
  .track-header {
    display: none;
  }
  
  .track-row {
    grid-template-columns: 30px 1fr;
    padding: 12px 8px;
    margin: 0 0 8px 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
  }
  
  .track-col-meta {
    display: none;
  }
  
  .track-col-index {
    justify-content: center;
  }
  
  .track-row:hover {
    background: transparent;
  }
  
  .track-row:active {
    background: var(--nav-hover);
  }
}
