*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0f1117;
  --surface:  #1a1d27;
  --surface2: #22263a;
  --surface3: #2a2f45;
  --accent:   #5865f2;
  --accent2:  #7289da;
  --accent-dim: #3d4575;
  --text:     #e2e8f0;
  --text2:    #94a3b8;
  --text3:    #64748b;
  --border:   #2d3150;
  --star:     #f59e0b;
  --danger:   #ef4444;
  --success:  #22c55e;
  --player-h: 90px;
  --header-h: 44px;
  --status-h: 22px;
  --sidebar-w: 210px;
  --info-w:   300px;
}
html, body { height: 100%; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 13px; }
button { font-family: inherit; }

/* ── Header / Toolbar ── */
#header { position: fixed; top: 0; left: 0; right: 0; height: var(--header-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; padding: 0 12px; z-index: 100; }
.icon-btn { background: none; border: 1px solid var(--border); color: var(--text2); font-size: 16px; padding: 4px 9px; border-radius: 6px; cursor: pointer; display: none; }
.icon-btn:hover { background: var(--surface2); color: var(--text); }
.settings-btn { display: inline-block; margin-left: 4px; }
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 150; display: none; }
.drawer-overlay.visible { display: block; }
.logo { font-size: 15px; font-weight: 700; white-space: nowrap; color: var(--accent2); cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.logo:hover { background: var(--surface2); }
.search-box { display: flex; flex: 1; max-width: 400px; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.search-box input { flex: 1; background: none; border: none; outline: none; color: var(--text); padding: 5px 10px; font-size: 12px; }
.search-box button { background: none; border: none; color: var(--text2); padding: 0 10px; cursor: pointer; font-size: 16px; }
.toolbar-views { display: flex; gap: 2px; }
.tb-btn { background: none; border: 1px solid var(--border); color: var(--text2); padding: 3px 8px; cursor: pointer; font-size: 14px; border-radius: 4px; }
.tb-btn.active { background: var(--accent-dim); color: var(--text); border-color: var(--accent); }
.tb-btn:hover { background: var(--surface2); color: var(--text); }
.header-stats { color: var(--text3); font-size: 11px; white-space: nowrap; margin-left: auto; }

/* ── Main layout ── */
#main { position: fixed; top: var(--header-h); bottom: calc(var(--player-h) + var(--status-h)); left: 0; right: 0; display: flex; }

/* ── Sidebar / Tree ── */
#sidebar { width: var(--sidebar-w); min-width: 140px; max-width: 400px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0; }
.sidebar-filter { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.sidebar-filter input { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; padding: 4px 8px; color: var(--text); outline: none; font-size: 11px; }
.tree { flex: 1; overflow-y: auto; padding: 4px 0; user-select: none; }
.tree-section { margin-bottom: 2px; }
.tree-header { display: flex; align-items: center; gap: 4px; padding: 5px 10px; cursor: pointer; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text2); }
.tree-header:hover { color: var(--text); background: var(--surface2); }
.tree-header .arrow { font-size: 9px; transition: transform 0.15s; width: 12px; text-align: center; }
.tree-header .arrow.open { transform: rotate(90deg); }
.tree-children { display: none; }
.tree-children.open { display: block; }
.tree-item { padding: 4px 10px 4px 28px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text2); font-size: 12px; border-radius: 4px; margin: 0 4px; }
.tree-item:hover { background: var(--surface2); color: var(--text); }
.tree-item.active { background: var(--accent); color: #fff; }
.tree-item .count { color: var(--text3); font-size: 10px; margin-left: 4px; }
.tree-add { padding: 4px 10px 4px 28px; cursor: pointer; color: var(--accent2); font-size: 12px; opacity: 0.7; }
.tree-add:hover { opacity: 1; }
.resize-handle { width: 4px; cursor: col-resize; background: transparent; flex-shrink: 0; z-index: 10; }
.resize-handle:hover, .resize-handle.active { background: var(--accent); }

/* ── Content area ── */
#content { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 200px; }
#contentToolbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; border-bottom: 1px solid var(--border); background: var(--surface); min-height: 32px; }
#breadcrumb { color: var(--text2); font-size: 12px; display: flex; gap: 4px; align-items: center; }
#breadcrumb span { cursor: pointer; } #breadcrumb span:hover { color: var(--accent2); }
#contentActions { display: flex; gap: 6px; align-items: center; }
#contentActions button { background: var(--accent); border: none; color: #fff; padding: 4px 12px; border-radius: 4px; cursor: pointer; font-size: 11px; font-weight: 600; }
#contentActions button:hover { background: var(--accent2); }
#contentActions button.secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
#view { flex: 1; overflow-y: auto; }

/* ── Track table ── */
.track-table { width: 100%; border-collapse: collapse; }
.track-table thead { position: sticky; top: 0; z-index: 5; background: var(--surface); }
.track-table th { padding: 6px 10px; text-align: left; font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border); cursor: pointer; white-space: nowrap; user-select: none; }
.track-table th:hover { color: var(--text); background: var(--surface2); }
.track-table th.sorted-asc::after { content: " ▲"; font-size: 9px; }
.track-table th.sorted-desc::after { content: " ▼"; font-size: 9px; }
.track-table th.col-num { width: 40px; text-align: right; }
.track-table th.col-rating { width: 80px; }
.track-table th.col-dur { width: 55px; text-align: right; }
.track-table th.col-year { width: 50px; }
.track-table th.col-bitrate { width: 65px; text-align: right; }
.track-table td { padding: 5px 10px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; border-bottom: 1px solid rgba(45,49,80,0.4); }
.track-table td.col-num { text-align: right; color: var(--text3); font-size: 11px; }
.track-table td.col-dur { text-align: right; color: var(--text3); }
.track-table td.col-bitrate { text-align: right; color: var(--text3); }
.track-table tr { cursor: pointer; transition: background 0.1s; }
.track-table tbody tr:hover { background: var(--surface2); }
.track-table tbody tr.playing { background: var(--accent-dim); }
.track-table tbody tr.playing td { color: var(--text); }
.track-table tbody tr.selected { background: var(--surface3); }
.track-table .rating-cell { color: var(--text3); letter-spacing: 1px; cursor: pointer; }
.track-table .rating-cell .star-on { color: var(--star); }
.track-table .artist-link, .track-table .album-link { color: var(--text2); }
.track-table .artist-link:hover, .track-table .album-link:hover { color: var(--accent2); text-decoration: underline; }
.track-table .row-remove { float: right; margin-left: 8px; color: var(--text3); cursor: pointer; opacity: 0; font-size: 13px; padding: 0 4px; }
.track-table tbody tr:hover .row-remove { opacity: 1; }
.track-table .row-remove:hover { color: var(--danger); }

/* Hide the grid/list toggle since everything is a list now */
.toolbar-views { display: none !important; }

/* ── Album list ── */
.album-list { padding: 6px 0; }
.album-list-item { display: flex; align-items: center; gap: 12px; padding: 8px 14px; cursor: pointer; transition: background 0.1s; border-bottom: 1px solid rgba(45,49,80,0.25); }
.album-list-item:hover { background: var(--surface2); }
.album-list-art { width: 40px; height: 40px; border-radius: 4px; overflow: hidden; background: var(--surface2); flex-shrink: 0; position: relative; display: flex; align-items: center; justify-content: center; }
.album-list-art img { width: 100%; height: 100%; object-fit: cover; }
.album-list-art.no-art { background: linear-gradient(135deg, var(--surface2), var(--surface)); }
.album-list-art.no-art::after { content: attr(data-initial); position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 16px; font-weight: 700; color: var(--text3); pointer-events: none; }
.album-list-info { flex: 1; min-width: 0; }
.album-list-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.album-list-meta { font-size: 11px; color: var(--text3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.simple-list-item { display: flex; align-items: center; gap: 12px; padding: 8px 14px; cursor: pointer; transition: background 0.1s; border-bottom: 1px solid rgba(45,49,80,0.25); }
.simple-list-item:hover { background: var(--surface2); }
.simple-list-icon { width: 32px; text-align: center; font-size: 20px; flex-shrink: 0; }

/* ── Album grid (legacy, kept for any edge cases) ── */
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; padding: 14px; align-items: start; grid-auto-rows: min-content; }
.album-card { background: var(--surface); border-radius: 8px; overflow: hidden; cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; border: 1px solid var(--border); }
.album-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.4); }
.album-art { width: 100%; aspect-ratio: 1; background: var(--surface2); display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.album-art img { width: 100%; height: 100%; object-fit: cover; }
.album-art .play-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; font-size: 32px; color: #fff; opacity: 0; transition: opacity 0.15s; }
.album-card:hover .play-overlay { opacity: 1; }
/* No album art — collapse the art area so the card is compact */
.album-art.no-art { aspect-ratio: auto; height: 4px; background: var(--accent-dim); }
.album-art.no-art .play-overlay { display: none; }
.album-info { padding: 8px 10px; }
.album-name { font-weight: 600; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.album-meta { font-size: 10px; color: var(--text3); margin-top: 2px; }

/* ── Album card rating ── */
.album-card-rating { display: flex; gap: 1px; margin-top: 5px; }
.album-card-rating .star { font-size: 11px; cursor: pointer; color: var(--text3); line-height: 1; }
.album-card-rating .star.star-on { color: var(--star); }

/* ── Section heading ── */
.section-heading { font-size: 18px; font-weight: 700; padding: 14px 14px 0; }

/* ── Browser filter input ── */
.browser-filter { display: block; width: 100%; box-sizing: border-box; background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; padding: 6px 10px; color: var(--text); outline: none; font-size: 12px; margin: 8px 0; }
.browser-filter:focus { border-color: var(--accent); }

/* ── Album / Artist header ── */
.artist-header { display: flex; align-items: center; gap: 14px; padding: 14px; }
.art-wrap { width: 90px; height: 90px; border-radius: 8px; overflow: hidden; background: var(--surface2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; position: relative; }
.art-wrap img { width: 100%; height: 100%; object-fit: cover; }
.art-wrap.no-art { width: 48px; height: 48px; background: linear-gradient(135deg, var(--surface2), var(--surface)); border: 1px solid var(--border); }
.artist-header h1 { font-size: 22px; font-weight: 700; }
.artist-header .meta { color: var(--text2); font-size: 12px; margin-top: 4px; }
.artist-header .actions { display: flex; gap: 8px; margin-top: 8px; }
.header-rating { display: flex; gap: 2px; margin-top: 6px; }
.header-rating .star { font-size: 18px; cursor: pointer; color: var(--text3); }
.header-rating .star.star-on { color: var(--star); }
.btn { border: none; padding: 6px 16px; border-radius: 20px; cursor: pointer; font-size: 12px; font-weight: 600; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface3); }

/* ── Artist list ── */
.artist-list { padding: 6px 0; }
.artist-list-item { display: flex; align-items: center; gap: 12px; padding: 7px 14px; cursor: pointer; transition: background 0.1s; }
.artist-list-item:hover { background: var(--surface2); }
.artist-avatar { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; color: #fff; flex-shrink: 0; letter-spacing: -1px; }
.artist-list-info { flex: 1; min-width: 0; }
.artist-list-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.artist-list-meta { font-size: 11px; color: var(--text3); margin-top: 1px; }
.inline-rating { display: flex; gap: 1px; flex-shrink: 0; }
.inline-rating .star { font-size: 13px; cursor: pointer; color: var(--text3); line-height: 1; }
.inline-rating .star.star-on { color: var(--star); }
.artist-list-chevron { color: var(--text3); font-size: 14px; flex-shrink: 0; }

/* ── Toolbar artist rating ── */
.toolbar-rating { display: flex; gap: 2px; align-items: center; margin-left: 4px; }
.toolbar-rating .star { font-size: 15px; cursor: pointer; color: var(--text3); }
.toolbar-rating .star.star-on { color: var(--star); }

/* ── Info / Right panel ── */
#infoPanel { width: var(--info-w); min-width: 220px; max-width: 500px; background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0; }
.info-tabs { display: flex; border-bottom: 1px solid var(--border); }
.info-tab { flex: 1; background: none; border: none; color: var(--text3); padding: 8px 4px; cursor: pointer; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 2px solid transparent; white-space: nowrap; }
.info-tab:hover { color: var(--text); background: var(--surface2); }
.info-tab.active { color: var(--accent2); border-bottom-color: var(--accent2); }
.info-content { flex: 1; overflow-y: auto; }
.queue-actions { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.queue-actions button { background: none; border: 1px solid var(--border); color: var(--text2); padding: 3px 10px; border-radius: 4px; cursor: pointer; font-size: 11px; }
.queue-actions button:hover { background: var(--surface2); color: var(--text); }
#queueCount, #playlistPanelCount { font-size: 11px; color: var(--text3); }
#queueList { list-style: none; }
#queueList li { display: flex; align-items: center; gap: 8px; padding: 6px 12px; cursor: pointer; font-size: 12px; border-bottom: 1px solid rgba(45,49,80,0.3); }
#queueList li:hover { background: var(--surface2); }
#queueList li.playing { background: var(--accent-dim); }
#queueList li .q-num { width: 20px; text-align: right; color: var(--text3); font-size: 10px; flex-shrink: 0; }
#queueList li .q-info { flex: 1; min-width: 0; }
#queueList li .q-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#queueList li .q-artist { font-size: 10px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#queueList li .q-dur { font-size: 10px; color: var(--text3); flex-shrink: 0; }
#queueList li .q-remove { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 14px; padding: 0 2px; opacity: 0; flex-shrink: 0; }
#queueList li:hover .q-remove { opacity: 1; }
#queueList li .q-remove:hover { color: var(--danger); }
#queueList li.drag-over { border-top: 2px solid var(--accent); }

/* ── Playlists panel ── */
#playlistPanelList { list-style: none; }
#playlistPanelList li { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; font-size: 12px; border-bottom: 1px solid rgba(45,49,80,0.3); transition: background 0.1s; }
#playlistPanelList li:hover { background: var(--surface2); }
#playlistPanelList li .pl-icon { font-size: 14px; flex-shrink: 0; }
#playlistPanelList li .q-info { flex: 1; min-width: 0; }
#playlistPanelList li .q-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
#playlistPanelList li .q-artist { font-size: 10px; color: var(--text3); }
#playlistPanelList li .pl-play { background: var(--accent); border: none; color: #fff; padding: 2px 8px; border-radius: 4px; cursor: pointer; font-size: 10px; opacity: 0; flex-shrink: 0; }
#playlistPanelList li:hover .pl-play { opacity: 1; }
#playlistPanelList li .pl-del { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 14px; padding: 0 2px; opacity: 0; flex-shrink: 0; }
#playlistPanelList li:hover .pl-del { opacity: 1; }
#playlistPanelList li .pl-del:hover { color: var(--danger); }
.pl-empty { color: var(--text3); text-align: center; padding: 30px 16px; font-size: 12px; line-height: 1.6; }

/* Now Playing tab */
.np-art { width: 100%; aspect-ratio: 1; background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 64px; color: var(--text3); overflow: hidden; }
.np-art img { width: 100%; height: 100%; object-fit: cover; }
.np-title { font-weight: 700; font-size: 16px; padding: 12px 14px 2px; }
.np-artist { font-size: 13px; color: var(--text2); padding: 0 14px; }
.np-album { font-size: 12px; color: var(--text3); padding: 2px 14px 8px; }
.np-meta { padding: 0 14px; font-size: 11px; color: var(--text3); line-height: 1.8; }

/* Details tab */
.details-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.details-table td { padding: 4px 12px; border-bottom: 1px solid rgba(45,49,80,0.3); vertical-align: top; }
.details-table td:first-child { color: var(--text3); font-weight: 600; white-space: nowrap; width: 90px; }

/* ── Player bar ── */
#player { position: fixed; bottom: var(--status-h); left: 0; right: 0; height: var(--player-h); background: var(--surface); border-top: 1px solid var(--border); display: flex; align-items: center; padding: 0 14px; z-index: 100; }
.player-left { display: flex; align-items: center; gap: 10px; width: 280px; flex-shrink: 0; }
.player-art { width: 56px; height: 56px; border-radius: 6px; overflow: hidden; background: var(--surface2); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--text3); position: relative; cursor: pointer; }
.player-art img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
#playerArtPH { position: absolute; }
.player-info { min-width: 0; }
.player-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-artist { font-size: 11px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-rating { display: flex; gap: 1px; margin-left: 4px; }
.player-rating .star { cursor: pointer; font-size: 14px; color: var(--text3); }
.player-rating .star.on { color: var(--star); }
.player-center { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0 20px; }
.player-controls { display: flex; align-items: center; gap: 10px; }
.ctrl-btn { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 16px; padding: 5px; border-radius: 50%; transition: color 0.12s, background 0.12s; line-height: 1; }
.ctrl-btn:hover { color: var(--text); background: var(--surface2); }
.ctrl-btn.active { color: var(--accent2); }
.play-btn { font-size: 20px; color: #fff; background: var(--accent); border-radius: 50%; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; }
.play-btn:hover { background: var(--accent2); }
.player-progress { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 600px; }
.progress-bar { flex: 1; height: 4px; background: var(--surface2); border-radius: 2px; cursor: pointer; position: relative; }
.progress-fill { height: 100%; background: var(--accent2); border-radius: 2px; width: 0%; pointer-events: none; }
.progress-hover { position: absolute; top: 0; left: 0; height: 100%; background: rgba(114,137,218,0.3); border-radius: 2px; width: 0%; pointer-events: none; }
.progress-bar:hover { height: 6px; margin-top: -1px; }
#timeElapsed, #timeDuration { font-size: 10px; color: var(--text3); white-space: nowrap; min-width: 32px; }
#timeElapsed { text-align: right; }
.player-right { display: flex; align-items: center; gap: 8px; width: 180px; flex-shrink: 0; justify-content: flex-end; }
.player-volume { display: flex; align-items: center; gap: 4px; }
.vol-icon { font-size: 14px; }
.player-volume input[type=range] { width: 80px; accent-color: var(--accent2); height: 4px; }

/* ── Cast launcher ── */
google-cast-launcher { --disconnected-color: var(--text2); --connected-color: var(--accent2); width: 24px; height: 24px; cursor: pointer; opacity: 0.85; }
google-cast-launcher:hover { opacity: 1; }
.casting-indicator { font-size: 11px; color: var(--accent2); margin-left: 6px; white-space: nowrap; }

/* ── Status bar ── */
#statusBar { position: fixed; bottom: 0; left: 0; right: 0; height: var(--status-h); background: var(--surface); border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 12px; font-size: 10px; color: var(--text3); z-index: 100; }

/* ── Context menu ── */
.ctx-menu { position: fixed; z-index: 1000; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 4px 0; min-width: 200px; box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
.ctx-item { padding: 6px 14px; cursor: pointer; font-size: 12px; display: flex; align-items: center; gap: 8px; position: relative; }
.ctx-item:hover { background: var(--accent); color: #fff; }
.ctx-sep { height: 1px; background: var(--border); margin: 3px 0; }
.ctx-sub { position: relative; }
.ctx-submenu { display: none; position: absolute; left: 100%; top: -4px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 4px 0; min-width: 160px; box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
.ctx-sub:hover .ctx-submenu { display: block; }
.ctx-submenu .ctx-item { font-size: 11px; }

/* ── Modal ── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 2000; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; min-width: 300px; }
.modal-box h3 { margin-bottom: 12px; font-size: 16px; }
.modal-box input { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; color: var(--text); outline: none; font-size: 13px; margin-bottom: 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.modal-actions button { padding: 6px 18px; border-radius: 6px; border: none; cursor: pointer; font-size: 12px; font-weight: 600; }
.modal-actions button:first-child { background: var(--accent); color: #fff; }
.modal-actions button:last-child { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.settings-box { min-width: 420px; max-width: 520px; }
.setting-row { display: flex; align-items: flex-start; gap: 14px; padding: 12px 0 18px; }
.setting-copy { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.setting-title { font-size: 13px; font-weight: 600; color: var(--text); }
.setting-help { font-size: 11px; line-height: 1.45; color: var(--text2); }
.setting-row input[type="checkbox"] { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent2); flex-shrink: 0; }

/* ── Smart playlist editor ── */
.smart-box { min-width: 520px; max-width: 640px; }
.smart-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.smart-label { font-size: 12px; color: var(--text2); min-width: 60px; }
.smart-row input[type="text"], .smart-row input[type="number"], .smart-row select {
  flex: 1; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; color: var(--text); font-size: 13px; outline: none; margin: 0;
}
.smart-rules-wrap { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }
.smart-rules-wrap > .smart-label { display: block; margin-bottom: 8px; }
.smart-rule-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.smart-rule-row select, .smart-rule-row input {
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
  padding: 5px 8px; color: var(--text); font-size: 12px; outline: none;
}
.smart-rule-row .smart-joiner { flex: 0 0 60px; font-weight: 600; color: var(--accent2); }
.smart-rule-row .smart-joiner-spacer { flex: 0 0 60px; font-size: 11px; color: var(--text3); padding-left: 4px; text-transform: uppercase; letter-spacing: 0.06em; }
.smart-rule-row .smart-field { flex: 1.2; }
.smart-rule-row .smart-op { flex: 0.8; }
.smart-rule-row .smart-op:disabled { opacity: 0.5; }
.smart-rule-row .smart-value { flex: 1; }
.smart-rule-row .smart-rule-del {
  background: transparent; border: none; color: var(--text3); font-size: 16px;
  cursor: pointer; padding: 0 6px; line-height: 1;
}
.smart-rule-row .smart-rule-del:hover { color: #e74c3c; }
.smart-add-rule {
  background: transparent; border: 1px dashed var(--border); color: var(--text2);
  border-radius: 4px; padding: 5px 10px; font-size: 12px; cursor: pointer; width: 100%;
}
.smart-add-rule:hover { color: var(--text); border-color: var(--text3); }

/* ── Popularity sync row in settings ── */
.setting-row-block { flex-direction: column; align-items: stretch; }
.setting-status { font-size: 11px; color: var(--text2); margin-top: 6px; min-height: 1.4em; }
.setting-status.syncing { color: var(--accent2); }
.setting-status.error { color: #e57373; }
.setting-row-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.setting-row-actions button {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 6px 12px; font-size: 12px; cursor: pointer;
}
.setting-row-actions button:hover { background: var(--surface3); }
.setting-row-actions button:disabled { opacity: 0.5; cursor: not-allowed; }
.setting-btn-stop { background: #4a2030 !important; }
.setting-link {
  display: inline-flex; align-items: center; padding: 6px 12px;
  border-radius: 6px; background: var(--surface2); border: 1px solid var(--border);
  color: var(--accent2); font-size: 12px; text-decoration: none;
}
.setting-link:hover { background: var(--surface3); color: var(--text); }

/* ── Last.fm panel inside Now Playing tab ── */
.np-lastfm { padding: 12px 14px 18px; border-top: 1px solid var(--border); margin-top: 12px; }
.np-lastfm.hidden { display: none; }
.lf-loading, .lf-empty { color: var(--text3); font-size: 12px; padding: 6px 0; }
.lf-section-title { font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; }
.lf-section-sub { font-size: 11px; font-weight: 600; color: var(--text2); margin: 14px 0 6px; }
.lf-stats { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--text2); margin-bottom: 8px; }
.lf-stat b { color: var(--text); font-weight: 600; }
.lf-link { color: var(--accent2); text-decoration: none; font-size: 11px; margin-left: auto; }
.lf-link:hover { text-decoration: underline; }
.lf-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.lf-tag {
  font-size: 10px; padding: 3px 8px; border-radius: 999px;
  background: var(--surface2); color: var(--text2); border: 1px solid var(--border);
  text-decoration: none; transition: background 0.1s, color 0.1s;
}
.lf-tag:hover { background: var(--surface3); color: var(--text); }
.lf-summary {
  font-size: 12px; line-height: 1.5; color: var(--text2);
  max-height: 7.5em; overflow: hidden; position: relative; margin-bottom: 4px;
  /* Fade the bottom so the truncation reads as deliberate. */
  mask-image: linear-gradient(to bottom, #000 75%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 75%, transparent 100%);
}
.lf-similar { display: flex; flex-wrap: wrap; gap: 4px; }
.lf-similar-link {
  font-size: 11px; padding: 3px 8px; border-radius: 4px;
  background: var(--surface2); color: var(--accent2); text-decoration: none;
  border: 1px solid var(--border);
}
.lf-similar-link:hover { background: var(--surface3); color: var(--text); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Utilities ── */
.hidden { display: none !important; }
.loading { display: flex; align-items: center; justify-content: center; height: 200px; color: var(--text2); font-size: 14px; }
.empty { color: var(--text3); text-align: center; padding: 40px 20px; font-size: 13px; }

/* ═══════════════ Mobile layout (phones, narrow tablets) ═══════════════ */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 280px;
    --info-w: 280px;
    --player-h: 110px;
  }

  #header { gap: 4px; padding: 0 6px; }
  .icon-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 36px; }
  .settings-btn { margin-left: 0; }
  /* Replace verbose logo with just the icon to free up header room */
  .logo { font-size: 0; padding: 4px 6px; }
  .logo::before { content: "🎵"; font-size: 18px; }
  /* The two view toggles add clutter on phones — grid is the better default */
  .toolbar-views { display: none; }
  .search-box { max-width: none; flex: 1; }
  .search-box input { font-size: 13px; padding: 7px 10px; }
  .search-box button { display: none; }
  .header-stats { display: none; }

  /* Sidebar becomes a slide-out drawer */
  #sidebar {
    position: fixed; top: var(--header-h); bottom: calc(var(--player-h) + var(--status-h));
    left: 0; z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.22s ease-in-out;
    box-shadow: 2px 0 18px rgba(0,0,0,0.5);
  }
  #sidebar.drawer-open { transform: translateX(0); }
  #sidebarResize { display: none; }

  /* Info panel also behaves as a right-side drawer */
  #infoPanel {
    position: fixed; top: var(--header-h); bottom: calc(var(--player-h) + var(--status-h));
    right: 0; z-index: 200; width: var(--info-w);
  }
  #infoPanelResize { display: none; }

  /* Content takes full width on mobile */
  #content { min-width: 0; }

  /* Compact player bar: two-row layout */
  #player { padding: 6px 8px; }
  .player-left { width: auto; flex: 1; min-width: 0; gap: 8px; }
  .player-art { width: 44px; height: 44px; }
  .player-title { font-size: 12px; }
  .player-artist { font-size: 10px; }
  .player-rating { display: none; }
  .player-center { padding: 0 4px; }
  .player-controls { gap: 4px; }
  .ctrl-btn { font-size: 14px; padding: 4px; }
  .play-btn { width: 32px; height: 32px; font-size: 16px; }
  .player-progress { max-width: none; gap: 4px; }
  #timeElapsed, #timeDuration { font-size: 9px; min-width: 28px; }
  .player-right { width: auto; gap: 4px; }
  .player-volume input[type=range] { width: 60px; }

  /* Track table: hide bitrate + genre + year to fit phone widths */
  .track-table th.col-bitrate, .track-table td.col-bitrate { display: none; }
  .track-table th.col-year, .track-table td.col-year { display: none; }
  .track-table td { padding: 4px 6px; font-size: 11px; max-width: 180px; }
  .track-table th { padding: 5px 6px; font-size: 10px; }

  /* Album/artist lists: tighter spacing */
  .album-list-item, .artist-list-item, .simple-list-item { padding: 10px 12px; gap: 10px; min-height: 44px; }
  .artist-list-chevron { display: none; }

  /* Tree (sidebar) — bigger touch targets */
  .tree-item { padding: 10px 12px 10px 28px; font-size: 13px; min-height: 40px; line-height: 1.3; }
  .tree-add { padding: 10px 12px 10px 28px; font-size: 13px; min-height: 40px; line-height: 1.3; }
  .tree-header { padding: 10px 12px; font-size: 12px; }

  /* Album grid: 2 columns on phones */
  .album-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 10px; }
  .album-card-title, .album-card-artist { font-size: 11px; }

  /* Section heading a bit smaller */
  .section-heading { font-size: 15px; padding: 10px 10px 0; }

  /* Status bar: hide the chatty middle text */
  #statusCenter { display: none; }

  /* Breadcrumb: allow wrapping */
  #breadcrumb { font-size: 11px; flex-wrap: wrap; }

  /* Context menu: bigger touch targets */
  .ctx-item { padding: 10px 14px; font-size: 13px; }
  .ctx-menu { min-width: 220px; }
  .settings-box { min-width: min(92vw, 420px); }
  .smart-box { min-width: min(94vw, 520px); max-width: 94vw; }
  .smart-rule-row { flex-wrap: wrap; }
  .smart-rule-row select, .smart-rule-row input { font-size: 13px; padding: 7px 10px; }
}

/* Tiny screens (older phones) */
@media (max-width: 380px) {
  .player-left { gap: 6px; }
  .player-art { width: 38px; height: 38px; }
  .player-title { max-width: 110px; }
  .player-artist { max-width: 110px; }
  .player-volume { display: none; }
  #btnMute { display: none; }
  .search-box button { padding: 0 8px; }
}
