/* ---------------------------------------------------------------------------
   Theme tokens. Colors live here only — layout rules below never hard-code
   a color, so re-theming is a matter of editing this block.
--------------------------------------------------------------------------- */
:root {
    --bg:          #16171b;
    --bg-raised:   #1e1f24;
    --bg-active:   #2a2c33;
    --text:        #e8e6e1;
    --text-dim:    #8b8f98;
    --fav:         #e5536b;   /* the favourite heart (issue #32) */
    --accent:      #58a6ff;
    --accent-soft: #1c3350;
    --border:      #2a2c33;

    --badge-bg:    #33363e;
    --badge-text:  #c8c6c1;
    --flac:        #2f9e5f;
    --mp3:         #cf8b2d;
    --m4a:         #4a7fd4;
    --wav:         #8a6fd0;
    --ogg:         #3aa8a0;
    --mixed:       #6a6e78;
    --mch:         #d4a93c;

    --ok:          #2f9e5f;
    --danger:      #d9534f;
    --warn:        #e0a84e;

    /* Spectrum analyzer palettes (issue #6): each is a run of stops
       --spec-<name>-1, -2, … (top to bottom), read by js/app.js at load and
       registered with the analyzer; the same tokens paint the menu swatches. */
    --spec-accent-1:  var(--accent);
    --spec-accent-2:  var(--text-dim);
    --spec-classic-1: #d94a3d;
    --spec-classic-2: #f2c14e;
    --spec-classic-3: #3fae6a;
    --spec-prism-1:   #b03a6a;
    --spec-prism-2:   #de5b3b;
    --spec-prism-3:   #ecaa3c;
    --spec-prism-4:   #e5d93a;
    --spec-prism-5:   #8fd04c;
    --spec-prism-6:   #3bbba1;
    --spec-prism-7:   #3b8fd8;
    --spec-prism-8:   #6d4ec2;
    --spec-fire-1:    #fff1a8;
    --spec-fire-2:    #f7a521;
    --spec-fire-3:    #d3261c;
    --spec-steel-1:   #d3e6ff;
    --spec-steel-2:   #4682b4;
    --spec-steel-3:   #1e3a5f;

    /* Widest a panel's content may run on a large screen; see "Centred content column". */
    --content-max: 1000px;
    /* Player column width in the desktop three-column layout: .player's own 26rem
       plus #panel-player's 1rem padding on each side. */
    --player-col: 28rem;
}

/* ---------------------------------------------------------------------------
   Base
--------------------------------------------------------------------------- */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 ui-sans-serif, system-ui, sans-serif;
    overflow: hidden;
}

.sprite { display: none; }
.hidden { display: none !important; }

/* Scrollbars: no track, a rounded thumb wide enough to grab, brightening on
   hover. Applies to every scrollable box (album/track lists, settings,
   folder browser, textareas).

   Two mechanisms, deliberately kept apart: browsers that understand
   ::-webkit-scrollbar (Chromium, Edge, Safari) get a 14px lane with an
   inset 10px thumb; Firefox gets the standard properties. Chromium ignores
   the ::-webkit-* rules as soon as scrollbar-width/scrollbar-color are set
   on the same element, which is why the standard properties are limited to
   engines WITHOUT the pseudo-element. */
@supports not selector(::-webkit-scrollbar) {
    * {
        scrollbar-width: auto;
        scrollbar-color: var(--badge-bg) transparent;
    }
}
::-webkit-scrollbar { width: 14px; height: 14px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--badge-bg);
    border-radius: 7px;
    border: 2px solid transparent;   /* inset look: the thumb floats in its lane */
    background-clip: content-box;
    min-height: 40px;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--text-dim); }
::-webkit-scrollbar-corner { background: transparent; }

.icon {
    width: 24px;
    height: 24px;
    fill: currentColor;
    display: block;
}

button {
    background: none;
    border: 0;
    padding: 0;
    color: inherit;
    cursor: pointer;
    font: inherit;
}

.msg { color: var(--text-dim); text-align: center; padding: 2rem 1rem; }

/* ---------------------------------------------------------------------------
   Panels: horizontal scroll-snap carousel
--------------------------------------------------------------------------- */
#panels {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    /* Without this, a vertically-scrollable panel can swallow a backward
       swipe while letting a forward one through, since the browser guesses
       axis ownership per-gesture instead of per-element. Own the x-axis
       here explicitly so panel switching is symmetric in both directions. */
    touch-action: pan-x;
}
#panels::-webkit-scrollbar { display: none; }

.panel {
    flex: 0 0 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.panel-head {
    padding: max(0.75rem, env(safe-area-inset-top)) 1rem 0.5rem;
    border-bottom: 1px solid var(--border);
}
.panel-head h2 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.panel-scroll {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    /* Cede the x-axis to #panels; own only vertical scrolling. */
    touch-action: pan-y;
    /* Anchors child offsetTop to this element (not the page) — see the
       scroll-anchor logic in app.js's setViewMode(). */
    position: relative;
}

/* Centred content column. On a wide window a list row otherwise runs edge to
   edge — artist far left, format badges a metre away on the right — and
   lines past ~90 characters stop being scannable. Cap the CONTENT of each
   panel (header rows and the scrolling list) and centre it; the panel, its
   header border and the scroll container stay full width so nothing else
   moves. The `.panel` prefix is deliberate: it out-ranks `.album-list {
   margin: 0 }` and `.panel-head h2 { margin: ... }` below. Column-count
   agnostic code (scroll anchor, jump-to-letter) needs no change. */
.panel .panel-head > *,
.panel .panel-scroll > * {
    max-width: var(--content-max);
    margin-left: auto;
    margin-right: auto;
}

/* Panel nav arrows (desktop only) */
.nav-arrow {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    color: var(--text-dim);
    padding: 1rem 0.5rem;
    display: none;
}
.nav-arrow:hover { color: var(--text); }
.nav-prev { left: 0.25rem; }
.nav-next { right: 0.25rem; }

@media (min-width: 768px) {
    .nav-arrow { display: block; }
    .nav-arrow.nav-hidden { display: none; }
}

/* Desktop: albums, player and tracks side by side. The carousel is a phone
   layout; a wide window has room for all three, so above this breakpoint
   #panels becomes a grid and app.js turns the panel-switching helpers into
   no-ops (see isDesktop()). Below it, nothing here applies and the carousel
   is exactly as before. Keep this breakpoint and app.js's matchMedia in sync. */
@media (min-width: 1200px) {
    #panels {
        display: grid;
        grid-template-columns: minmax(0, 1fr) var(--player-col) minmax(0, 1fr);
        /* One row exactly the container's height. An `auto` row would size
           itself to the tallest content — the 2000-row album list — and
           push the vertically-centred player tens of thousands of pixels
           below the fold. min-height: 0 lets each panel shrink to the row
           so its own .panel-scroll does the scrolling, as in the carousel. */
        grid-template-rows: minmax(0, 1fr);
        overflow-x: hidden;
        scroll-snap-type: none;
    }
    .panel { scroll-snap-align: none; min-height: 0; }
    #panel-player {
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
    .nav-arrow { display: none !important; }
}

/* ---------------------------------------------------------------------------
   Albums panel
--------------------------------------------------------------------------- */
.head-tools { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }

.filter-input {
    flex: 1;
    min-width: 0;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 0.4rem 0.7rem;
    font: inherit;
}
.filter-input:focus { outline: 1px solid var(--accent); }

.icon-btn { color: var(--text-dim); padding: 0.4rem; }
.icon-btn:hover { color: var(--text); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn:disabled:hover { color: var(--text-dim); }
.icon-btn.active { color: var(--accent); }

.album-toolbar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.toolbar-group { display: flex; align-items: center; gap: 0.15rem; background: var(--bg-raised);
                  border: 1px solid var(--border); border-radius: 6px; }
.toolbar-group .icon-btn { padding: 0.3rem 0.4rem; }

.reindex-status { margin: 0 0 0.5rem; font-size: 0.85rem; color: var(--accent); }
/* The reindex line keeps its close cross top-right, next to text that may wrap. */
.reindex-summary { display: flex; align-items: flex-start; gap: 0.25rem; }
.reindex-summary > span { flex: 1; min-width: 0; padding-top: 0.1rem; }
.reindex-summary .icon-btn { flex: none; padding: 0.1rem; margin: -0.1rem 0 0; }
.reindex-summary .icon { width: 18px; height: 18px; }

/* Tracks panel: the open album's artist and title sit in a block that mirrors
   the album panel's icon toolbar (same slot, same height), so the two
   headers line up side by side on desktop. */
.tracks-context {
    display: flex;
    align-items: center;   /* the heart button (issue #32) sits level with the text; the two texts differ by 0.1rem */
    gap: 0.6rem;
    min-height: calc(24px + 0.8rem);   /* = the album toolbar row: a 24px icon in an .icon-btn with 0.4rem padding */
    margin-bottom: 0.5rem;
    overflow: hidden;
    white-space: nowrap;
}
.tc-artist { color: var(--text-dim); font-size: 0.9rem; flex: none; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.tc-title  { font-weight: 600; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
/* Album title as "copy folder path" (mouse devices; js/app.js updateFolderLink()). */
.tc-title.is-folder-link { cursor: pointer; }
.tc-title.is-folder-link:hover { color: var(--accent); text-decoration: underline; }
#folder-status { overflow-wrap: anywhere; }
/* The textarea js/app.js copies from where the Clipboard API is unavailable (plain http on a LAN address). */
.offscreen { position: fixed; top: 0; left: -10000px; opacity: 0; }

.album-list, .track-list { list-style: none; margin: 0; padding: 0; }

.album-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}
.album-list li:hover { background: var(--bg-raised); }
.album-list li.active { background: var(--accent-soft); }
.album-list li.filtered, .track-list li.filtered { display: none; }

/* Rows whose folder is unreachable (NAS offline): still listed, greyed out;
   tracks aren't clickable, albums still open so the list can be browsed. */
.album-list li.unavailable, .track-list li.unavailable { opacity: 0.45; }
.track-list li.unavailable { cursor: default; }
.track-list li.unavailable:hover { background: transparent; }
.album-list li.unavailable .a-title::after,
.track-list li.unavailable .t-title::after { content: " · unavailable"; color: var(--text-dim); font-size: 0.8em; }

.thumb {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    border-radius: 4px;
    object-fit: cover;
    background: var(--bg-raised);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    overflow: hidden;
}

.a-meta { flex: 1; min-width: 0; }
.a-artist { color: var(--text-dim); font-size: 0.85rem; display: block;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.a-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* A cut-off title or artist scrolls to its end while its row is hovered (mouse
   only, set from js/app.js): its text, wrapped in .scroll-text on the first hover,
   slides with a transform. The transition lives on the class, so leaving jumps
   back; at rest the span is plain inline text, so the ellipsis works as before.
   The list is SCROLL_LINES in js/app.js; :is() outweighs each line's own
   text-overflow rule wherever it sits in this file. */
:is(.a-title, .a-artist, .t-artist, .tc-artist, .tc-title).is-scrolling { text-overflow: clip; }
.is-scrolling > .scroll-text { display: inline-block; transform: translateX(var(--title-scroll));
                               transition: transform var(--title-scroll-time) linear 0.3s; }
.a-year { color: var(--text-dim); }
/* Folder label (issue #19): present only while two or more music folders are shown. */
.a-root { color: var(--text-dim); font-size: 0.75rem; display: block;
          white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.badges { display: flex; flex-direction: column; gap: 0.25rem; align-items: flex-end; }
/* Favourite album (issue #32): a small heart with the badges; the button
   next to the open album's title is outline while off, filled while on. */
.a-fav { display: flex; color: var(--fav); }
.a-fav .icon { width: 14px; height: 14px; }
.fav-btn { flex: none; padding: 0.2rem; }
.fav-btn .icon { width: 20px; height: 20px; }
.fav-btn.is-on, .fav-btn.is-on:hover { color: var(--fav); }
#fav-filter-btn.active { color: var(--fav); }

/* Track search hits (issue #31): the same rows as the album list, under it,
   while the search box has two or more characters; never in grid view. */
.hits-head {
    margin: 1rem 1rem 0.25rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
}

.badge {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: var(--badge-bg);
    color: var(--badge-text);
    white-space: nowrap;
}
.badge.b-FLAC { background: var(--flac); color: #06180d; }
.badge.b-MP3  { background: var(--mp3);  color: #201302; }
.badge.b-M4A, .badge.b-AAC { background: var(--m4a); color: #0a1526; }
.badge.b-WAV  { background: var(--wav);  color: #150d24; }
.badge.b-OGG, .badge.b-OGA, .badge.b-OPUS { background: var(--ogg); color: #06201e; }
.badge.b-MIXED { background: var(--mixed); color: #17181c; }
.badge.b-PLAYLIST { background: var(--accent); color: #06121f; }
.badge.mch { background: var(--mch); color: #241a02; }

/* Cover grid display */
.album-list.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    padding: 1rem;
}
.album-list.grid-view li {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    padding: 0;
    border-bottom: 0;
    text-align: center;
}
.album-list.grid-view .thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    flex: none;
    border-radius: 6px;
}
.album-list.grid-view .a-meta { flex: none; }
.album-list.grid-view .badges { flex-direction: row; justify-content: center; }
/* Jump-to-letter target: force it to start a new row so it lands top-left,
   rather than sharing a row (and losing top-left billing) with whichever
   albums sort just before it. */
.album-list.grid-view li.jump-target { grid-column-start: 1; }

/* ---------------------------------------------------------------------------
   Jump-to-letter panel
--------------------------------------------------------------------------- */
.letter-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-raised);
    width: min(22rem, 90vw);
}
.letter-panel-title { margin: 0; font-size: 0.95rem; font-weight: 600; text-align: center; }
.letter-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.4rem;
}
.letter-btn {
    padding: 0.5rem 0;
    border-radius: 6px;
    background: var(--bg-active);
    color: var(--text);
    font-weight: 600;
}
.letter-btn:hover { color: var(--accent); }
.letter-btn:disabled { color: var(--text-dim); opacity: 0.35; cursor: default; }

/* ---------------------------------------------------------------------------
   Player panel
--------------------------------------------------------------------------- */
#panel-player .panel-scroll { display: none; }
#panel-player {
    justify-content: center;
    justify-content: safe center; /* a player taller than the panel starts at the top padding instead of past it */
    /* The cover shrinks with the window height (see .cover); below its minimum the
       panel scrolls, so every control stays reachable however short the window. */
    overflow-y: auto;
    overflow-x: hidden;
    align-items: center;
    padding: 1rem;
}

.player {
    width: min(26rem, 100%); /* inside #panel-player's padding, so text never touches the edges */
    flex-shrink: 0;
    /* Never taller than the panel: what the lines below the cover need (more while a
       track plays, more again with the "Play on" row) is taken from the cover. */
    max-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.player > * { flex-shrink: 0; } /* the one-line boxes clip, so they would shrink too */

.cover {
    position: relative; /* anchors .spectrum */
    /* The only part of .player that shrinks: it gives up height until the rest fits
       inside #panel-player's padding, and its width follows (aspect-ratio). Never
       below the 13.5rem the About card needs, or 10rem once a track has replaced
       the card; past that the panel scrolls. */
    flex-shrink: 1;
    height: min(60vw, 300px);
    min-height: 13.5rem;
    aspect-ratio: 1;
    border-radius: 8px;
    background: var(--bg-raised);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 1.25rem;
}
#player.has-track .cover { min-height: 10rem; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-fallback { width: 40%; height: 40%; color: var(--text-dim); }

/* About card: name, version, copyright and three links, filling the cover box
   until a track is loaded here or on a remote target (js/app.js keeps
   has-track on #player). The same markup sits in the About overlay behind the
   info button, where .about-panel gives it room. */
.about-card {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    padding: 0.75rem;
    background: var(--bg-raised);
    text-align: center;
}
#player.has-track .about-card { display: none; }
.about-logo { width: 22%; height: 22%; color: var(--accent); margin-bottom: 0.3rem; }
.about-name { margin: 0; font-size: 1.15rem; font-weight: 600; }
.about-version, .about-copy { margin: 0; font-size: 0.75rem; color: var(--text-dim); }
.about-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.2rem 0.9rem;
    margin-top: 0.6rem;
    font-size: 0.8rem;
}
.about-link { color: var(--accent); text-decoration: none; }
.about-link:hover { text-decoration: underline; }

/* Spectrum analyzer (issue #6): a strip over the lower part of the cover, shown
   only while this browser itself is playing. The library appends its own canvas
   into #spectrum and follows the container's size; its colors are read from the
   :root tokens at runtime (js/app.js, initSpectrum), which also sets has-spectrum. */
.spectrum {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 42%;
    display: none;
    pointer-events: none;
}
#player.has-spectrum.is-playing:not(.is-remote) .spectrum { display: block; }
.spectrum.is-full { height: 100%; } /* the radial style draws in a circle */
.spectrum canvas { display: block; width: 100% !important; height: 100% !important; }

/* Style/colour menu, in the cover's top corner: the button shows on hover
   (the analyzer is desktop-only, so hover exists) and the popover sits
   inside the cover. Swatches paint from the same --spec-* tokens the
   analyzer was given. */
.spectrum-btn {
    display: none;
    position: absolute;
    top: 0.4rem; right: 0.4rem;
    padding: 0.3rem;
    border-radius: 6px;
    background: var(--bg-raised);
    color: var(--text); /* light icon: readable on a black cover, the box on a white one */
    opacity: 0;
    transition: opacity 0.15s;
}
#player.has-spectrum .spectrum-btn { display: block; }
#player:not(.has-track) .spectrum-btn { display: none; } /* the About card is showing */
.cover:hover .spectrum-btn, .cover.menu-open .spectrum-btn, .spectrum-btn:focus-visible { opacity: 1; }
.spectrum-btn:hover { color: var(--accent); }
.spectrum-menu {
    position: absolute;
    top: 2.7rem; right: 0.4rem;
    max-width: calc(100% - 0.8rem);
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-raised);
    text-align: left;
    z-index: 5;
}
.spectrum-row-label { font-size: 0.7rem; color: var(--text-dim); letter-spacing: 0.05em;
                      text-transform: uppercase; margin-bottom: 0.25rem; }
.spectrum-row { display: flex; gap: 0.3rem; flex-wrap: wrap; align-items: center; }
.chip { padding: 0.25rem 0.55rem; border-radius: 999px; background: var(--bg-active);
        color: var(--text); font-size: 0.8rem; }
.chip:hover { color: var(--accent); }
.chip.active { background: var(--accent-soft); color: var(--accent); }
.swatch { width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 2px solid transparent; }
.swatch:hover { border-color: var(--text-dim); }
.swatch.active { border-color: var(--accent); }
.swatch-accent  { background: linear-gradient(var(--spec-accent-1), var(--spec-accent-2)); }
.swatch-classic { background: linear-gradient(var(--spec-classic-1), var(--spec-classic-2), var(--spec-classic-3)); }
.swatch-prism   { background: linear-gradient(var(--spec-prism-1), var(--spec-prism-3), var(--spec-prism-5), var(--spec-prism-7), var(--spec-prism-8)); }
.swatch-fire    { background: linear-gradient(var(--spec-fire-1), var(--spec-fire-2), var(--spec-fire-3)); }
.swatch-steel   { background: linear-gradient(var(--spec-steel-1), var(--spec-steel-2), var(--spec-steel-3)); }

.np-album  { margin: 0; color: var(--text-dim); font-size: 0.85rem; max-width: 100%;
             white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-title  { margin: 0.15rem 0; font-size: 1.3rem; font-weight: 600; max-width: 100%;
             white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-title.is-placeholder { cursor: pointer; color: var(--accent); }
/* Now-playing ticker (js/app.js updateTicker()): a line too long to fit runs past
   continuously as [text][gap][copy][gap]; moving by text + gap puts the copy where
   the text began, so the loop has no seam. The copy is ::after, never textContent. */
:is(.np-album, .np-title, .np-artist).is-ticker { text-overflow: clip; text-align: left; }
.is-ticker > .ticker-text { display: inline-block; padding-right: 3rem;
                            animation: ticker var(--ticker-time) linear 1.5s infinite; }
.is-ticker > .ticker-text::after { content: attr(data-ticker); padding-left: 3rem; }
@keyframes ticker { to { transform: translateX(var(--ticker-shift)); } }
/* Three blinks once the page is ready (js/app.js, flashPlaceholder). */
.np-title.is-placeholder.flash { animation: placeholder-flash 0.6s ease-in-out 3; }
@keyframes placeholder-flash { 50% { opacity: 0.15; } }
@media (prefers-reduced-motion: reduce) {
    .np-title.is-placeholder.flash { animation: none; }
}
.np-artist { margin: 0; color: var(--text-dim); max-width: 100%;
             white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-tech   { margin: 0.35rem 0 0; color: var(--text-dim); font-size: 0.75rem;
             letter-spacing: 0.05em; min-height: 1.2em; }

.seek-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    margin: 1.25rem 0 0.5rem;
}
.time { font-variant-numeric: tabular-nums; font-size: 0.8rem; color: var(--text-dim); min-width: 2.6rem; }
#time-cur { text-align: right; }

input[type="range"] {
    flex: 1;
    appearance: none;
    -webkit-appearance: none;
    height: 4px;
    border-radius: 2px;
    background: var(--bg-active);
    cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 0;
}
input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 0;
}
input[type="range"]:disabled::-webkit-slider-thumb { background: var(--text-dim); }
input[type="range"]:disabled::-moz-range-thumb { background: var(--text-dim); }

.controls {
    display: flex;
    align-items: center;
    gap: 1.4rem;
    margin: 0.75rem 0;
}
.ctrl { color: var(--text); }
.ctrl:hover { color: var(--accent); }
.ctrl:disabled { color: var(--text-dim); opacity: 0.4; cursor: default; }
.ctrl:disabled:hover { color: var(--text-dim); }
.ctrl .icon { width: 34px; height: 34px; }
.ctrl-main .icon { width: 56px; height: 56px; }
.ctrl-mode { color: var(--text-dim); }
.ctrl-mode .icon { width: 22px; height: 22px; }

/* Mode toggles light up via player state classes */
#player.is-shuffle #btn-shuffle,
#player.is-repeat #btn-repeat { color: var(--accent); }

/* Play/pause icon swap driven purely by player state class */
#player .icon-pause { display: none; }
#player.is-playing .icon-play { display: none; }
#player.is-playing .icon-pause { display: block; }

#player .icon-muted { display: none; }
#player.is-muted .icon-vol { display: none; }
#player.is-muted .icon-muted { display: block; }

.volume-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 60%;
    margin-top: 0.25rem;
}

/* Remote control: "Play on" picker (remote side) and the device note (device side).
   The picker row only appears once another device is online, so a browser that
   never meets one sees the player exactly as before. */
.target-row {
    display: flex;
    flex-wrap: wrap;            /* the status line breaks below the dropdown */
    justify-content: center;    /* and neither state shifts the label + dropdown */
    align-items: center;
    gap: 0.35rem 0.5rem;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--text-dim);
}
.target-select {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 0.3rem 0.5rem;
    font: inherit;
    font-size: 0.85rem;
    max-width: 14rem;
}
.target-select:focus { outline: 1px solid var(--accent); }
#player.is-remote .target-select { color: var(--accent); }
.target-status { flex-basis: 100%; text-align: center; font-size: 0.8rem; }
.target-status:empty { display: none; }
.target-status.is-error { color: var(--danger); }
.target-status .text-btn { font-size: inherit; padding: 0.1rem 0.4rem; }
.device-note { margin: 0.6rem 0 0; font-size: 0.75rem; color: var(--text-dim); }

/* ---------------------------------------------------------------------------
   Tracks panel
--------------------------------------------------------------------------- */
.track-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}
.track-list li:hover { background: var(--bg-raised); }
.track-list li.active { background: var(--accent-soft); }

.t-no { color: var(--text-dim); font-variant-numeric: tabular-nums; min-width: 1.6rem; text-align: right; }
.t-meta { flex: 1; min-width: 0; }
.t-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
           overflow: hidden; } /* two lines, then an ellipsis */
.t-title.is-expanded { -webkit-line-clamp: unset; } /* in full while the row is hovered (js/app.js) */
.t-artist { display: block; color: var(--text-dim); font-size: 0.8rem;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem;
          min-width: 2.25rem; } /* duration over rating, stacked like the badges */
.t-dur, .t-dr { color: var(--text-dim); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
/* Tags the player uses but the file lacks: "no ReplayGain or DR" under the
   track's title, and a summary under the open item's title. */
.t-untagged { display: block; color: var(--text-dim); font-size: 0.75rem; font-style: italic; }
/* A track the browser could not load (issue #29): marked where it sits, playback moves on. */
.t-failed { display: block; color: var(--danger); font-size: 0.75rem; font-style: italic; }
.tags-note { margin: 0 0 0.5rem; font-size: 0.8rem; color: var(--warn); }

/* ---------------------------------------------------------------------------
   Autoplay-unlock overlay
--------------------------------------------------------------------------- */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
}
.unlock {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    color: var(--text);
    font-size: 1.1rem;
    padding: 2rem 3rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-raised);
}
.unlock .icon { width: 48px; height: 48px; color: var(--accent); }

.confirm-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.75rem 2rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-raised);
    color: var(--text);
    text-align: center;
    width: min(20rem, 85vw);
}
.confirm-title { margin: 0; font-size: 1.1rem; font-weight: 600; }
.confirm-body  { margin: 0; color: var(--text-dim); font-size: 0.9rem; }
.confirm-actions { display: flex; gap: 0.75rem; margin-top: 0.5rem; width: 100%; }
.confirm-btn {
    flex: 1;
    padding: 0.6rem 0;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
}
.confirm-stay  { background: var(--accent); color: #06121f; }
.confirm-leave { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }

/* Demo welcome card (issue #25), once per demo account. */
.welcome-card { width: min(24rem, 88vw); }
.welcome-card .confirm-body { text-align: left; }
.welcome-card .confirm-actions .confirm-btn { flex: 0 0 auto; padding: 0.6rem 2rem; margin: 0 auto; }
.welcome-logo { width: 48px; height: 48px; color: var(--accent); }

/* Roles (issue #25): <body data-role> hides what the session cannot use. The
   server refuses anyway; this only keeps the screen honest. */
body:not([data-role="admin"]) .admin-only { display: none !important; }
body[data-role="demo"] .no-demo { display: none !important; }
body:not([data-role="listener"]) .listener-only { display: none !important; }
body:not([data-role="demo"]) .demo-only { display: none !important; }

/* Swipe hint (touch screens, once): three panel outlines with the middle one
   lit, and a hand sliding across them. Pure CSS; it stands still for anyone
   who asked for reduced motion. */
.swipe-card .confirm-actions .confirm-btn { flex: 0 0 auto; padding: 0.6rem 2rem; margin: 0 auto; }
.swipe-demo {
    position: relative;
    display: flex;
    gap: 0.4rem;
    width: 9rem;
    height: 4.5rem;
    margin: 0 auto 0.5rem;
}
.swipe-pane { flex: 1; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); }
.swipe-pane.is-current { border-color: var(--accent); background: var(--accent-soft); }
.swipe-hand {
    position: absolute;
    left: 50%; top: 50%;
    width: 32px; height: 32px;
    margin: -12px 0 0 -16px;
    color: var(--text);
    animation: swipe-hand 2.6s ease-in-out infinite;
}
@keyframes swipe-hand {
    0%, 8%    { transform: translateX(2.4rem); opacity: 0; }
    16%       { opacity: 1; }
    42%, 52%  { transform: translateX(-2.4rem); opacity: 1; }
    60%       { opacity: 0; }
    100%      { transform: translateX(2.4rem); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .swipe-hand { animation: none; }
}

/* ---------------------------------------------------------------------------
   Settings overlay + folder browser
--------------------------------------------------------------------------- */
.settings-panel {
    display: flex;
    flex-direction: column;
    width: min(40rem, 94vw);
    max-height: 90vh;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-raised);
}
.settings-head { padding: 1rem 1.25rem 0; }
.settings-title { margin: 0; font-size: 1.1rem; }
.settings-body { overflow-y: auto; padding: 0.25rem 1.25rem 1rem; }
.settings-section h3 {
    margin: 1rem 0 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
}
.settings-notice {
    margin: 0.75rem 0 0;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    background: var(--accent-soft);
    font-size: 0.9rem;
}
.settings-check { display: flex; align-items: center; gap: 0.6rem; font-size: 0.9rem; cursor: pointer; }
.settings-check input { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; margin: 0; }
.settings-hint { margin: 0.4rem 0 0; font-size: 0.8rem; color: var(--text-dim); }
.pref-libraries { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.pref-libraries .settings-check span { overflow-wrap: anywhere; }
.pref-lib-meta { color: var(--text-dim); font-size: 0.8rem; white-space: nowrap; }
.signin-actions { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; margin-top: 0.6rem; }
.signin-actions + .settings-field { margin-top: 0.9rem; }
.session-line { margin: 0; font-size: 0.9rem; }
.session-line .settings-hint { display: inline; margin: 0; }

/* Demo section (issue #25): invite row, the one-time link, the account list. */
.invite-row, .invite-result { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.invite-row .invite-role { flex: 0 0 auto; width: auto; }
.account-role { color: var(--accent); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.invite-row .settings-input, .invite-result .settings-input { flex: 1; min-width: 0; }
.invite-result .settings-input { font-family: ui-monospace, monospace; font-size: 0.8rem; }
.accounts-list { list-style: none; margin: 0.75rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; }
/* One account = a two-line card: address and role, then details and the two
   buttons — a grid, so the columns line up down the list and nothing wraps
   mid-word or strands a button on a line of its own (it did, 2026-10-01). */
.account-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.2rem 0.75rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}
.account-email { font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-email .account-you { color: var(--text-dim); font-size: 0.8rem; margin-left: 0.4rem; }
.account-role { justify-self: end; padding: 0.05rem 0.45rem; border: 1px solid currentColor; border-radius: 999px; }
.account-role.role-admin    { color: var(--accent); }
.account-role.role-listener { color: var(--ok); }
.account-role.role-demo     { color: var(--text-dim); }
.account-meta { color: var(--text-dim); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-actions { display: flex; gap: 0.25rem; justify-self: end; }
.account-row .text-btn { font-size: 0.8rem; padding: 0.15rem 0.4rem; }
/* Phones: the address gets the whole first line, the pill and the buttons share
   the second, the details wrap on a third — nothing is cut short. */
@media (max-width: 480px) {
    .account-email   { grid-column: 1 / -1; }
    .account-role    { grid-row: 2; grid-column: 1; justify-self: start; }
    .account-actions { grid-row: 2; grid-column: 2; }
    .account-meta    { grid-row: 3; grid-column: 1 / -1; white-space: normal; }
}
.accounts-empty { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.75rem; }

/* ---------------------------------------------------------------------------
   Sign-in page (login.php): a standalone page that borrows the settings
   field styles above. No script on it.
--------------------------------------------------------------------------- */
.login-body {
    height: auto;          /* the app body is a fixed, non-scrolling frame; this page is not */
    min-height: 100vh;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--bg);
    color: var(--text);
}
.login-panel {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    width: min(22rem, 100%);
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-raised);
}
.login-title { margin: 0; font-size: 1.3rem; }
.login-lead  { margin: 0; font-size: 0.9rem; color: var(--text-dim); }
.login-form  { display: flex; flex-direction: column; gap: 0.75rem; }
.login-form .confirm-btn { flex: 0 0 auto; }
.login-error { margin: 0; font-size: 0.85rem; color: var(--danger); }
.login-error:empty { display: none; }
.login-panel code { font-size: 0.8em; }
.login-link { color: var(--accent); }
/* The access form's honeypot (issue #26): off screen, never display:none,
   so a bot that skips hidden fields still fills it and a person never sees it. */
.login-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.login-captcha { width: 6rem; }
.login-captcha-img { display: block; margin: 0.3rem 0; border-radius: 6px; border: 1px solid var(--border); }

/* Folder lists (foobar2000-style): one line per folder, status first, Add…/Remove below. */
.folder-list {
    list-style: none;
    margin: 0;
    padding: 0.25rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    max-height: 11rem;
    overflow-y: auto;
}
.folder-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}
.folder-item:hover { background: var(--bg-raised); }
.folder-item.selected { background: var(--accent-soft); }
.folder-status { flex: none; width: 1.1rem; text-align: center; font-weight: 700; }
.st-ok { color: var(--ok); }
.st-bad { color: var(--danger); }
.st-new { color: var(--accent); }
.st-removing { color: var(--danger); }
.folder-path { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-meta { flex: none; font-size: 0.8rem; color: var(--text-dim); white-space: nowrap; }
.folder-main { flex: 1; min-width: 0; }
.folder-main .folder-path { display: block; }
.folder-tags { display: block; font-size: 0.75rem; color: var(--text-dim);
               white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag-coverage { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.75rem; margin: 0;
                color: var(--text); font-size: 0.85rem; }
.tag-coverage dd { margin: 0; }
.folder-item.invalid .folder-path { color: var(--danger); }
.folder-item.removing .folder-path { text-decoration: line-through; opacity: 0.6; }
.folder-item.removing .folder-meta { color: var(--danger); }
.folder-empty { padding: 0.6rem; color: var(--text-dim); font-size: 0.85rem; }
.folder-actions { display: flex; gap: 0.5rem; margin-top: 0.4rem; }
.folder-details { display: grid; gap: 0.5rem; padding: 0.75rem; margin-top: 0.5rem; border: 1px solid var(--border); border-radius: 8px; }
.icon-btn.warn { color: var(--danger); }
.icon-btn.warn:hover { color: var(--danger); }

.settings-field { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.8rem; color: var(--text-dim); }
.settings-input {
    width: 100%;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 0.4rem 0.6rem;
    font: inherit;
    font-size: 0.9rem;
}
.settings-input:focus { outline: 1px solid var(--accent); }
.settings-input[readonly] { color: var(--text-dim); cursor: default; }
textarea.settings-input { resize: vertical; font-family: ui-monospace, monospace; font-size: 0.85rem; }
.path-row { display: flex; gap: 0.5rem; }
.path-row .settings-input { flex: 1; min-width: 0; }

.text-btn { color: var(--accent); font-size: 0.9rem; padding: 0.3rem 0.5rem; border-radius: 6px; white-space: nowrap; }
.text-btn:hover { background: var(--bg-active); }
.text-danger { color: var(--danger); }

.root-error { margin: 0; color: var(--danger); font-size: 0.85rem; }

.check-list { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; }
.check-list li { padding: 0.15rem 0; word-break: break-word; }
.check-ok { color: var(--ok); }
.check-bad { color: var(--danger); }
.check-pending, .check-info { color: var(--text-dim); }

/* Dim text in settings is a strain to read; under the pointer it lights up to the
   full text colour — the line itself, or the whole row for folders and accounts.
   Pointer devices only: a touch screen has no hover and would leave it stuck lit. */
@media (hover: hover) {
    #settings-overlay .settings-section h3:hover,
    #settings-overlay .settings-hint:hover,
    #settings-overlay .settings-field:hover,
    #settings-overlay .settings-input[readonly]:hover,
    #settings-overlay .settings-check:hover .pref-lib-meta,
    #settings-overlay .account-row:hover .account-meta,
    #settings-overlay .accounts-empty:hover,
    #settings-overlay .folder-item:hover .folder-meta,
    #settings-overlay .folder-item:hover .folder-tags,
    #settings-overlay .folder-empty:hover,
    #settings-overlay .check-pending:hover,
    #settings-overlay .check-info:hover { color: var(--text); }
}

.settings-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem 1rem;
    border-top: 1px solid var(--border);
}
.settings-actions .confirm-btn { flex: 0 0 auto; padding: 0.6rem 1.2rem; }
.settings-status { flex: 1; min-width: 0; margin: 0; font-size: 0.85rem; color: var(--danger); }

/* About overlay (the card, larger) and the Usage / License & credits texts. */
.about-panel { width: min(24rem, 94vw); }
.about-panel .about-card { position: static; padding: 2rem 1.25rem 1.5rem; background: transparent; }
.about-panel .about-logo { width: 64px; height: 64px; }
.about-panel .about-name { font-size: 1.4rem; }
.about-panel .about-version, .about-panel .about-copy { font-size: 0.85rem; }
.about-panel .about-links { font-size: 0.95rem; gap: 0.3rem 1.25rem; margin-top: 1rem; }

.doc-panel { width: min(44rem, 94vw); }
.doc { font-size: 0.92rem; line-height: 1.55; }
.doc h3 {
    margin: 1.1rem 0 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
}
.doc p { margin: 0.5rem 0; }
.doc ul { margin: 0.4rem 0; padding-left: 1.2rem; }
.doc li { margin: 0.3rem 0; }
.doc a { color: var(--accent); }
.doc code {
    font-family: ui-monospace, monospace;
    font-size: 0.85em;
    padding: 0.05em 0.3em;
    border-radius: 4px;
    background: var(--bg-active);
}

.browse-panel { width: min(32rem, 94vw); }
.browse-goto { display: flex; gap: 0.5rem; margin: 0.75rem 1.25rem 0; }
.browse-goto .settings-input { flex: 1; min-width: 0; }
.browse-path { margin: 0.5rem 1.25rem; font-size: 0.85rem; color: var(--text-dim); word-break: break-all; font-family: ui-monospace, monospace; }
.browse-list { list-style: none; margin: 0; padding: 0 1.25rem 0.5rem; overflow-y: auto; max-height: 50vh; min-height: 6rem; }
.browse-entry { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.6rem; border-radius: 6px; cursor: pointer; word-break: break-all; }
.browse-entry:hover { background: var(--bg-active); }
.browse-entry .icon { flex: none; width: 20px; height: 20px; color: var(--text-dim); }
.browse-entry.not-allowed { color: var(--text-dim); }
.browse-empty { color: var(--text-dim); padding: 0.5rem 0.6rem; }

/* ---------------------------------------------------------------------------
   Small screens
--------------------------------------------------------------------------- */
@media (max-width: 480px) {
    .volume-row { display: none; } /* hardware volume on mobile */
    /* ...except while this phone is a remote: its buttons cannot reach the
       device, and the slider already sends volume/mute commands. */
    #player.is-remote .volume-row { display: flex; }

    /* Opt-in (settings > Display): one large cover per row instead of the
       auto-fill's two or three small ones. Column-count agnostic code
       elsewhere (scroll anchor, jump-to-letter) needs no change for this.
       minmax(0, 1fr), not a bare 1fr: 1fr is minmax(auto, 1fr), and the
       auto minimum lets the item's min-content width (the 100%-wide cover
       image) blow the single column out past the viewport. */
    .album-list.grid-view.grid-single-mobile { grid-template-columns: minmax(0, 1fr); }
}
