*{margin:0;padding:0;box-sizing:border-box}
:root{
  --bg:#0a0e14;--surface:#131820;--surface2:#1a2030;--surface3:#222c3c;
  --border:#2a3545;--text:#e2e8f0;--text2:#8899aa;--text3:#556677;
  --accent:#58a6ff;--accent2:#1f6feb;--accent-dim:rgba(88,166,255,.12);
  --green:#3fb950;--red:#f85149;--yellow:#d29922;
  --sidebar-w:220px;--queue-w:320px;--player-h:80px;
  --radius:8px;--radius-lg:12px;
}
body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;background:var(--bg);color:var(--text);height:100vh;overflow:hidden}
.hidden{display:none!important}
a{color:var(--accent);text-decoration:none}
a:hover{text-decoration:underline}
button{background:none;border:none;color:var(--text);cursor:pointer;font-family:inherit}

/* Buttons */
.btn-primary{background:var(--accent2);color:#fff;padding:.6rem 1.2rem;border-radius:var(--radius);font-size:.95rem;font-weight:500;width:100%;transition:background .15s}
.btn-primary:hover{background:var(--accent)}
.btn-secondary{background:var(--surface2);color:var(--text);padding:.5rem 1rem;border-radius:var(--radius);font-size:.85rem;border:1px solid var(--border);transition:background .15s}
.btn-secondary:hover{background:var(--surface3)}
.icon-btn{padding:.4rem;border-radius:6px;color:var(--text2);transition:color .15s,background .15s}
.icon-btn:hover{color:var(--text);background:var(--surface2)}
.icon-btn svg{width:20px;height:20px}
.error-msg{color:var(--red);font-size:.85rem;margin-top:.5rem}

/* Auth Screens */
#auth-screen,#room-screen{display:flex;align-items:center;justify-content:center;height:100vh;background:var(--bg)}
.auth-box{background:var(--surface);padding:2.5rem;border-radius:var(--radius-lg);border:1px solid var(--border);width:360px;max-width:90vw}
.auth-logo{font-size:1.8rem;font-weight:700;color:var(--accent);text-align:center;margin-bottom:1.5rem;letter-spacing:-.02em}
.auth-box h2{font-size:1.1rem;color:var(--text2);margin-bottom:1rem;font-weight:500}
.auth-box input{display:block;width:100%;background:var(--surface2);border:1px solid var(--border);color:var(--text);padding:.6rem .8rem;border-radius:var(--radius);font-size:.95rem;margin-bottom:.8rem;outline:none;transition:border-color .15s}
.auth-box input:focus{border-color:var(--accent)}
.auth-switch{font-size:.85rem;color:var(--text2);margin-top:1rem;text-align:center}

/* App Shell */
#app{display:grid;grid-template-columns:var(--sidebar-w) 1fr var(--queue-w);grid-template-rows:1fr var(--player-h);height:100vh;overflow:hidden}
#app.queue-hidden{grid-template-columns:var(--sidebar-w) 1fr}
#app.queue-hidden #queue-panel{display:none}

/* Sidebar */
#sidebar{grid-row:1/3;background:var(--surface);border-right:1px solid var(--border);display:flex;flex-direction:column;padding:.8rem 0;overflow-y:auto}
.sidebar-logo{font-size:1.4rem;font-weight:700;color:var(--accent);padding:0 1rem .8rem;letter-spacing:-.02em}
.nav-item{display:flex;align-items:center;gap:.7rem;padding:.55rem 1rem;margin:1px .5rem;border-radius:var(--radius);color:var(--text2);font-size:.9rem;transition:all .15s;text-decoration:none}
.nav-item:hover{background:var(--surface2);color:var(--text);text-decoration:none}
.nav-item.active{background:var(--accent-dim);color:var(--accent)}
.nav-item svg{width:20px;height:20px;flex-shrink:0}
.sidebar-spacer{flex:1}
.sidebar-room{padding:.4rem 1rem;font-size:.8rem;color:var(--text2)}
.sidebar-users{padding:0 1rem .4rem;display:flex;flex-wrap:wrap;gap:.3rem}
.user-pill{font-size:.75rem;padding:.15rem .5rem;border-radius:12px;background:var(--surface2);color:var(--text2);display:flex;align-items:center;gap:.3rem}
.user-pill::before{content:'';width:6px;height:6px;border-radius:50%;background:var(--green)}
.sidebar-status{padding:.5rem 1rem;font-size:.8rem;display:flex;align-items:center;gap:.4rem;border-top:1px solid var(--border)}
.status-dot{width:8px;height:8px;border-radius:50%;background:var(--yellow)}
.status-dot.connected{background:var(--green)}
.status-dot.disconnected{background:var(--red)}

/* Main Content */
#content{overflow-y:auto;padding:1.5rem 2rem;scrollbar-width:thin;scrollbar-color:var(--surface3) transparent}
#content::-webkit-scrollbar{width:6px}
#content::-webkit-scrollbar-thumb{background:var(--surface3);border-radius:3px}

/* Page Headers */
.page-title{font-size:1.6rem;font-weight:700;margin-bottom:1.2rem}
.section-title{font-size:1rem;font-weight:600;color:var(--text2);margin-bottom:.8rem;text-transform:uppercase;letter-spacing:.04em;font-size:.8rem}
.section{margin-bottom:2rem}

/* Horizontal Scroll Row */
.h-scroll{display:flex;gap:1rem;overflow-x:auto;padding-bottom:.5rem;scroll-snap-type:x proximity;-webkit-overflow-scrolling:touch}
.h-scroll::-webkit-scrollbar{height:4px}
.h-scroll::-webkit-scrollbar-thumb{background:var(--surface3);border-radius:2px}

/* Album/Artist Cards */
.card{flex:0 0 160px;cursor:pointer;padding:.6rem;border-radius:var(--radius);transition:background .15s;scroll-snap-align:start}
.card:hover{background:var(--surface2)}
.card img{width:100%;aspect-ratio:1;object-fit:cover;border-radius:6px;background:var(--surface2);display:block}
.card .card-title{font-size:.85rem;font-weight:500;margin-top:.5rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.card .card-sub{font-size:.78rem;color:var(--text2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* Album/Artist Grid */
.card-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(155px,1fr));gap:.5rem}

/* Track List */
.track-row{display:flex;align-items:center;gap:.8rem;padding:.45rem .6rem;border-radius:var(--radius);transition:background .15s;cursor:default}
.track-row:hover{background:var(--surface2)}
.track-row.active{background:var(--accent-dim)}
.track-row .track-num{width:24px;text-align:center;font-size:.8rem;color:var(--text3);flex-shrink:0}
.track-row img{width:40px;height:40px;border-radius:4px;object-fit:cover;background:var(--surface2);flex-shrink:0}
.track-row .track-info{flex:1;min-width:0}
.track-row .track-name{font-size:.9rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.track-row .track-artist{font-size:.8rem;color:var(--text2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.track-row .track-duration{font-size:.8rem;color:var(--text3);flex-shrink:0;margin-right:.3rem}
.track-row .track-actions{display:flex;gap:.2rem;opacity:0;transition:opacity .15s}
.track-row:hover .track-actions{opacity:1}
.track-row .fav-btn{color:var(--text3)}
.track-row .fav-btn.is-fav{color:var(--red)}

/* Search Input */
.search-wrap{position:relative;margin-bottom:1.5rem}
.search-wrap input{width:100%;background:var(--surface2);border:1px solid var(--border);color:var(--text);padding:.7rem 1rem .7rem 2.5rem;border-radius:var(--radius-lg);font-size:1rem;outline:none;transition:border-color .15s}
.search-wrap input:focus{border-color:var(--accent)}
.search-wrap svg{position:absolute;left:.8rem;top:50%;transform:translateY(-50%);width:18px;height:18px;color:var(--text3)}
.search-hint{font-size:.8rem;color:var(--text3);padding:.5rem 0}

/* Queue Panel */
#queue-panel{grid-row:1;background:var(--surface);border-left:1px solid var(--border);display:flex;flex-direction:column;overflow:hidden}
.queue-header{display:flex;align-items:center;justify-content:space-between;padding:.8rem 1rem;border-bottom:1px solid var(--border)}
.queue-header h2{font-size:1rem;font-weight:600}
.queue-actions{display:flex;gap:.3rem}
#queue-list{flex:1;overflow-y:auto;padding:.4rem}
#queue-list::-webkit-scrollbar{width:4px}
#queue-list::-webkit-scrollbar-thumb{background:var(--surface3);border-radius:2px}

.q-item{display:flex;align-items:center;gap:.6rem;padding:.4rem .5rem;border-radius:var(--radius);transition:background .15s;cursor:default}
.q-item:hover{background:var(--surface2)}
.q-item.active{background:var(--accent-dim);border-left:3px solid var(--accent)}
.q-item img{width:36px;height:36px;border-radius:4px;object-fit:cover;background:var(--surface2);flex-shrink:0}
.q-item .q-info{flex:1;min-width:0}
.q-item .q-title{font-size:.82rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.q-item .q-artist{font-size:.75rem;color:var(--text2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.q-item .q-added{font-size:.7rem;color:var(--accent);opacity:.7}
.q-item .q-remove{opacity:0;color:var(--text3);padding:.2rem;transition:opacity .15s}
.q-item:hover .q-remove{opacity:1}
.q-item .q-remove:hover{color:var(--red)}

/* Player Bar */
#player-bar{grid-column:2/4;grid-row:2;background:var(--surface);border-top:1px solid var(--border);display:flex;align-items:center;padding:0 1rem;gap:1rem}
#app.queue-hidden #player-bar{grid-column:2/3}
.pb-now{display:flex;align-items:center;gap:.7rem;width:200px;min-width:0;cursor:pointer}
#pb-cover{width:48px;height:48px;border-radius:4px;object-fit:cover;background:var(--surface2)}
.pb-info{min-width:0}
#pb-title{font-size:.88rem;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#pb-artist{font-size:.78rem;color:var(--text2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pb-center{flex:1;display:flex;flex-direction:column;align-items:center;gap:.3rem;max-width:600px;margin:0 auto}
.pb-controls{display:flex;align-items:center;gap:.8rem}
.pb-controls .icon-btn svg{width:18px;height:18px}
.pb-play-btn{width:36px;height:36px;border-radius:50%;background:var(--text);display:flex;align-items:center;justify-content:center;transition:transform .1s}
.pb-play-btn:hover{transform:scale(1.06)}
.pb-play-btn svg{width:16px;height:16px;color:var(--bg);fill:var(--bg)}
.pb-progress{display:flex;align-items:center;gap:.5rem;width:100%}
.pb-time{font-size:.72rem;color:var(--text3);min-width:36px;text-align:center}
.pb-right{display:flex;align-items:center;gap:.5rem;width:200px;justify-content:flex-end}
.pb-volume{display:flex;align-items:center;gap:.4rem}
.pb-volume .vol-icon{width:18px;height:18px;color:var(--text2);flex-shrink:0}

/* Range inputs */
input[type="range"]{-webkit-appearance:none;appearance:none;height:4px;background:var(--surface3);border-radius:2px;outline:none;cursor:pointer;flex:1}
input[type="range"]::-webkit-slider-thumb{-webkit-appearance:none;width:12px;height:12px;border-radius:50%;background:var(--accent);opacity:0;transition:opacity .15s}
input[type="range"]:hover::-webkit-slider-thumb{opacity:1}
.pb-progress input[type="range"]{height:3px}
#pb-volume{width:90px}

/* Now Playing Fullscreen */
#np-fullscreen{position:fixed;inset:0;z-index:100;background:var(--bg);display:flex;flex-direction:column;align-items:center;justify-content:center;animation:slideUp .3s ease}
@keyframes slideUp{from{transform:translateY(100%)}to{transform:translateY(0)}}
#np-close{position:absolute;top:1rem;right:1rem}
#np-close svg{width:28px;height:28px}
.np-content{text-align:center;width:90%;max-width:420px}
#np-cover{width:100%;max-width:360px;aspect-ratio:1;object-fit:cover;border-radius:var(--radius-lg);background:var(--surface2);margin-bottom:1.5rem;box-shadow:0 20px 60px rgba(0,0,0,.5)}
.np-title{font-size:1.4rem;font-weight:700;margin-bottom:.3rem}
.np-artist{font-size:1rem;color:var(--text2);margin-bottom:1.5rem}
.np-progress{margin-bottom:1rem}
.np-progress input[type="range"]{width:100%;height:5px}
.np-progress input[type="range"]::-webkit-slider-thumb{opacity:1}
.np-times{display:flex;justify-content:space-between;font-size:.78rem;color:var(--text3);margin-top:.4rem}
.np-controls{display:flex;align-items:center;justify-content:center;gap:2rem}
.np-controls .icon-btn svg{width:28px;height:28px}
.np-play-btn{width:56px;height:56px;border-radius:50%;background:var(--text);display:flex;align-items:center;justify-content:center}
.np-play-btn svg{width:24px;height:24px;color:var(--bg);fill:var(--bg)}

/* Tabs */
.tabs{display:flex;gap:.3rem;margin-bottom:1.2rem;border-bottom:1px solid var(--border);padding-bottom:.3rem}
.tab{padding:.4rem .8rem;border-radius:var(--radius) var(--radius) 0 0;font-size:.88rem;color:var(--text2);transition:all .15s}
.tab:hover{color:var(--text)}
.tab.active{color:var(--accent);border-bottom:2px solid var(--accent);margin-bottom:-1px}

/* Playlist create */
.create-row{display:flex;gap:.5rem;margin-bottom:1rem}
.create-row input{flex:1;background:var(--surface2);border:1px solid var(--border);color:var(--text);padding:.5rem .7rem;border-radius:var(--radius);outline:none;font-size:.9rem}
.create-row input:focus{border-color:var(--accent)}
.create-row button{padding:.5rem 1rem}

/* Empty state */
.empty{text-align:center;padding:3rem 1rem;color:var(--text3)}
.empty svg{width:48px;height:48px;margin-bottom:.8rem;opacity:.4}
.empty p{font-size:.95rem}

/* Artist letter group */
.letter-group{margin-bottom:1.5rem}
.letter-group h3{font-size:.85rem;color:var(--text3);margin-bottom:.5rem;padding-left:.3rem}
.artist-row{display:flex;align-items:center;gap:.8rem;padding:.45rem .6rem;border-radius:var(--radius);cursor:pointer;transition:background .15s}
.artist-row:hover{background:var(--surface2)}
.artist-row .artist-name{font-size:.9rem}
.artist-row .artist-count{font-size:.8rem;color:var(--text3);margin-left:auto}

/* Detail page header */
.detail-header{display:flex;gap:1.5rem;margin-bottom:1.5rem;align-items:flex-end}
.detail-header img{width:200px;height:200px;border-radius:var(--radius);object-fit:cover;background:var(--surface2);flex-shrink:0}
.detail-header .detail-info{min-width:0}
.detail-header .detail-type{font-size:.75rem;text-transform:uppercase;letter-spacing:.06em;color:var(--text3);margin-bottom:.3rem}
.detail-header .detail-name{font-size:2rem;font-weight:700;margin-bottom:.3rem}
.detail-header .detail-meta{font-size:.9rem;color:var(--text2);margin-bottom:.8rem}
.detail-actions{display:flex;gap:.5rem}

/* Loading */
.loading{text-align:center;padding:2rem;color:var(--text3)}.loading::after{content:'';display:inline-block;width:18px;height:18px;border:2px solid var(--surface3);border-top-color:var(--accent);border-radius:50%;animation:spin .6s linear infinite;margin-left:.5rem;vertical-align:middle}
@keyframes spin{to{transform:rotate(360deg)}}

/* Mobile */
@media(max-width:900px){
  :root{--sidebar-w:60px;--queue-w:0px}
  .nav-item span{display:none}
  .nav-item{justify-content:center;padding:.6rem}
  .sidebar-logo{text-align:center;padding:0 0 .8rem;font-size:1.1rem}
  .sidebar-room,.sidebar-users,.sidebar-status .status-text{display:none}
  .sidebar-status{justify-content:center}
  #queue-panel{display:none;position:fixed;right:0;top:0;bottom:var(--player-h);width:300px;z-index:50}
  #app.queue-visible #queue-panel{display:flex}
  #player-bar{grid-column:2/3}
  .pb-right .pb-volume{display:none}
  .pb-now{width:140px}
  #content{padding:1rem}
  .detail-header{flex-direction:column;align-items:center;text-align:center}
  .detail-header img{width:160px;height:160px}
}
@media(max-width:600px){
  :root{--sidebar-w:0px}
  #sidebar{display:none}
  #app{grid-template-columns:1fr}
  #player-bar{grid-column:1}
}
