:root {
  --bg: #0f1115; --panel: #161922; --panel-2: #1d212c; --border: #2a2f3d;
  --text: #e8eaf0; --text-dim: #9aa1b4; --accent: #6ea8ff; --accent-dim: #3a5c94;
  --danger: #ff6b6b; --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, sans-serif;
}
button { font: inherit; cursor: pointer; }
input, select { font: inherit; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px; }

.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-screen form { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; width: min(360px, 90vw); text-align: center; }
.login-screen h1 { margin-top: 0; }
.login-screen input { width: 100%; margin: 16px 0; }
.login-screen button[type="submit"] { width: 100%; background: var(--accent); color: #06101f; border: none; padding: 10px; border-radius: var(--radius); font-weight: 600; }
#login-message { color: var(--text-dim); min-height: 1.5em; }

#app { display: flex; flex-direction: column; min-height: 100vh; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--panel); }
.topbar h1 { font-size: 18px; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 12px; color: var(--text-dim); }
.topbar-right button { background: transparent; color: var(--text-dim); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 12px; }

.layout { flex: 1; display: flex; min-height: 0; }
.sidebar { width: 260px; flex-shrink: 0; border-right: 1px solid var(--border); padding: 16px; overflow-y: auto; }
.filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.filters input, .filters select { width: 100%; }
.playlists-header { display: flex; justify-content: space-between; align-items: center; }
.playlists-header h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); margin: 0; }
#btn-new-playlist { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); width: 28px; height: 28px; }
#playlist-list { list-style: none; margin: 8px 0; padding: 0; }
#playlist-list li { display: flex; align-items: center; gap: 4px; padding: 4px 0; }
.playlist-link { flex: 1; text-align: left; background: none; border: none; color: var(--text); padding: 4px; border-radius: var(--radius); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.playlist-link:hover { background: var(--panel-2); }
.playlist-count { color: var(--text-dim); font-size: 12px; }
.favorites-link { width: 100%; text-align: left; background: none; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: 8px; margin-top: 8px; }

.library { flex: 1; padding: 16px 20px; overflow-y: auto; }
.library h2 { font-size: 16px; margin-top: 0; }
.track-table { width: 100%; border-collapse: collapse; }
.track-table th { text-align: left; color: var(--text-dim); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.track-table td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.track-table tr:hover { background: var(--panel); }
.title-cell { display: flex; flex-direction: column; }
.track-title { text-align: left; background: none; border: none; color: var(--text); font-size: 14px; padding: 0; }
.track-title:hover { color: var(--accent); text-decoration: underline; }
.track-artist { color: var(--text-dim); font-size: 12px; }
.model-cell, .duration-cell { color: var(--text-dim); white-space: nowrap; }
.icon-btn { background: none; border: none; color: var(--text-dim); padding: 4px; border-radius: var(--radius); }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.fav-btn.active { color: #ffd76b; }
#empty-state { color: var(--text-dim); }

.player-bar { display: flex; align-items: center; gap: 16px; padding: 10px 20px; border-top: 1px solid var(--border); background: var(--panel); }
.transport { display: flex; gap: 4px; }
.transport button { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); width: 36px; height: 36px; font-size: 16px; }
.transport button:disabled { opacity: .3; cursor: default; }
.now-playing { display: flex; flex-direction: column; min-width: 160px; }
.now-playing span { color: var(--text-dim); font-size: 12px; }
#audio { flex: 1; }
.autoplay-toggle { display: flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: 13px; white-space: nowrap; }
#btn-toggle-lyrics, #btn-download { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 8px 12px; }

#lyrics-panel { position: fixed; right: 0; top: 0; bottom: 0; width: min(360px, 90vw); background: var(--panel); border-left: 1px solid var(--border); padding: 20px; overflow-y: auto; }
#lyrics-panel .close { position: absolute; top: 12px; right: 12px; background: none; border: none; color: var(--text-dim); font-size: 20px; }
#lyrics-panel h3 { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
#lyrics-panel pre { white-space: pre-wrap; font: inherit; margin: 0 0 20px; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; width: min(360px, 90vw); }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog input { width: 100%; margin: 12px 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog-actions button { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 6px 14px; }
.dialog-actions button[type="submit"] { background: var(--accent); color: #06101f; border: none; font-weight: 600; }
#add-to-playlist-list { list-style: none; padding: 0; margin: 12px 0; max-height: 260px; overflow-y: auto; }
.playlist-pick { width: 100%; text-align: left; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 8px; margin-bottom: 6px; }
.playlist-pick:hover { border-color: var(--accent); }

@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .player-bar { flex-wrap: wrap; }
  #audio { width: 100%; order: 1; }
}
