/* ashleighmusic — Spotify-inspired dark UI */
:root {
    --bg-main: #121212;
    --bg-elevated: #181818;
    --bg-card: #242424;
    --bg-hover: #2a2a2a;
    --accent: #1db954;
    --accent-hover: #1ed760;
    --accent-soft: rgba(29, 185, 84, 0.14);
    --text: #ffffff;
    --muted: #b3b3b3;
    --muted-dim: #6a6a6a;
    --border: #2a2a2a;
    --spotify: #1ed760;
    --danger: #e0524c;
    --font: "Segoe UI", "Noto Sans", system-ui, -apple-system, -moz-system-ui, sans-serif;
    --nav-width: 250px;
    --queue-width: 330px;
    --player-height: 88px;
    --header-height: 68px;
    --radius: 8px;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg-main);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
img { display: block; }

/* ---------------- Icons ---------------- */
.icon {
    width: 1em;
    height: 1em;
    display: inline-block;
    vertical-align: -0.125em;
    fill: currentColor;
    flex-shrink: 0;
    pointer-events: none;
}
.icon-lg { width: 1.35em; height: 1.35em; }
.icon-xl { width: 2.4em; height: 2.4em; }
/* safety net: no svg inside a control may ever fall back to the browser's
   300x150 default box, even if a class is missing somewhere */
.btn-icon svg:not([class]), .play-overlay svg:not([class]),
.track-actions svg:not([class]), .player-controls svg:not([class]),
.queue-item svg:not([class]), .ctx-menu svg:not([class]),
.np-controls svg:not([class]), .np-footer svg:not([class]) {
    width: 1em;
    height: 1em;
    fill: currentColor;
    flex-shrink: 0;
}

.logo-mark { color: var(--accent); }
.logo-img {
    width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
    background: #fff;
}

/* buttons that mix an icon + label */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn .icon { font-size: 1.05em; }
.btn-ghost .icon { color: var(--muted); }

/* ---------------- Buttons ---------------- */
.btn {
    padding: 11px 22px;
    border-radius: 500px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.01em;
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: wait; transform: none; }
.btn.busy { cursor: wait; }
.btn-primary { background: var(--text); color: #000; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { color: var(--muted); background: transparent; }
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }
/* Spotify's brand green is very close to our accent, so this button uses a
   near-black chip with a white wordmark instead of fighting the palette */
.btn-spotify {
    background: #191414;
    color: #fff;
    box-shadow: inset 0 0 0 1px #2e2e2e;
}
.btn-spotify:hover { background: #221c1c; }
.btn-spotify .icon { color: #1ed760; flex-shrink: 0; }
.btn-full { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 12px; font-weight: 700; }

.btn-icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 15px; line-height: 1;
    color: var(--muted);
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.btn-icon:hover { color: var(--text); background: var(--bg-hover); }
.btn-icon:active { transform: scale(0.94); }

.hidden { display: none !important; }
.loading { color: var(--muted); padding: 28px 0; grid-column: 1 / -1; }

/* ---------------- Shell ---------------- */
#app {
    display: grid;
    /* minmax(0,...) lets the columns shrink below their content, otherwise a
       wide player row forces the whole grid wider than the viewport */
    grid-template-columns: var(--nav-width) minmax(0, 1fr);
    grid-template-rows: 1fr var(--player-height);
    height: 100vh;
    height: 100dvh;
    /* --app-h is set from JS (visualViewport-aware): on mobile Safari the
       URL bar showing/hiding changes the real viewport, which vh units lag
       behind — that used to push the player bar below the fold */
    height: var(--app-h, 100dvh);
}

#sidebar {
    background: #000;
    padding: 22px 14px;
    display: flex; flex-direction: column; gap: 18px;
    overflow-y: auto; overflow-x: hidden;
    grid-row: 1;
    min-width: 0;
}
#main {
    background: linear-gradient(180deg, #1e1e1e 0%, var(--bg-main) 260px);
    overflow-y: auto; overflow-x: hidden;
    position: relative;
    scroll-behavior: smooth;
    min-width: 0;
}

/* ---------------- Sidebar ---------------- */
.sidebar-header {
    padding: 4px 8px 0;
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px;
}
/* the close control only exists on mobile, where there is no visible toggle */
.sidebar-close { display: none; flex-shrink: 0; }
.logo-sm {
    font-size: 17px; font-weight: 800; letter-spacing: -0.01em;
    display: flex; align-items: center; gap: 8px;
    min-width: 0;
}
.logo-sm > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo-accent { color: var(--accent); }

.sidebar-scrim {
    position: fixed; inset: 0; z-index: 85;
    background: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.24s ease;
}
.sidebar-scrim.show { opacity: 1; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    padding: 11px 12px; border-radius: 6px;
    color: var(--muted); font-weight: 700; font-size: 14px;
    display: flex; align-items: center; gap: 13px;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { color: var(--text); background: var(--bg-hover); }
.nav-item.active { color: var(--text); background: var(--bg-hover); }
.nav-icon { width: 21px; height: 21px; flex-shrink: 0; opacity: 0.9; }

.sidebar-section { border-top: 1px solid #1f1f1f; padding-top: 16px; }
.sidebar-title {
    font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--muted);
    margin-bottom: 10px; padding-left: 12px;
}
.playlist-nav { display: flex; flex-direction: column; gap: 1px; max-height: 240px; overflow-y: auto; margin-bottom: 8px; }
.playlist-nav-item {
    padding: 8px 12px; border-radius: 5px;
    color: var(--muted); font-size: 14px; font-weight: 500;
    display: flex; align-items: center; gap: 10px;
    width: 100%; min-width: 0;
    text-align: left;
    cursor: pointer; transition: background 0.15s ease, color 0.15s ease;
}
.playlist-nav-item .icon { color: var(--muted-dim); transition: color 0.15s ease; }
.playlist-nav-item:hover .icon { color: var(--text); }
.playlist-nav-item:hover { background: var(--bg-hover); color: var(--text); }
.playlist-nav-item .ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spotify-status { font-size: 11px; color: var(--muted-dim); padding: 8px 12px 0; min-height: 16px; }

/* ---------------- Header ---------------- */
#header {
    position: sticky; top: 0; z-index: 20;
    height: var(--header-height);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px;
    background: linear-gradient(180deg, rgba(0,0,0,0.55) 0%, transparent 100%);
}
#menu-toggle { display: none; font-size: 18px; }
#page-title { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.user-badge {
    display: flex; align-items: center; gap: 9px;
    font-size: 13px; font-weight: 700;
    padding: 5px 6px 5px 5px;
    background: rgba(0,0,0,0.55); border-radius: 500px;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}
.avatar {
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--accent); color: #000;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 800;
}
#logout-btn {
    color: var(--muted); font-size: 11px; font-weight: 700;
    padding: 5px 10px; border-radius: 500px;
}
#logout-btn:hover { color: var(--text); background: rgba(255,255,255,0.1); }

/* ---------------- Views ---------------- */
.view { padding: 8px 28px 32px; display: none; }
.view.active { display: block; animation: fade 0.22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.greeting { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; margin: 6px 0 22px; }
.section-title {
    font-size: 19px; font-weight: 800; letter-spacing: -0.01em;
    margin: 26px 0 14px;
}
.section-title:first-child { margin-top: 0; }

/* ---------------- Track grid ---------------- */
.track-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 16px;
}
.track-card {
    background: var(--bg-elevated);
    border-radius: var(--radius);
    padding: 14px;
    cursor: pointer;
    position: relative;
    transition: background 0.2s ease, transform 0.15s ease;
}
.track-card:hover { background: var(--bg-hover); }
.track-card.playing { background: var(--bg-card); }

.track-img {
    width: 100%; aspect-ratio: 1 / 1;
    border-radius: 6px; overflow: hidden;
    background: var(--bg-card);
    margin-bottom: 12px; position: relative;
}
.track-img img { width: 100%; height: 100%; object-fit: cover; }
.track-img .no-art {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted-dim); font-size: 26px;
}
.play-overlay {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.4);
    opacity: 0; transition: opacity 0.15s ease;
}
.track-card:hover .play-overlay, .track-card.playing .play-overlay { opacity: 1; }
.play-overlay .btn-icon {
    width: 46px; height: 46px; font-size: 18px;
    background: var(--accent); color: #000;
    box-shadow: 0 6px 18px rgba(0,0,0,0.45);
}
.play-overlay .btn-icon:hover { background: var(--accent-hover); transform: scale(1.06); }

.track-title {
    font-size: 14px; font-weight: 600; line-height: 1.35;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; margin-bottom: 5px;
}
.track-artist {
    font-size: 13px; color: var(--muted); line-height: 1.35;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.track-meta { font-size: 11px; color: var(--muted-dim); margin-top: 8px; }

.track-actions {
    position: absolute; top: 8px; right: 8px;
    display: flex; gap: 4px;
    opacity: 0; transition: opacity 0.15s ease;
}
.track-card:hover .track-actions { opacity: 1; }
.track-actions .btn-icon {
    width: 28px; height: 28px; font-size: 12px;
    background: rgba(0,0,0,0.75); color: var(--text);
}
.track-actions .like-btn.liked { color: var(--accent); }

/* ---------------- Categories ---------------- */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 14px;
}
.category-card {
    --cat: hsl(var(--cat-hue, 158) 62% 56%);
    --cat-soft: hsl(var(--cat-hue, 158) 62% 56% / 0.16);
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    min-height: 116px;
    display: flex; flex-direction: column; justify-content: space-between;
    cursor: pointer; position: relative; overflow: hidden;
    transition: background 0.2s ease, transform 0.15s ease;
}
.category-card::after {
    /* soft tint in the corner so each genre is distinguishable at a glance */
    content: "";
    position: absolute; top: -34px; right: -34px;
    width: 108px; height: 108px; border-radius: 50%;
    background: var(--cat-soft);
    pointer-events: none;
}
.category-card:hover { background: var(--bg-hover); transform: translateY(-2px); }
.category-card:hover .cat-icon { color: var(--cat); }
.cat-icon {
    position: relative; z-index: 1;
    color: var(--muted);
    transition: color 0.2s ease;
}
.cat-name {
    position: relative; z-index: 1;
    font-size: 14px; font-weight: 800; letter-spacing: -0.01em;
    margin-top: 14px;
}

/* ---------------- Search ---------------- */
.search-container { display: flex; gap: 10px; margin: 6px 0 24px; max-width: 640px; }
#search-input {
    flex: 1; padding: 13px 20px;
    border-radius: 500px; border: 1px solid var(--border);
    background: var(--bg-elevated); color: var(--text); font-size: 15px;
}
#search-input::placeholder { color: var(--muted-dim); }
#search-input:focus { outline: none; border-color: var(--accent); background: var(--bg-card); }

/* ---------------- Library / playlist ---------------- */
.library-header {
    display: flex; justify-content: space-between; align-items: center;
    gap: 14px; margin: 6px 0 18px; flex-wrap: wrap;
}
.library-header h3 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.library-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.playlist-hero {
    display: flex; align-items: flex-end; gap: 22px;
    padding: 26px; margin: 6px 0 22px;
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    border-radius: 12px;
}
.playlist-hero-art {
    width: 168px; height: 168px; border-radius: var(--radius);
    background: var(--bg-card); flex-shrink: 0; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    font-size: 42px; color: var(--muted-dim);
}
.playlist-hero-art img { width: 100%; height: 100%; object-fit: cover; }
.playlist-hero-info { min-width: 0; }
.playlist-hero-kicker {
    font-size: 11px; font-weight: 700; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--muted); margin-bottom: 8px;
}
.playlist-hero-info h1 {
    font-size: 34px; font-weight: 800; letter-spacing: -0.02em;
    line-height: 1.1; margin-bottom: 10px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.playlist-hero-meta { font-size: 13px; color: var(--muted); }

.playlist-controls { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; }
.playlist-controls .play-btn {
    width: 54px; height: 54px; font-size: 22px;
    background: var(--accent); color: #000;
}
.playlist-controls .play-btn:hover { background: var(--accent-hover); transform: scale(1.05); }

/* ---------------- Player ---------------- */
#player {
    grid-column: 1 / -1;
    background: rgba(24,24,24,0.92);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    border-top: 1px solid #2a2a2a;
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 0 16px;
    z-index: 40;
    min-width: 0;
    overflow: hidden;
    /* explicit anchor for the mobile progress line pinned to the bar's top —
       without this it positions against the viewport on some browsers */
    position: relative;
}
/* the whole left block opens the full-screen player */
.player-left {
    display: flex; align-items: center; gap: 12px;
    flex: 0 1 260px; min-width: 0;
    padding: 0; margin: 0; background: none; color: inherit;
    text-align: left; cursor: pointer; border-radius: 6px;
}
.player-left:hover .player-title { text-decoration: underline; }
#player-art {
    width: 56px; height: 56px; border-radius: 6px;
    background: var(--bg-card); object-fit: cover; flex-shrink: 0;
    /* before any track loads this is an empty <img>; show a neutral block
       rather than a broken-image outline */
    visibility: hidden;
}
#player-art.has-art { visibility: visible; }
.player-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.player-title {
    font-size: 13px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player-artist {
    font-size: 11px; color: var(--muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.like-btn { font-size: 15px; flex-shrink: 0; }
.like-btn.liked { color: var(--accent); }

.player-center {
    flex: 1 1 auto; max-width: 620px;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    min-width: 0;
}
.player-controls { display: flex; align-items: center; gap: 8px; }
/* secondary controls read smaller than the primary play button */
.player-controls .btn-icon { color: var(--muted); }
/* the white play button keeps a dark glyph in every state — a generic
   :hover color would turn it white-on-white (and mobile browsers keep
   :hover stuck after a tap, hiding the button until you tap elsewhere) */
.player-controls .btn-icon:not(.play-btn):hover { color: var(--text); }
.player-controls .play-btn:hover { color: #000; background: var(--text); }
.player-controls .btn-icon .icon { width: 17px; height: 17px; }
.player-controls #player-shuffle[style*="--accent"],
.player-controls #player-repeat[style*="--accent"] { color: var(--accent); }
.player-controls .play-btn {
    width: 42px; height: 42px; margin: 0 4px;
    background: var(--text); color: #000;
}
.player-controls .play-btn .icon { width: 18px; height: 18px; }
.player-controls .play-btn:hover { transform: scale(1.07); }

.progress-container { display: flex; align-items: center; gap: 9px; width: 100%; }
.progress-container span { font-size: 10px; color: var(--muted); min-width: 34px; text-align: center; font-variant-numeric: tabular-nums; }

#progress-bar, #volume-bar {
    -webkit-appearance: none; appearance: none;
    height: 4px; border-radius: 2px; background: #4d4d4d;
    cursor: pointer; outline: none;
}
/* painted fill: the played portion is brand green, the rest is track grey */
#progress-bar { flex: 1; background: linear-gradient(to right, var(--accent) var(--fill, 0%), #4d4d4d var(--fill, 0%)); }
#volume-bar { flex: 1; background: linear-gradient(to right, var(--text) var(--fill, 75%), #4d4d4d var(--fill, 75%)); }
#progress-bar::-webkit-slider-thumb, #volume-bar::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--text); opacity: 0; transition: opacity 0.15s ease;
}
#progress-bar::-moz-range-thumb, #volume-bar::-moz-range-thumb {
    width: 12px; height: 12px; border: none; border-radius: 50%;
    background: var(--text); opacity: 0;
}
.progress-container:hover #progress-bar::-webkit-slider-thumb,
.volume-container:hover #volume-bar::-webkit-slider-thumb { opacity: 1; }
#progress-bar::-moz-range-thumb, #volume-bar::-moz-range-thumb { opacity: 1; }
#progress-bar::-moz-range-track, #volume-bar::-moz-range-track {
    height: 4px; border-radius: 2px; background: #4d4d4d;
}

.player-right {
    display: flex; align-items: center; gap: 10px;
    flex: 0 0 auto; justify-content: flex-end;
    min-width: 0;
    /* the fixed-width column can be the first thing to squeeze on narrow phones */
    max-width: 45%;
}
/* the like button lives inside .player-left now */
#player .like-btn { flex-shrink: 0; }
.volume-btn { flex-shrink: 0; }
#volume-bar { flex: 1 1 auto; width: auto; min-width: 0; max-width: 110px; }

/* ---------------- Queue drawer ---------------- */
.queue-drawer {
    position: fixed; top: 0; right: 0; bottom: var(--player-height);
    width: var(--queue-width); max-width: 86vw;
    background: rgba(18,18,18,0.97);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-left: 1px solid var(--border);
    z-index: 60;
    transform: translateX(100%);
    transition: transform 0.24s ease;
    display: flex; flex-direction: column;
}
.queue-drawer.open { transform: translateX(0); }
/* On wide screens the drawer should push the content rather than cover it, so
   the last column of cards is never hidden behind it. */
@media (min-width: 901px) {
    #app:has(.queue-drawer.open) #main { margin-right: var(--queue-width); }
    #app:has(.queue-drawer.open) #sidebar { grid-column: 1; }
    .queue-drawer { box-shadow: -14px 0 40px rgba(0, 0, 0, 0.45); }
}
.queue-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.queue-header h3 { font-size: 16px; font-weight: 800; }
.queue-list { flex: 1; overflow-y: auto; padding: 10px 12px 20px; }
.queue-item {
    display: flex; align-items: center; gap: 11px;
    padding: 8px 8px; border-radius: 6px; cursor: pointer;
}
.queue-item:hover { background: var(--bg-hover); }
.queue-item.current { background: var(--accent-soft); }
.queue-item img, .queue-item .qi-art {
    width: 42px; height: 42px; border-radius: 4px;
    background: var(--bg-card); flex-shrink: 0; object-fit: cover;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted-dim); font-size: 14px;
}
.queue-item .qi-meta { min-width: 0; }
.queue-item .qi-title {
    font-size: 13px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.queue-item .qi-artist { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------- Modals ---------------- */
.modal {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,0.8);
    display: none; align-items: center; justify-content: center;
    padding: 20px;
}
.modal.open { display: flex; }
.modal-content {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px; padding: 26px;
    width: 100%; max-width: 460px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: fade 0.18s ease;
}
.modal-content h3 { font-size: 20px; font-weight: 800; margin-bottom: 16px; }
.modal-content input {
    width: 100%; padding: 13px 15px;
    border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--bg-main); color: var(--text); font-size: 14px;
}
.modal-content input:focus { outline: none; border-color: var(--accent); }
.modal-hint { font-size: 12px; color: var(--muted); margin: 10px 0 18px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------------- Spotify library (connected account) ---------------- */
.spotify-library {
    display: flex; flex-direction: column; gap: 8px;
    margin-bottom: 14px;
    max-height: 260px; overflow-y: auto;
}
.spotify-library[hidden] { display: none; }
.sp-row {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
}
.sp-row .sp-name {
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-weight: 600;
}
.sp-row .sp-count { color: var(--muted-dim); font-size: 11px; flex-shrink: 0; }
.sp-row .btn { flex-shrink: 0; }
.sp-account {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; color: var(--muted);
    padding: 2px 2px 6px;
}
.sp-account strong { color: var(--text); }
.sp-note { font-size: 12px; color: var(--muted); line-height: 1.5; }
.sp-note .btn { margin-top: 8px; }

/* ---------------- Import progress ---------------- */
.import-bar {
    display: block;
    height: 6px; border-radius: 3px;
    background: var(--bg-hover);
    margin-top: 10px;
    overflow: hidden;
}
.import-bar span {
    display: block; height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ---------------- Build tag + update banner ---------------- */
.build-tag {
    font-size: 10px; color: var(--muted-dim);
    text-align: center; padding-top: 8px;
    font-variant-numeric: tabular-nums;
}
.update-banner {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: calc(var(--player-height) + 12px);
    z-index: 400;
    display: flex; align-items: center; gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: 500px;
    padding: 8px 8px 8px 18px;
    font-size: 13px; font-weight: 600;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
    max-width: 92vw;
}
.update-banner[hidden] { display: none; }

/* ---------------- Toast ---------------- */
#toast {
    position: fixed; bottom: calc(var(--player-height) + 18px);
    left: 50%; transform: translateX(-50%) translateY(10px);
    background: var(--bg-card); color: var(--text);
    padding: 11px 20px; border-radius: 500px;
    font-size: 13px; font-weight: 600;
    z-index: 300; box-shadow: 0 8px 28px rgba(0,0,0,0.55);
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); }

/* On phones the full-screen player covers the bottom bar, so a bottom-anchored
   toast would land on the transport controls. Move it to the top instead. */
@media (max-width: 900px) {
    #toast {
        bottom: auto;
        top: calc(12px + env(safe-area-inset-top, 0px));
        transform: translateX(-50%) translateY(-10px);
    }
    #toast.show { transform: translateX(-50%) translateY(0); }
}

/* ---------------- iOS / Android specifics ---------------- */
/* the full-screen player sits above everything and blocks background scroll */
body.np-visible { overflow: hidden; }

/* iOS Safari: a <button> in the bar needs an explicit font-size or text
   renders huge inside the flex row */
.player-left {
    -webkit-appearance: none;
    appearance: none;
    font: inherit;
    font-size: 14px;
}
/* iOS shows a grey flash on tap; keep highlights off the chrome */
.btn, .btn-icon, .player-left, .category-card, .playlist-nav-item, .nav-item,
.track-card, .queue-item, .ctx-item {
    -webkit-tap-highlight-color: transparent;
}
/* both platforms: stop long-press selection on icon buttons */
.btn-icon { user-select: none; -webkit-user-select: none; touch-action: manipulation; }
/* Android/iOS both benefit from larger hit areas on touch */
@media (pointer: coarse) {
    .btn-icon { min-width: 40px; min-height: 40px; }
    .track-card { padding: 12px; }
}

/* iOS standalone mode: no browser chrome, so respect the notch + home bar */
@media (display-mode: standalone) {
    #app { height: 100dvh; }
    #sidebar { padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
}

/* Install section / offline badge */
/* ---------------- Full-screen now playing ---------------- */
.now-playing {
    position: fixed; inset: 0; z-index: 120;
    display: none;
    flex-direction: column;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 22px calc(20px + env(safe-area-inset-bottom, 0px));
    background: #121212;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    overflow: hidden;
}
.now-playing.open { display: flex; }
.now-playing.animating { display: flex; transform: translateY(0); }
/* artwork-tinted wash behind everything */
.np-backdrop {
    position: absolute; inset: -20% -20% 0;
    background: radial-gradient(120% 80% at 50% 0%, var(--np-hue, #1db954) 0%, transparent 65%);
    opacity: 0.35;
    transition: background 0.4s ease;
    pointer-events: none;
}
.np-header {
    position: relative; z-index: 1;
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; padding: 4px 0 6px;
}
.np-heading { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.np-kicker {
    font-size: 10px; font-weight: 700; letter-spacing: 0.14em;
    text-transform: uppercase; color: var(--muted);
}
.np-source { font-size: 11px; color: var(--muted-dim); }

.np-art-wrap {
    position: relative; z-index: 1;
    flex: 1 1 auto;
    min-height: 0;
    display: flex; align-items: center; justify-content: center;
    padding: 10px 0;
}
.np-art-wrap img {
    /* intrinsic square; never let flex squeeze the height */
    width: auto; height: auto;
    max-width: min(78vw, 380px);
    max-height: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 10px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
    visibility: hidden;
}
.np-art-wrap img.has-art { visibility: visible; }

.np-meta {
    position: relative; z-index: 1;
    display: flex; align-items: flex-start; gap: 12px;
    padding-bottom: 14px;
}
.np-titles { flex: 1; min-width: 0; }
.np-title {
    font-size: 21px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.25;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.np-artist {
    font-size: 15px; color: var(--muted); margin-top: 5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.np-like { flex-shrink: 0; }
.np-like.liked { color: var(--accent); }

.np-progress { position: relative; z-index: 1; padding-bottom: 6px; }
.np-progress input[type="range"] {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 5px; border-radius: 3px;
    background: linear-gradient(to right, #fff var(--fill, 0%), #555 var(--fill, 0%));
    cursor: pointer;
}
.np-progress input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 13px; height: 13px; border-radius: 50%; background: #fff;
}
.np-progress input[type="range"]::-moz-range-thumb {
    width: 13px; height: 13px; border: none; border-radius: 50%; background: #fff;
}
.np-times {
    display: flex; justify-content: space-between;
    font-size: 11px; color: var(--muted); margin-top: 7px;
    font-variant-numeric: tabular-nums;
}

.np-controls {
    position: relative; z-index: 1;
    display: flex; align-items: center; justify-content: space-between;
    gap: 6px; padding: 14px 6px 10px;
}
.np-controls .btn-icon .icon { width: 21px; height: 21px; }
.np-skip .icon { width: 26px; height: 26px; }
.np-controls .btn-icon.active { color: var(--accent); }
.np-play {
    width: 64px; height: 64px; border-radius: 50%;
    background: #fff; color: #000;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.np-play .icon { width: 26px; height: 26px; margin-left: 3px; }
.np-play:active { transform: scale(0.95); }

/* ---------------- Synced lyrics ---------------- */
.np-lyrics {
    position: relative; z-index: 1;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px 4px 20px;
    mask-image: linear-gradient(to bottom, transparent 0, #000 48px, #000 calc(100% - 48px), transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 48px, #000 calc(100% - 48px), transparent 100%);
}
.np-lyrics-lines {
    display: flex; flex-direction: column; gap: 14px;
    padding: 30vh 0;
}
.lyr-line {
    font-size: 20px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.35;
    color: var(--muted-dim);
    opacity: 0.55;
    transition: color 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
    cursor: pointer;
}
.lyr-line:hover { color: var(--muted); }
.lyr-line.past { opacity: 0.4; }
.lyr-line.active {
    color: #fff;
    opacity: 1;
    transform: scale(1.015);
    transform-origin: left center;
}
.lyr-line.plain {
    font-size: 15px; font-weight: 500; line-height: 1.7;
    color: var(--muted);
    opacity: 0.85;
    cursor: default;
}
.lyr-line.plain:hover { color: var(--muted); }
.np-lyrics-loading, .np-lyrics-empty {
    color: var(--muted);
    font-size: 14px; font-weight: 600;
    text-align: center;
    padding: 30vh 20px;
}
.np-footer .btn-icon.active { color: var(--accent); }

.np-footer {
    position: relative; z-index: 1;
    display: flex; justify-content: center; gap: 8px; padding-top: 4px;
}
.np-footer .btn-icon {
    width: auto; height: 34px; border-radius: 500px;
    padding: 0 14px; gap: 7px; font-size: 12px; font-weight: 700;
    color: var(--muted);
}
.np-footer .btn-icon .icon { width: 15px; height: 15px; }

.install-section { margin-top: auto; }
.install-section .btn { color: var(--muted); }
.offline-note {
    display: none; align-items: center; gap: 7px;
    font-size: 11px; color: var(--muted-dim);
    padding: 8px 12px 0;
}
.offline-note.show { display: flex; }
.offline-note .icon { color: var(--accent); }

/* ---------------- Context menu ---------------- */
.ctx-menu {
    position: fixed; z-index: 9999; min-width: 190px;
    background: var(--bg-card); border: 1px solid #3a3a3a;
    border-radius: var(--radius); overflow: hidden;
    box-shadow: 0 12px 34px rgba(0,0,0,0.6);
    padding: 4px;
}
.ctx-item {
    padding: 10px 12px; border-radius: 4px;
    font-size: 13px; font-weight: 600; color: var(--text);
    cursor: pointer; display: flex; align-items: center; gap: 10px;
}
.ctx-item:hover { background: var(--bg-hover); }
.ctx-item.danger { color: #f0685f; }

/* ---------------- Mobile ---------------- */
@media (max-width: 900px) {
    :root { --player-height: 76px; }
    #app { grid-template-columns: 1fr; }
    #sidebar {
        position: fixed; top: 0; bottom: 0; left: 0;
        width: min(300px, 86vw); z-index: 90;
        transform: translateX(-100%);
        transition: transform 0.24s ease;
        /* keep the drawer scrollable with room for the OS home indicator */
        padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    }
    #sidebar.open { transform: translateX(0); }
    /* the drawer covers the header toggle, so it carries its own close button */
    .sidebar-close { display: inline-flex; }
    #menu-toggle { display: inline-flex; }
    #header { padding: 0 16px; }
    .view { padding: 8px 16px 28px; }
    .greeting { font-size: 22px; }
    .section-title { font-size: 17px; }
    .track-list { grid-template-columns: repeat(auto-fill, minmax(142px, 1fr)); gap: 12px; }
    .categories-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .track-actions { opacity: 1; }

    /* Single row: [art + title ......... play + next | queue]
       No absolute positioning, so nothing can overlap the artwork. */
    #player { padding: 0 8px 0 10px; gap: 8px; }
    .player-left { width: auto; flex: 1 1 auto; min-width: 0; gap: 10px; }
    #player-art { width: 44px; height: 44px; }
    .player-info { min-width: 0; }
    .player-title { font-size: 12.5px; }
    .player-artist { font-size: 11px; }

    .player-center {
        flex: 0 0 auto; max-width: none; flex-direction: row;
        gap: 2px; align-items: center;
    }
    .player-controls { gap: 2px; }
    .player-controls .btn-icon { width: 40px; height: 40px; }
    .player-controls #player-shuffle,
    .player-controls #player-repeat { display: none; }
    .player-controls .play-btn { width: 40px; height: 40px; margin: 0; }

    .player-right { flex: 0 0 auto; gap: 4px; }
    #queue-toggle { width: 40px; height: 40px; }
    #volume-bar, .volume-btn { display: none; }
    .like-btn { display: none; }

        /* safe-area padding so nothing hides under a notch / home indicator */
        #player {
            padding-left: max(10px, env(safe-area-inset-left, 0px));
            padding-right: max(8px, env(safe-area-inset-right, 0px));
            padding-bottom: env(safe-area-inset-bottom, 0px);
        }
        #header {
            padding-top: env(safe-area-inset-top, 0px);
            height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
        }
        .view { padding-bottom: calc(var(--player-height) + 28px + env(safe-area-inset-bottom, 0px)); }
        #main { padding-bottom: var(--player-height); }

    /* thin progress line pinned to the very top of the bar, with a tall
       invisible touch target so it can actually be grabbed on a phone */
    .progress-container {
        position: absolute;
        top: 0; left: 0; right: 0;
        width: 100%;
        padding: 10px 0;
        margin-top: -10px;
        gap: 0;
        pointer-events: none;
    }
    .progress-container span { display: none; }
    #progress-bar {
        pointer-events: auto;
        height: 4px; border-radius: 0;
        background: linear-gradient(to right, var(--accent) var(--fill, 0%), rgba(255,255,255,0.22) var(--fill, 0%));
    }

    .playlist-hero { padding: 18px; gap: 16px; }
    .playlist-hero-art { width: 112px; height: 112px; font-size: 28px; }
    .playlist-hero-info h1 { font-size: 21px; }
    .search-container { flex-direction: column; }
    .library-header { align-items: flex-start; }
}