:root {
	--bg-primary: #0b0d0f;
	--bg-secondary: #0f1113;
	--bg-card: #121416;
	--accent: #1db954;
	--accent-hover: #1ed760;
	--text-primary: #e8eef0;
	--text-secondary: #9aa5a7;
	--text-muted: #6c7678;
	--border: #1e2224;
	--radius: 12px;
	--shadow: 0 12px 28px rgba(0,0,0,0.6);
	--glass: rgba(255,255,255,0.03);
	--transition: all 0.18s cubic-bezier(.2,.9,.2,1);
	--container-width: 1100px;
	--player-height: 84px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
.app-layout { display: flex; min-height: 100vh; background: radial-gradient(1200px 600px at 10% 10%, rgba(29,185,84,0.04), transparent), linear-gradient(180deg, rgba(255,255,255,0.01), transparent); }
body { font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, 'Helvetica Neue', Arial; background: var(--bg-primary); color: var(--text-primary); padding-top: calc(var(--player-height) + 18px); -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale; }

/* Center main content and enforce container width for readability */
.main-content { max-width: var(--container-width); margin: 0 auto; }

/* Accessibility: focus outlines for keyboard users */
.nav-item:focus, .btn:focus, .player-btn:focus, .play-btn:focus { outline: 3px solid rgba(29,185,84,0.12); outline-offset: 2px; }

/* Slight lift on interactive elements */
.btn:hover { box-shadow: 0 8px 20px rgba(0,0,0,0.45); }
.sidebar { width: 250px; background: linear-gradient(180deg, var(--bg-secondary), rgba(0,0,0,0.02)); padding: 20px; display: flex; flex-direction: column; border-right: 1px solid rgba(255,255,255,0.02); }
.logo { font-size: 1.35em; font-weight: 700; display: flex; align-items: center; gap: 10px; margin-bottom: 28px; color: var(--accent); letter-spacing: 0.4px; }
.logo span { font-weight: 600; letter-spacing: 0.6px; }

/* Avatar styles */
.sidebar-avatar, .profile-avatar { border-radius: 50%; object-fit: cover; background: linear-gradient(180deg, rgba(255,255,255,0.02), var(--bg-card)); border: 1px solid rgba(255,255,255,0.03); }
.sidebar-avatar { width: 40px; height: 40px; display:inline-block; }
.sidebar-avatar--placeholder, .profile-avatar--placeholder { display:flex; align-items:center; justify-content:center; color:var(--text-muted); width:40px; height:40px; border-radius:50%; }
.profile-avatar { width:84px; height:84px; }
.profile-avatar--placeholder { width:84px; height:84px; }
.form-input[type="file"] { padding:8px 10px; }
.nav-item { display: block; padding: 12px 16px; color: var(--text-secondary); text-decoration: none; border-radius: var(--radius); margin-bottom: 8px; transition: var(--transition); }
.nav-item:hover, .nav-item.active { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { box-shadow: inset 6px 0 0 rgba(29,185,84,0.06); background: linear-gradient(180deg, rgba(255,255,255,0.008), var(--bg-card)); }
.nav-item i { margin-right: 10px; width: 20px; text-align: center; }
.main-content { flex: 1 1 auto; padding: 28px 36px; overflow-y: auto; padding-bottom: 160px; max-width: var(--container-width); margin: 0 auto; width: auto; }
.library-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.library-header h1 { font-size: 2em; }

/* Make search box take more space in the header */
.library-header > div { display:flex; gap:12px; align-items:center; width:70%; }
.library-header .search-box { position: relative; flex: 1 1 520px; max-width: 760px; min-width: 220px; }
.library-header .search-box input { width: 100%; }
@media (max-width: 900px) {
	.library-header { flex-direction: column; align-items: stretch; gap: 12px; }
	.library-header > div { width: 100%; }
	.library-header .search-box { max-width: 100%; }
}
	.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; color: var(--text-secondary); text-decoration: none; border-radius: 10px; margin-bottom: 8px; transition: var(--transition); }
	.nav-item .nav-text { flex:1 }
	.nav-item i { width:20px; text-align:center }
	.nav-item:hover { background: linear-gradient(90deg, rgba(255,255,255,0.012), rgba(0,0,0,0.04)); color: var(--text-primary); transform: translateX(3px); }
	.nav-item.active { background: linear-gradient(90deg, rgba(29,185,84,0.06), rgba(0,0,0,0.03)); color: var(--text-primary); box-shadow: inset 6px 0 0 rgba(29,185,84,0.12); }
.search-box input { width: 100%; padding: 12px 16px 12px 44px; background: linear-gradient(180deg,var(--bg-card),var(--glass)); border: 1px solid rgba(255,255,255,0.03); border-radius: 22px; color: var(--text-primary); outline: none; box-shadow: inset 0 1px 0 rgba(255,255,255,0.01); }
.search-box input:focus { border-color: var(--accent); box-shadow: 0 6px 18px rgba(29,185,84,0.06); }
.search-box i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-results { position: absolute; top: 100%; left: 0; right: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); margin-top: 8px; max-height: 300px; overflow-y: auto; display: none; z-index: 10; }
.search-results div { padding: 10px 14px; cursor: pointer; transition: var(--transition); }
.search-results div:hover { background: var(--bg-primary); }
.track-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 24px; margin-bottom: 40px; align-items: start; grid-auto-rows: auto; justify-items: stretch; }

/* Guarantee at least 2 columns on medium+ screens */
@media (min-width: 700px) {
	.track-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}
@media (min-width: 1100px) {
	.track-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
}
.track-card { background: linear-gradient(180deg, rgba(255,255,255,0.01), var(--bg-card)); border-radius: calc(var(--radius) - 2px); overflow: hidden; transition: var(--transition); cursor: pointer; position: relative; border: 1px solid rgba(255,255,255,0.02); display:flex; flex-direction:column; box-sizing:border-box; }
.track-card:hover { transform: translateY(-6px) scale(1.01); box-shadow: var(--shadow); }
.track-cover { aspect-ratio: 1; background: linear-gradient(135deg, rgba(255,255,255,0.02), rgba(0,0,0,0.08)); display: flex; align-items: center; justify-content: center; font-size: 2.4em; color: var(--text-muted); position: relative; flex: 0 0 auto; }
.track-play-btn { position: absolute; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; opacity: 0; transition: var(--transition); color: white; font-size: 2em; }
.track-card:hover .track-play-btn { opacity: 1; }
.track-play-btn.is-playing { background: linear-gradient(90deg, rgba(29,185,84,0.18), rgba(29,185,84,0.08)); transform: scale(1.04); box-shadow: 0 8px 24px rgba(29,185,84,0.12); }
.track-play-btn.is-playing i { transform: scale(1.05); }
.track-info { padding: 16px; display:flex; flex-direction:column; gap:8px; flex:1 1 auto; }
.track-title { font-weight: 600; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1rem; }
.track-artist { color: var(--text-secondary); font-size: 0.9em; margin-bottom: 10px; }
.track-meta { display: flex; gap: 12px; color: var(--text-muted); font-size: 0.85em; }
/* Make share button more visible on larger screens */
.share-track-btn { padding: 6px 8px; border-radius: 8px; border: 1px solid transparent; background: transparent; display: inline-flex; align-items: center; gap: 8px; color: var(--text-secondary); }
.share-track-btn i { font-size: 0.95em; }
.share-track-btn:hover { background: var(--glass); color: var(--text-primary); border-color: rgba(255,255,255,0.03); }
.share-text { display: none; font-weight: 600; }
@media (min-width: 700px) {
	.share-text { display: inline-block; }
}
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 30px; }
.page-item { padding: 8px 14px; background: var(--bg-card); border-radius: 8px; text-decoration: none; color: var(--text-secondary); }
.page-item.active { background: var(--accent); color: white; }
.player-bar { position: fixed; top: 0; left: 260px; right: 0; height: var(--player-height); background: linear-gradient(180deg, rgba(0,0,0,0.10), rgba(0,0,0,0.12)); border-bottom: 1px solid rgba(255,255,255,0.02); display: flex; align-items: center; justify-content: space-between; padding: 0 26px; z-index: 140; backdrop-filter: blur(6px); }
.player-track-info { display: flex; align-items: center; gap: 14px; width: 280px; }
.player-thumb { width: 56px; height: 56px; background: linear-gradient(180deg, rgba(255,255,255,0.02), var(--bg-card)); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.player-details { line-height: 1.4; }
.player-title { font-weight: 600; font-size: 0.95em; }
.player-artist { color: var(--text-secondary); font-size: 0.8em; }
.player-controls { flex: 1; max-width: 600px; margin: 0 20px; }
.player-buttons { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 6px; }
.player-btn, .play-btn { background: none; border: none; color: var(--text-secondary); cursor: pointer; transition: var(--transition); }
.player-btn:hover, .play-btn:hover { color: var(--text-primary); }
.player-btn.active-reaction { color: var(--accent); }
.like-count, .dislike-count { font-weight: 700; margin-left: 6px; color: var(--text-primary); }
.play-btn { width: 42px; height: 42px; background: var(--accent); border-radius: 50%; color: white; display: flex; align-items: center; justify-content: center; font-size: 1.1em; }
.play-btn:hover { background: var(--accent-hover); transform: scale(1.05); }
/* Visual state when playing */
.play-btn.is-playing { background: linear-gradient(90deg, #17c964 0%, #0fb357 100%); box-shadow: 0 10px 30px rgba(29,185,84,0.22); transform: scale(1.08); }
.play-btn.is-playing i { transform: scale(1.05) rotate(0deg); }
.play-btn i { transition: transform 200ms ease, color 120ms ease; }
.play-btn.is-playing::after { content: ''; position: absolute; width: 56px; height: 56px; border-radius: 50%; left: 50%; top: 50%; transform: translate(-50%,-50%); box-shadow: 0 0 0 0 rgba(29,185,84,0.14); animation: pulse 1600ms infinite; pointer-events: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(29,185,84,0.16); } 70% { box-shadow: 0 0 0 18px rgba(29,185,84,0.00); } 100% { box-shadow: 0 0 0 0 rgba(29,185,84,0.00); } }
.player-progress { display: flex; align-items: center; gap: 10px; width: 100%; }
.progress-time { color: var(--text-muted); font-size: 0.75em; min-width: 35px; text-align: center; }
.progress-bar { flex: 1; height: 4px; background: var(--bg-card); border-radius: 2px; cursor: pointer; position: relative; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; width: 0%; transition: width 0.1s linear; }
.player-volume { width: 160px; display: flex; align-items: center; gap: 10px; color: var(--text-muted); }
.volume-slider { -webkit-appearance: none; width: 100%; height: 4px; background: var(--bg-card); border-radius: 2px; outline: none; }
.volume-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; background: var(--accent); border-radius: 50%; cursor: pointer; }
.flash-message { padding: 14px 20px; border-radius: 10px; margin-bottom: 20px; background: linear-gradient(180deg, rgba(255,255,255,0.01), var(--bg-card)); border: 1px solid rgba(255,255,255,0.02); }
.flash-error { border-color: #e74c3c; color: #e74c3c; }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.04); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.07); }

.sidebar { width: 260px; padding: 22px; }
.sidebar-top { display:flex; flex-direction:column; gap:14px; }
.sidebar-profile { display:flex; gap:12px; align-items:center; padding:8px; border-radius:10px; background: linear-gradient(180deg, rgba(255,255,255,0.01), transparent); }
.sidebar-profile-info { display:flex; flex-direction:column; min-width:0 }
.sidebar-username { font-weight:700; color:var(--text-primary); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sidebar-profile-link { color:var(--text-muted); font-size:0.85em; text-decoration:none }
.sidebar-profile-link:hover { color:var(--text-primary) }
.nav-sections { margin-top:12px }
.nav-section { margin-bottom:12px }
.nav-section-title { color:var(--text-muted); font-size:0.78em; padding:8px 6px; text-transform:uppercase; letter-spacing:0.8px }

@media (max-width: 900px) {
    /* mobile: off-canvas sidebar instead of display:none */
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 200; transform: translateX(-100%); transition: transform 0.22s ease; width: 260px; padding: 18px; }
    .sidebar.show { transform: translateX(0); }
    .player-bar { left: 0; height: 76px; padding: 0 14px; }
    .main-content { padding: 18px; }
    .track-grid { gap: 16px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
    .app-layout { padding-left: 0; }
}

/* Sidebar toggle button for small screens */
.sidebar-toggle { display: none; position: fixed; top: 10px; left: 10px; z-index: 300; background: var(--bg-card); color: var(--text-primary); border: 1px solid rgba(255,255,255,0.03); padding:8px 10px; border-radius:10px; box-shadow: 0 6px 18px rgba(0,0,0,0.5); }
.sidebar-toggle i { font-size: 1.05em }
@media (max-width:900px) {
	.sidebar-toggle { display: block }
}

@media (min-width: 1200px) {
    .main-content { max-width: var(--container-width); }
}

.site-footer { padding: 14px 20px; color: var(--text-muted); background: transparent; display: block; border-top: 1px solid rgba(255,255,255,0.02); margin-top: 24px; }
.site-footer .footer-inner { max-width: var(--container-width); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.site-footer .footer-stats { display: flex; align-items: center; gap: 12px; font-size: 0.95em; }
.flash-error { border-color: #e74c3c; color: #e74c3c; }

/* Playlists */
.playlist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; margin-top: 12px; }
.playlist-card { background: linear-gradient(180deg, rgba(255,255,255,0.01), var(--bg-card)); border: 1px solid rgba(255,255,255,0.02); padding: 12px; border-radius: 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; transition: var(--transition); }
.playlist-card:hover { transform: translateY(-4px); box-shadow: 0 10px 22px rgba(0,0,0,0.5); }
.playlist-body { display:flex; align-items:center; gap:12px; }
.playlist-thumb { width:56px; height:56px; border-radius:8px; background: linear-gradient(135deg, rgba(255,255,255,0.02), rgba(0,0,0,0.06)); display:flex; align-items:center; justify-content:center; color:var(--text-muted); font-size:1.4em; }
.playlist-info { min-width:0 }
.playlist-title { display:block; font-weight:700; color:var(--text-primary); text-decoration:none; /* allow wrapping and clamp to two lines */ display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; }
.playlist-meta { color:var(--text-muted); font-size:0.9em; margin-top:4px }
.playlist-actions { display:flex; gap:8px; align-items:center }

.playlist-actions { flex-shrink: 0; }

/* Buttons */
.btn { padding:8px 12px; border-radius:8px; border:1px solid transparent; cursor:pointer; font-size:0.95em; text-decoration:none; display:inline-flex; align-items:center; gap:8px; }
.btn-ghost { background:transparent; color:var(--text-secondary); border-color:transparent; }
.btn-ghost:hover { color:var(--text-primary); background:var(--glass); }
.btn-danger { background:rgba(231,76,60,0.06); color:#e5736b; border-color:rgba(231,76,60,0.12); }
.btn-danger:hover { background:rgba(231,76,60,0.12); color:#e74c3c; }

@media (max-width: 900px) {
	.sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 200; transform: translateX(-100%); transition: transform 0.22s ease; width: 260px; padding: 18px; }
	.sidebar.show { transform: translateX(0); }
	.player-bar { left: 0; height: 76px; padding: 0 14px; }
	body { padding-top: calc(76px + 12px); }
	.main-content { padding: 18px; }
	.track-grid { gap: 16px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
	.app-layout { padding-left: 0; }
}
/* Auth / forms */
.auth-container { max-width: 480px; margin: 36px auto; padding: 0 12px; }
.auth-card { background: linear-gradient(180deg, rgba(255,255,255,0.01), var(--bg-card)); border: 1px solid rgba(255,255,255,0.02); padding: 22px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.auth-card h2 { margin: 0 0 12px 0; font-size: 1.25rem; }
.form-row { display:flex; flex-direction:column; gap:8px; margin-bottom:10px; }
.form-row label { color:var(--text-secondary); font-size:0.95em; }
.form-input { padding:10px 12px; border-radius:8px; border:1px solid rgba(255,255,255,0.03); background: linear-gradient(180deg,var(--bg-card), rgba(255,255,255,0.01)); color:var(--text-primary); outline:none; transition: box-shadow var(--transition), border-color var(--transition); }
.form-input:focus { border-color: var(--accent); box-shadow: 0 10px 24px rgba(29,185,84,0.06); }
.btn-primary { background: var(--accent); color: #fff; border: none; padding: 10px 14px; border-radius: 8px; cursor: pointer; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

/* Create playlist button: larger and more prominent */
.create-playlist-btn {
	padding: 10px 18px;
	font-weight: 800;
	letter-spacing: 0.2px;
	color: #ffffff;
	background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
	border: none;
	border-radius: 999px;
	align-items: center;
	display: inline-flex;
	gap: 12px;
	box-shadow: 0 10px 30px rgba(37,99,235,0.12);
	transition: transform 180ms cubic-bezier(.2,.9,.2,1), box-shadow 200ms, opacity 120ms;
}
.create-playlist-btn .create-text { display: inline-block; }
.create-playlist-btn i { font-size: 1.05em; color: rgba(255,255,255,0.95); }
@media (max-width: 700px) {
	.create-playlist-btn { padding: 8px 12px; font-size: 0.95em; }
	.create-playlist-btn .create-text { display: none; }
}
.create-playlist-btn:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 18px 40px rgba(6,182,212,0.16); }
.create-playlist-btn:active { transform: translateY(-1px) scale(0.98); }
.create-playlist-btn:focus { outline: none; box-shadow: 0 0 0 6px rgba(6,182,212,0.12); }

/* Specific styling for header/library button by id to ensure exact look */
#createPlaylistBtn, #createPlaylistBtnSidebar {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 10px 18px;
	font-weight: 800;
	font-size: 0.98rem;
	color: #ffffff;
	background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
	border-radius: 999px;
	border: none;
	box-shadow: 0 12px 30px rgba(37,99,235,0.14);
	transition: transform 160ms ease, box-shadow 160ms ease, opacity 120ms ease;
}
#createPlaylistBtn i, #createPlaylistBtnSidebar i { color: rgba(255,255,255,0.95); font-size:1.05em }
#createPlaylistBtn:hover, #createPlaylistBtnSidebar:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 18px 40px rgba(37,99,235,0.18); }
#createPlaylistBtn:active, #createPlaylistBtnSidebar:active { transform: translateY(-1px) scale(0.98); }
#createPlaylistBtn:focus, #createPlaylistBtnSidebar:focus { outline: none; box-shadow: 0 0 0 6px rgba(37,99,235,0.12); }

@media (max-width:700px) {
	#createPlaylistBtn, #createPlaylistBtnSidebar { padding: 8px 12px; }
	#createPlaylistBtn .create-text, #createPlaylistBtnSidebar .create-text { display: none; }
}

@media (max-width:480px) {
	.auth-container { padding: 0 8px; }
	.auth-card { padding: 16px; }
}

/* Track comments */
.track-card { position: relative; }
.comment-btn { padding:6px 8px; border-radius:8px; background:transparent; color:var(--text-secondary); border:1px solid transparent; }
.comment-btn:hover { color:var(--text-primary); background:var(--glass); }
.track-meta { display:flex; gap:12px; align-items:center; margin-top:6px; }
.track-meta .meta-item { display:inline-flex; align-items:center; gap:6px; color:var(--text-muted); font-size:0.9em; }
.track-meta .comment-btn { color:var(--text-secondary); border-radius:6px; padding:6px 8px; }
.track-meta .comment-btn .comment-count { font-weight:600; margin-left:6px; color:var(--text-primary); }
.track-comments { margin-top:12px; padding:12px; background:linear-gradient(180deg, rgba(255,255,255,0.01), rgba(0,0,0,0.04)); border-radius:8px; border:1px solid rgba(255,255,255,0.02); }
.comments-list { max-height:220px; overflow:auto; display:flex; flex-direction:column; gap:8px; margin-bottom:8px; }
.comment { padding:8px 10px; background: rgba(0,0,0,0.12); border-radius:8px; }
.comment .meta { color:var(--text-muted); font-size:0.85em; margin-bottom:6px }
.comment .body { color:var(--text-primary); white-space:pre-wrap }
.comment-avatar { border-radius:50%; object-fit:cover; width:40px; height:40px; border:1px solid rgba(255,255,255,0.03); }
.comment-avatar--placeholder { display:flex; align-items:center; justify-content:center; color:var(--text-muted); width:40px; height:40px; border-radius:50%; background:linear-gradient(180deg, rgba(255,255,255,0.01), rgba(0,0,0,0.04)); }
.comment-form .form-input { width:100%; }

/* Override meta-item defaults for the share button to increase contrast on desktop */
.track-meta .meta-item.share-track-btn, .track-meta .share-track-btn {
	color: var(--text-primary);
	border-color: rgba(255,255,255,0.03);
	background: rgba(255,255,255,0.02);
}
.track-meta .share-track-btn:hover { background: linear-gradient(90deg, rgba(29,185,84,0.06), rgba(255,255,255,0.01)); color: var(--text-primary); }
.track-meta .share-track-btn .share-text { display: none; }
@media (min-width:700px) {
	.track-meta .share-track-btn .share-text { display: inline-block; }
}

/* Position share button inside cover (top-left) */
.track-cover .share-track-btn { position: absolute; top: 8px; left: 8px; z-index: 20; padding: 6px 8px; background: rgba(0,0,0,0.45); color: var(--text-primary); border-radius: 8px; border: 1px solid rgba(255,255,255,0.03); }
.track-cover .share-track-btn i { margin-right: 6px; }
.track-cover .share-track-btn:hover { background: linear-gradient(90deg, rgba(29,185,84,0.08), rgba(255,255,255,0.02)); color: var(--text-primary); }
.track-cover .share-text { display: none; }
@media (min-width:700px) { .track-cover .share-text { display: inline-block; } }
