*{box-sizing:border-box}html,body{margin:0;padding:0;background:#0b0b0f;color:#f5f5f7;font-family:system-ui,-apple-system,Segoe UI,Roboto}
header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;border-bottom:1px solid #222;background:#0f0f17;position:sticky;top:0}
h1{font-weight:800;letter-spacing:.5px;color:#7e5bef;margin:0}
.toggles label{font-size:.9rem;margin-left:12px}
main{display:grid;grid-template-columns:160px 1fr;gap:12px;padding:12px}
#art{display:flex;align-items:flex-start;justify-content:center}
#art img{width:150px;height:150px;object-fit:cover;border-radius:8px;box-shadow:0 0 0 2px #111, 0 8px 30px rgba(0,0,0,.45)}
#list{display:grid;gap:8px}
.track{display:flex;align-items:center;justify-content:space-between;background:#12121b;border:1px solid #1f1f2b;padding:10px 12px;border-radius:10px}
.meta{display:flex;gap:10px;align-items:center}
.num{opacity:.6;width:28px;text-align:right}
.title{font-weight:700}
.artist{opacity:.7;font-size:.9rem}
.play{border:1px solid #2b2b3a;background:#191925;padding:6px 10px;border-radius:8px;color:#ddd}
.play:hover{background:#23233a}
footer{position:sticky;bottom:0;background:#0f0f17;border-top:1px solid #222;padding:8px}
audio{width:100%}
.actions{display:flex;gap:8px;margin-top:6px}
button#install{border:1px solid #7e5bef;color:#7e5bef;background:transparent;padding:6px 10px;border-radius:8px}

/* Enhanced UI Components & Visual Effects */
.track {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.track:hover {
  transform: translateY(-2px);
  background: #1a1a28;
  border-color: #7e5bef;
  box-shadow: 0 8px 32px rgba(126, 91, 239, 0.2);
}
.track::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(126, 91, 239, 0.1), transparent);
  transition: left 0.5s;
}
.track:hover::before {
  left: 100%;
}

.play {
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}
.play:hover {
  background: #7e5bef;
  color: white;
  transform: scale(1.05);
}
.play:active {
  transform: scale(0.98);
}

button#install {
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}
button#install:hover {
  background: #7e5bef;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(126, 91, 239, 0.4);
}

#art img {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
#art img:hover {
  transform: scale(1.05) rotate(2deg);
  box-shadow: 0 0 0 3px #7e5bef, 0 12px 40px rgba(0,0,0,.6);
}

/* Enhanced Typography */
h1 {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  background: linear-gradient(135deg, #7e5bef, #a855f7, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 30px rgba(126, 91, 239, 0.3);
}

.title {
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  color: #f8fafc;
}

.artist {
  font-size: clamp(0.8rem, 2vw, 0.9rem);
}

/* Color Themes */
:root {
  --primary: #7e5bef;
  --primary-hover: #a855f7;
  --bg-primary: #0b0b0f;
  --bg-secondary: #0f0f17;
  --bg-tertiary: #12121b;
  --border: #222;
  --text-primary: #f5f5f7;
  --text-secondary: #a1a1aa;
}

/* Light Theme */
body.light-theme {
  --primary: #7e5bef;
  --primary-hover: #6d28d9;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --border: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
}

body.light-theme {
  background: var(--bg-primary);
  color: var(--text-primary);
}

body.light-theme header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

body.light-theme .track {
  background: var(--bg-tertiary);
  border-color: var(--border);
}

body.light-theme .track:hover {
  background: #e2e8f0;
  box-shadow: 0 8px 32px rgba(126, 91, 239, 0.15);
}

body.light-theme footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

/* Neon Theme */
body.neon-theme {
  background: #000012;
  color: #00ffff;
}

body.neon-theme h1 {
  color: #ff00ff;
  text-shadow: 0 0 20px #ff00ff;
}

body.neon-theme .track {
  background: #001122;
  border: 1px solid #00ffff;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.2);
}

body.neon-theme .track:hover {
  box-shadow: 0 0 20px rgba(255, 0, 255, 0.4);
  border-color: #ff00ff;
}

/* Responsive Design */
@media (max-width: 768px) {
  main {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 8px;
  }
  
  #art {
    order: -1;
    margin-bottom: 16px;
  }
  
  #art img {
    width: 120px;
    height: 120px;
  }
  
  header {
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .toggles {
    order: 2;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 16px;
  }
  
  .track {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .meta {
    width: 100%;
    justify-content: space-between;
  }
  
  .play {
    align-self: stretch;
    text-align: center;
  }
  
  .actions {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  main {
    padding: 4px;
  }
  
  .track {
    padding: 8px;
  }
  
  #art img {
    width: 100px;
    height: 100px;
  }
  
  h1 {
    font-size: 1.3rem;
  }
  
  .toggles label {
    font-size: 0.8rem;
    margin-left: 8px;
  }
}

/* Tablet Portrait */
@media (min-width: 769px) and (max-width: 1024px) {
  main {
    grid-template-columns: 200px 1fr;
    gap: 20px;
    padding: 16px;
  }
  
  #art img {
    width: 180px;
    height: 180px;
  }
}

/* Layout Improvements */
.track-grid {
  display: grid;
  gap: 6px;
}

.track-number {
  grid-area: num;
  opacity: 0.6;
  font-size: 0.9rem;
  font-weight: 600;
}

.track-title {
  grid-area: title;
  font-weight: 700;
  color: var(--text-primary);
}

.track-artist {
  grid-area: artist;
  opacity: 0.7;
  font-size: 0.85rem;
}

.track-play {
  grid-area: play;
  justify-self: end;
}

@media (min-width: 600px) {
  .track {
    display: grid;
    grid-template-areas: "num title artist play";
    grid-template-columns: 40px 1fr 1fr auto;
    align-items: center;
    gap: 12px;
  }
  
  .num { grid-area: num; }
  .title { grid-area: title; }
  .artist { grid-area: artist; }
  .play { grid-area: play; }
  
  .meta {
    display: contents;
  }
}

/* Loading & Animation States */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.track {
  animation: slideIn 0.3s ease-out;
}

.track:nth-child(odd) {
  animation-delay: 0.1s;
}

.track:nth-child(even) {
  animation-delay: 0.2s;
}

.loading {
  animation: pulse 1.5s infinite;
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus States */
.track:focus-within,
.play:focus,
button#install:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Dan fun theme (when cjpack built with danfun) */
body.danfun {
  background: linear-gradient(135deg, #fff5f8, #ffeaf5, #e0f7fa);
  background-size: 400% 400%;
  animation: pastelShift 12s ease infinite;
  font-family: "Comic Sans MS", "Marker Felt", cursive, sans-serif;
}
@keyframes pastelShift { 0%{background-position:0% 50%} 50%{background-position:100% 50%} 100%{background-position:0% 50%} }
.card.danfun { border:3px dashed #ff8ad9; transform:rotate(-1deg); box-shadow:0 8px 20px rgba(255,138,217,0.3) }
.btn.danfun { background:#ffd580; border:2px solid #ff8ad9; color:#5a004f; font-weight:bold; transform:rotate(1deg) }
