:root {
  --spotify: #1DB954; --spotify-dark: #1AA34A;
  --bg: #0a0a0a; --surface: #141414; --surface-2: #1e1e1e; --surface-3: #282828;
  --border: #333; --text: #fff; --text-2: #b3b3b3; --text-3: #727272;
  --radius: 12px; --t: 200ms ease;
  --orange: #F97316; --orange-dark: #EA580C;
}
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { font-family: 'Plus Jakarta Sans', -apple-system, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; -webkit-font-smoothing: antialiased; min-height: 100vh; }

/* Header */
.header { position: sticky; top: 0; z-index: 50; background: rgba(10,10,10,0.85); backdrop-filter: blur(16px); border-bottom: 1px solid var(--border); padding: 16px 24px; }
.header-inner { max-width: 1000px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; }
.header h1 { font-size: 1.3rem; font-weight: 400; display: flex; align-items: center; gap: 10px; font-family: 'Righteous', cursive; letter-spacing: 0.5px; }
.header h1 img { width: 28px; height: 28px; object-fit: contain; }
.user-info { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--text-2); }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); }
.btn-logout { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); padding: 6px 14px; border-radius: 8px; font-size: 0.78rem; font-weight: 600; cursor: pointer; transition: all var(--t); font-family: inherit; }
.btn-logout:hover { background: var(--surface-3); color: var(--text); }

/* Login */
.login-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 80vh; gap: 24px; padding: 32px; }
.login-icon { font-size: 4rem; }
.login-screen h2 { font-size: 1.8rem; font-weight: 800; }
.login-screen p { color: var(--text-2); font-size: 0.95rem; max-width: 400px; text-align: center; }
.btn-spotify { background: var(--spotify); color: #000; border: none; padding: 14px 36px; border-radius: 50px; font-size: 1rem; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 10px; transition: all var(--t); font-family: inherit; }
.btn-spotify:hover { background: var(--spotify-dark); transform: scale(1.03); }

/* Main */
.main { max-width: 1000px; margin: 0 auto; padding: 24px; }
.playlists-title { font-size: 1.4rem; font-weight: 800; margin-bottom: 20px; }
.playlists-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 40px; }

/* Playlist cards */
.playlist-card { background: var(--surface); border-radius: var(--radius); padding: 16px; cursor: pointer; transition: all 0.4s ease; border: 1px solid transparent; position: relative; }
.playlist-card:hover { background: var(--surface-2); border-color: var(--border); transform: translateY(-2px); }
.playlist-card.active { border-color: var(--spotify); background: var(--surface-2); }
.playlist-cover { width: 100%; aspect-ratio: 1; border-radius: 8px; background: var(--surface-3); margin-bottom: 12px; overflow: hidden; }
.playlist-cover img { width: 100%; height: 100%; object-fit: cover; }
.playlist-card h3 { font-size: 0.88rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.playlist-card .meta { font-size: 0.75rem; color: var(--text-3); margin-top: 4px; }
.playlist-card .fav-btn { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,0.6); border: none; border-radius: 50%; width: 28px; height: 28px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; transition: all var(--t); opacity: 0; z-index: 2; }
.playlist-card:hover .fav-btn, .playlist-card .fav-btn.is-fav { opacity: 1; }
.playlist-card .fav-btn.is-fav { color: #FFD93D; }
.playlist-card .fav-btn:not(.is-fav) { color: var(--text-3); }
.playlist-card .fav-btn:hover { transform: scale(1.15); }
.playlist-card .fav-btn.pop { animation: favPop 0.4s ease; }
@keyframes favPop { 0% { transform: scale(1); } 30% { transform: scale(1.5); } 50% { transform: scale(0.9); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
.playlist-card.loading-card { pointer-events: none; }
.playlist-card.loading-card::after { content: ''; position: absolute; inset: 0; border-radius: var(--radius); background: rgba(29,185,84,0.08); animation: cardPulse 1.2s ease-in-out infinite; }
@keyframes cardPulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 0.8; } }

/* Track section */
.track-section { margin-top: 24px; scroll-margin-top: 80px; }
.track-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.track-header h2 { font-size: 1.3rem; font-weight: 800; }
.track-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.track-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }

/* Contributor tags */
.contributor-tag { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 50px; font-size: 0.78rem; font-weight: 600; cursor: pointer; border: 1px solid var(--border); background: var(--surface); transition: all var(--t); user-select: none; }
.contributor-tag:hover { background: var(--surface-2); }
.contributor-tag.selected { border-color: var(--spotify); background: rgba(29,185,84,0.15); }
.contributor-tag .dot { width: 8px; height: 8px; border-radius: 50%; }
.contributor-tag .count { color: var(--text-3); }

/* Buttons */
.btn-sort, .btn-save, .btn-transfer { border: none; padding: 8px 20px; border-radius: 50px; font-size: 0.82rem; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: all var(--t); font-family: inherit; }
.btn-sort { background: var(--spotify); color: #000; }
.btn-sort:hover { background: var(--spotify-dark); }
.btn-save { background: var(--orange); color: #000; }
.btn-save:hover { background: var(--orange-dark); }
.btn-save:disabled, .btn-transfer:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-transfer { background: #6C5CE7; color: #fff; }
.btn-transfer:hover { background: #5A4BD1; }
.btn-reset { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); padding: 8px 20px; border-radius: 50px; font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: all var(--t); font-family: inherit; }
.btn-reset:hover { background: var(--surface-3); color: var(--text); }
.btn-arrange { background: #36A2EB; color: #fff; border: none; padding: 8px 20px; border-radius: 50px; font-size: 0.82rem; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: all var(--t); font-family: inherit; }
.btn-arrange:hover { background: #2B8AD4; }
.btn-arrange-done { background: var(--spotify); color: #000; }
.btn-arrange-done:hover { background: var(--spotify-dark); }
.btn-arrange-cancel { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); padding: 8px 20px; border-radius: 50px; font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: all var(--t); font-family: inherit; }
.btn-arrange-cancel:hover { background: var(--surface-3); color: var(--text); }

/* Track table */
.track-table { width: 100%; border-collapse: collapse; }
.track-table th { text-align: left; font-size: 0.72rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.track-table th:first-child { width: 40px; text-align: center; }
.track-row { transition: background var(--t); }
.track-row:hover { background: var(--surface); }
.track-row.dragging { opacity: 0.4; background: var(--surface-2); }
.track-row.drag-over { border-top: 2px solid var(--spotify); }
.track-row td { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,0.03); vertical-align: middle; }
.track-row.dimmed { opacity: 0.35; }
.drag-handle { cursor: grab; color: var(--text-3); font-size: 0.75rem; user-select: none; touch-action: none; }
.track-row.my-track { cursor: default; }
.track-row.my-track .drag-handle { touch-action: none; }
.track-num { text-align: center; font-size: 0.82rem; color: var(--text-3); font-weight: 500; }
.track-info { display: flex; align-items: center; gap: 12px; }
.track-art { width: 40px; height: 40px; border-radius: 4px; background: var(--surface-3); flex-shrink: 0; overflow: hidden; }
.track-art img { width: 100%; height: 100%; object-fit: cover; }
.track-name { font-size: 0.9rem; font-weight: 600; }
.track-artist { font-size: 0.78rem; color: var(--text-2); }
.track-added-by { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 600; }
.track-added-by .dot { width: 6px; height: 6px; border-radius: 50%; }
.track-duration { font-size: 0.82rem; color: var(--text-3); text-align: right; }
.track-delete { color: var(--text-3); cursor: pointer; font-size: 0.9rem; text-align: center; padding: 0 8px; transition: all var(--t); }
.track-delete:hover { color: #FF6B6B; }

/* Banners */
.sort-banner, .save-banner, .transfer-banner { border-radius: 10px; padding: 12px 20px; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; font-size: 0.85rem; }
.sort-banner { background: rgba(29,185,84,0.1); border: 1px solid rgba(29,185,84,0.2); color: var(--spotify); }
.save-banner { background: rgba(249,115,22,0.1); border: 1px solid rgba(249,115,22,0.2); color: var(--orange); }
.transfer-banner { background: rgba(108,92,231,0.1); border: 1px solid rgba(108,92,231,0.2); color: #6C5CE7; }
.arrange-banner { border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; background: rgba(54,162,235,0.1); border: 1px solid rgba(54,162,235,0.25); color: #36A2EB; display: flex; flex-direction: column; font-size: 0.85rem; gap: 10px; }
.arrange-banner .arrange-info { display: flex; align-items: center; gap: 8px; }
.arrange-banner .arrange-btns { display: flex; gap: 8px; width: 100%; }
.arrange-banner .arrange-btns button { flex: 1; }

/* Loading */
.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 80px 0; gap: 16px; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--surface-3); border-top-color: var(--spotify); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-3); font-size: 0.88rem; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px; backdrop-filter: blur(4px); }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px; width: 100%; max-width: 500px; max-height: 80vh; display: flex; flex-direction: column; }
.modal h3 { font-size: 1.15rem; font-weight: 800; margin-bottom: 8px; }
.modal .modal-desc { font-size: 0.85rem; color: var(--text-2); margin-bottom: 20px; }
.modal-search { width: 100%; padding: 10px 14px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-size: 0.88rem; font-family: inherit; margin-bottom: 12px; outline: none; }
.modal-search:focus { border-color: var(--spotify); }
.modal-playlist-list { flex: 1; overflow-y: auto; margin-bottom: 16px; max-height: 300px; }
.modal-playlist-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; cursor: pointer; transition: all var(--t); }
.modal-playlist-item:hover { background: var(--surface-2); }
.modal-playlist-item.selected { background: rgba(29,185,84,0.15); border: 1px solid rgba(29,185,84,0.3); }
.modal-playlist-item img { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; }
.modal-playlist-item .pl-placeholder { width: 40px; height: 40px; border-radius: 6px; background: var(--surface-3); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.modal-playlist-item .pl-info h4 { font-size: 0.88rem; font-weight: 600; }
.modal-playlist-item .pl-info span { font-size: 0.72rem; color: var(--text-3); }
.modal-options { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.modal-options label { font-size: 0.85rem; color: var(--text-2); cursor: pointer; display: flex; align-items: center; gap: 8px; }
.modal-options input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--spotify); cursor: pointer; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions .btn-cancel { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); padding: 10px 24px; border-radius: 10px; font-size: 0.88rem; font-weight: 600; cursor: pointer; font-family: inherit; }
.modal-actions .btn-confirm { background: #6C5CE7; color: #fff; border: none; padding: 10px 24px; border-radius: 10px; font-size: 0.88rem; font-weight: 700; cursor: pointer; font-family: inherit; transition: all var(--t); }
.modal-actions .btn-confirm:hover { background: #5A4BD1; }
.modal-actions .btn-confirm:disabled { opacity: 0.4; cursor: not-allowed; }

.selected-info { font-size: 0.82rem; color: var(--text-2); margin-bottom: 12px; }
.hidden { display: none !important; }

@media (max-width: 640px) {
  .playlists-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .track-table .col-album { display: none; }
  .main { padding: 16px; }
}
