/* Pinner Music app styles.
   Layout, structure, spacing and type scale come from relayout (rl-*). This file holds only what
   relayout doesn't own: colour tokens, surfaces, the nav's fixed height, scrolling regions, and
   the look of a few custom controls. */

/* ── Theme tokens ──────────────────────────────────────────────────────────────
   Neutrals are the portal's (codesense/portal/ui/assets/css/portal.css), which were measured
   for contrast there: text 16:1 · muted 7:1 · subtle 4.6:1 against --bg in both themes.

   --brand is the mark's crimson, #dc143c. Measured: white on it 5.0, it on the light page 4.7,
   on the dark page 3.5 (fine for fills, rings and icons; not for small text, which is what
   --brand-text is for in dark). */
:root {
    color-scheme: light;
    --bg: #f5f8fb;
    --bg-elev: #ffffff;
    --bg-sunken: #f2f4f8;
    --chrome: var(--bg-elev);
    --border: #cdd1d7;
    --text: #141619;
    --text-muted: #4e5258;
    --text-subtle: #6a6e74;

    /* The mark's own colour, crimson, the same in both themes: the fill in assets/favicon.svg. It is also the UI accent. */
    --logo: #dc143c;
    --brand: var(--logo);
    --brand-on: oklch(1 0 0);
    --brand-text: var(--brand);

    /* How a folder slides in and out (music-ui.md › Dive and back animation). */
    --nav-duration: 250ms;
    --nav-ease: cubic-bezier(0.2, 0, 0, 1);

    --notice-bg: oklch(0.96 0.04 85);
    --notice-border: oklch(0.82 0.1 85);
    --danger-bg: oklch(0.96 0.03 27);
    --danger-border: oklch(0.8 0.1 27);
    --ok: oklch(0.65 0.15 150);
    --danger-text: oklch(0.5 0.17 27);

}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #171a1f;
    --bg-elev: #23262b;
    --bg-sunken: #2a2e33;
    /* The nav sinks below the page in dark, as in the portal: it is the frame, not a panel. */
    --chrome: #0b0d12;
    --border: #2f3339;
    --text: #eceff3;
    --text-muted: #989da4;
    --text-subtle: #797d83;

    /* A lighter crimson for text: 6.4:1 on --bg, 7.1:1 on --chrome, 5.0:1 on --bg-sunken. */
    --brand-text: #ff6b81;

    --notice-bg: oklch(0.3 0.04 85);
    --notice-border: oklch(0.45 0.08 85);
    --danger-bg: oklch(0.3 0.05 27);
    --danger-border: oklch(0.45 0.1 27);
    --ok: oklch(0.72 0.15 150);
    --danger-text: oklch(0.75 0.13 27);
}

/* Web Awesome follows the same brand. Its components read these semantic brand tokens (not a
   single "primary"), and its theme declares them inside @layer wa-theme, so these unlayered
   values win whatever order the stylesheets load in. */
:root, .wa-light, .wa-dark {
    --wa-color-brand-fill-loud: var(--brand);
    --wa-color-brand-border-loud: var(--brand);
    --wa-color-brand-on-loud: var(--brand-on);
    --wa-color-brand-fill-quiet: color-mix(in oklab, var(--brand) 10%, var(--bg-elev));
    --wa-color-brand-fill-normal: color-mix(in oklab, var(--brand) 18%, var(--bg-elev));
    --wa-color-brand-border-quiet: color-mix(in oklab, var(--brand) 25%, var(--bg-elev));
    --wa-color-brand-border-normal: color-mix(in oklab, var(--brand) 40%, var(--bg-elev));
    --wa-color-brand-on-quiet: var(--brand-text);
    --wa-color-brand-on-normal: var(--brand-text);
    --wa-color-focus: var(--brand);
    --wa-color-surface-raised: var(--bg-elev);
}

/* relayout's largest text, 1.5rem, is too big for a one-row page bar. Here it sets the page titles,
   and the heading of the Dropbox page that says the folder is ready to match them; the rest is body
   size or smaller, the track name on Now playing included (bold). */
:root { --rl-text-xl: 1.25rem; }

/* ── Base ── */
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { font-family: var(--rl-font-sans, system-ui, sans-serif); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
code { font-family: var(--rl-font-mono, ui-monospace, monospace); font-size: 0.9em; }

ms-app { display: block; }

.ms-text-muted { color: var(--text-muted); }

/* ── Shell ──
   The tab bar is a rail beside the content (regular) or a bar below it (compact); the content
   column takes the rest: the top bar, then <main>, which scrolls on its own.
   The page itself never scrolls. In an app added to an iPhone's home screen, the status bar is
   translucent (index.html): the page takes the whole screen, and the shell keeps clear of the bar
   (Notches and home indicators, below). With the opaque bar, iOS laid the page out at the
   screen's full height but showed it below the bar, so after a turn of the phone the whole page,
   tab bar included, slid up by the bar's height. The shell takes the height shown, set by
   fitViewport() (src/pwa/); 100dvh only until the script runs. */
html, body { overflow: hidden; }
.ms-shell { height: var(--ms-app-height, 100dvh); }
.ms-content { min-width: 0; }
.ms-main { overflow-y: auto; overscroll-behavior: contain; }
/* Every page: the full width of the window on a phone, no wider than relayout's xl and centred on a desktop. */
.ms-page { max-width: var(--rl-width-xl); margin-inline: auto; height: 100%; }
/* The stage under the top bar is one grid cell, which the page fills and the player box floats in
   (The player box, below): in the page's cell rather than positioned, so it sits in the stage on a
   phone too, where the stage isn't positioned (Overlays). */
.ms-stage { display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.ms-stage > .ms-main { grid-area: 1 / 1; }

/* ── Top bar ──
   The page's title, 🔍 and ⚙ above every page (music-library.md › The top bar), as wide as
   the page under it; while the search is open, the field and ✕. Its row is as tall as the field,
   so it keeps its height as the search opens and closes. */
ms-top-bar { display: block; flex-shrink: 0; border-bottom: 1px solid var(--border); }
.ms-top-bar { max-width: var(--rl-width-xl); margin-inline: auto; min-height: calc(var(--wa-form-control-height) + 2 * var(--rl-space-s)); }
.ms-top-title { min-width: 0; margin: 0; }
/* The page header renders the title for the top bar, and shows nothing of it itself. */
ms-page-title { display: none; }
.ms-top-search { min-width: 0; }
.ms-top-search[hidden] { display: none; }
.ms-top-search-icon { line-height: 0; font-size: 1.1rem; color: var(--text-subtle); }
.ms-top-bar-btn { flex-shrink: 0; font-size: 1.25rem; }
/* The page's add button, such as + Add station: an outlined pill, so it doesn't compete with what plays. */
.ms-top-add { flex-shrink: 0; white-space: nowrap; }
/* The add button and the search field are slimmer pills than the page's own controls: 36 px tall,
   with less padding. On a touch screen the add button's box keeps the 44 px floor (--ms-touch),
   the rest around the pill, so it's as easy to tap. */
.ms-top-add, .ms-top-search { --wa-form-control-height: 36px; --wa-form-control-padding-inline: 0.75em; }
.ms-top-add { padding-block: max(0px, (var(--ms-touch) - 36px) / 2); }
.ms-settings-btn { position: relative; }

/* ── Overlays ──
   The search results and Settings open over part of the app. On a wide screen the results cover
   the stage under the top bar (.ms-stage), with the page dimmed behind them, and Settings covers
   the content column beside the rail (.ms-content): the top bar and the page. On a phone both run
   to the bottom edge, over the tab bar: the whole shell holds them, and the results start under
   the top bar, whose height the shell keeps in --ms-top-bar-height (app-shell.ts). Covering the
   tab bar rather than hiding it keeps the page's height, so a list scrolled to its end is still
   there when they close. What they cover is inert. Settings is above the results, and the player
   box (z-index 30) and its video (31) above both. */
.ms-stage { position: relative; min-height: 0; }
.ms-content { position: relative; }
ms-app[data-layout='compact'] .ms-shell { position: relative; }
ms-app[data-layout='compact'] .ms-content, ms-app[data-layout='compact'] .ms-stage { position: static; }

ms-search-overlay { display: block; position: absolute; inset: 0; z-index: 20; }
ms-app[data-layout='compact'] ms-search-overlay { top: var(--ms-top-bar-height, 0px); }
.ms-search-overlay { height: 100%; background: rgb(0 0 0 / 0.45); }
.ms-search-panel {
    max-height: 100%; max-width: var(--rl-width-xl); margin-inline: auto;
    background: var(--bg);
    box-shadow: 0 8px 24px rgb(0 0 0 / 0.25);
    overscroll-behavior: contain;
}
ms-app[data-layout='compact'] .ms-search-panel {
    height: 100%; box-shadow: none;
    padding-bottom: calc(var(--rl-space-m) + env(safe-area-inset-bottom, 0px));
}
/* A playlist result's icon takes the same column as the other results' covers, so every name starts at the same place. */
.ms-search-panel .ms-playlist-row .ms-row-lead { width: 3.75rem; }
ms-app[data-layout='compact'] .ms-search-panel .ms-playlist-row .ms-row-lead { width: 40px; display: grid; justify-items: center; }
/* ▶ and › at the end of a result. */
.ms-row-actions { flex-shrink: 0; }
.ms-row-actions .ms-icon-btn { font-size: 1.2rem; }
.ms-row-play { color: var(--brand-text); }
.ms-row-actions .ms-icon-btn:disabled { opacity: 0.35; cursor: default; background: none; }

/* Settings pads into the safe areas the bars it covers padded into (Notches and home indicators, below). */
.ms-settings-overlay {
    position: absolute; inset: 0; z-index: 25;
    background: var(--bg);
    padding-right: env(safe-area-inset-right, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
ms-app[data-layout='compact'] .ms-settings-overlay { padding-left: env(safe-area-inset-left, 0px); }

/* ── Tab bar ── */
ms-tab-bar { display: contents; }
.ms-rail {
    width: 80px;
    flex-shrink: 0;
    background: var(--chrome);
    border-right: 1px solid var(--border);
}
.ms-rail .ms-tab { width: 100%; }
.ms-rail-mark {
    color: var(--logo);
    font-size: 2rem;
    line-height: 0;
    padding: 0.5rem;
    border-radius: 8px;
}
.ms-rail-mark:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.ms-tabbar {
    background: var(--chrome);
    border-top: 1px solid var(--border);
}

.ms-tab {
    color: var(--text-muted);
    padding: 0.5rem 0.25rem;
    transition: color .15s;
}
.ms-tab:hover { color: var(--text); }
.ms-tab:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; border-radius: 8px; }
.ms-tab--selected, .ms-tab--selected:hover { color: var(--brand-text); }
.ms-tab--selected .ms-tab-label { font-weight: 600; }
/* The pill behind the selected tab's icon. */
.ms-tab-icon {
    position: relative;
    font-size: 1.5rem;
    line-height: 0;
    transition: background .15s;
}
.ms-tab--selected .ms-tab-icon { background: color-mix(in oklab, var(--brand) 18%, transparent); }
/* A pulsing dot on the Player tab while a track plays, so playback shows from every tab. */
.ms-tab-live, .ms-settings-badge {
    position: absolute; top: 2px; right: 8px;
    width: 7px; height: 7px;
    border-radius: 50%;
}
.ms-tab-live {
    background: var(--brand-text);
    animation: ms-pulse 1.2s ease-in-out infinite;
}
/* A still dot on ⚙ while a new version of the app is available (Settings › About). */
.ms-settings-badge { top: 6px; right: 6px; background: var(--brand); }
@media (prefers-reduced-motion: reduce) { .ms-tab-live { animation: none; } }

/* padding: 0 matters: Web Awesome's native styles give every <button> 0 16px of padding, which
   left 2px of content in a 34px square and shrank the icon to a dot. */
.ms-icon-btn {
    width: max(34px, var(--ms-touch)); height: max(34px, var(--ms-touch));
    display: grid; place-items: center;
    padding: 0;
    border: none; background: none; cursor: pointer;
    border-radius: 7px; color: var(--text-muted);
    transition: color .15s, background .15s;
}
.ms-icon-btn:hover { color: var(--text); background: var(--bg-sunken); }
.ms-icon-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* A green "connected" dot. */
.ms-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }

/* ── Notices ── */
.ms-notice {
    background: var(--notice-bg);
    border: 1px solid var(--notice-border);
}
.ms-notice--danger {
    background: var(--danger-bg);
    border-color: var(--danger-border);
}

/* ── Settings ── */
.ms-section-title { letter-spacing: 0.06em; }
.ms-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
}

/* ── Page-level spinner (restoring, OAuth callback) ── */
.ms-page-spinner { font-size: 2rem; }

/* ── Pages ──
   Every page fills <main> exactly: the bar at its top (page-header.ts) stays put, and the body
   under it scrolls. */
ms-library-page, ms-radio-source, ms-station-directory, ms-youtube-source, ms-playlists-page, ms-settings-page { display: block; height: 100%; }
ms-dropbox-source { display: block; min-height: 0; }
.ms-library, .ms-playlists, .ms-settings, .ms-radio, .ms-youtube { height: 100%; }
ms-scan-status { display: block; }
ms-scan-status:empty { display: none; }
.ms-library-alert { margin: 0 var(--rl-space-m, 0.5rem) var(--rl-space-m, 0.5rem); }

/* The bar: one row of the same height on every page, whatever is in it. ‹ sits in the page's left
   margin, so the title lines up with the content under it. */
.ms-page-header { flex-shrink: 0; border-bottom: 1px solid var(--border); }
.ms-page-bar { min-height: 44px; }
.ms-page-title { min-width: 0; margin: 0; }
.ms-back-btn { flex-shrink: 0; margin-left: -0.5rem; margin-right: -0.25rem; font-size: 1.5rem; color: var(--brand-text); }
.ms-back-btn:hover { color: var(--brand-text); }

/* Opaque, so that while two lists slide past each other (see Folder navigation) neither shows through the other. */
ms-folder-view, ms-recent-list { display: block; min-height: 0; background: var(--bg); }
.ms-folder-view, .ms-recent-list { height: 100%; }
.ms-recent-list { position: relative; }

/* The list is windowed (folder-view.ts): the spacer is as tall as all the rows, and the window of
   rows that exist is moved to where they belong in it. The row height (--ms-row-h) is set from
   there too, so the CSS and the arithmetic can't disagree. */
.ms-row-scroller { overflow-y: auto; overscroll-behavior: contain; }
.ms-row-spacer { position: relative; }
.ms-row-window { position: absolute; top: 0; left: 0; right: 0; }

.ms-row {
    height: var(--ms-row-h);
    width: 100%;
    box-sizing: border-box;
    border-bottom: 1px solid color-mix(in oklab, var(--border) 45%, transparent);
    cursor: pointer;
}
.ms-row:hover { background: var(--bg-sunken); }
.ms-row--current { background: color-mix(in oklab, var(--brand) 12%, transparent); }
.ms-row--current .ms-row-main { color: var(--brand-text); font-weight: 600; }
.ms-row:has(.ms-row-main:focus-visible) { outline: 2px solid var(--brand); outline-offset: -2px; }

/* The title is the row's keyboard control; a click anywhere on the row does the same (see folder-view.ts). */
/* display and width matter: Web Awesome styles native buttons as centred flex boxes, which centred every title. */
.ms-row-main {
    display: block; width: 100%; min-width: 0; min-height: 0; height: auto;
    padding: 0; border: none; background: none;
    color: inherit; font: inherit; line-height: inherit; text-align: left; text-decoration: none;
    cursor: pointer;
}
.ms-row-main:focus-visible { outline: none; }

.ms-row-lead { width: 3.75rem; flex-shrink: 0; }
.ms-rows--compact .ms-row-lead { width: 1.5rem; }
/* Lists that mix tracks with stations and videos: on a phone the column is as wide as a tile
   (.ms-row-cover, 40px), with ▶ centred in it, so every name in the list starts at the same place. */
.ms-item-list.ms-rows--compact .ms-row-lead, .ms-recent-list.ms-rows--compact .ms-row-lead { width: 40px; display: grid; justify-items: center; }
.ms-row-icon { line-height: 0; flex-shrink: 0; font-size: 1.25rem; }
.ms-row-icon--play { color: var(--text-subtle); }
.ms-row-number { width: 1.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.ms-row-meta { flex-shrink: 0; }
.ms-row-time { width: 3.5rem; flex-shrink: 0; text-align: right; font-variant-numeric: tabular-nums; }
.ms-row-when { width: 6rem; flex-shrink: 0; text-align: right; font-variant-numeric: tabular-nums; }

/* Recent: "Latest" floats over the bottom of the list while it is scrolled up. */
.ms-latest-btn {
    position: absolute; left: 50%; bottom: 0.75rem; transform: translateX(-50%);
    min-height: max(34px, var(--ms-touch)); padding: 0 0.9rem 0 0.7rem;
    border: none; border-radius: 999px; cursor: pointer;
    background: var(--brand); color: var(--brand-on);
    font: inherit; font-weight: 600;
    box-shadow: 0 2px 10px rgb(0 0 0 / 0.25);
}
.ms-latest-btn:hover { filter: brightness(1.08); }
.ms-latest-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.ms-latest-btn svg { font-size: 1.1rem; }
/* ♡ and ⋯ at the end of every item's row (item-actions.ts). */
ms-item-actions { display: block; flex-shrink: 0; }
.ms-item-actions .ms-icon-btn { font-size: 1.2rem; }
.ms-row-heart--on, .ms-row-heart--on:hover { color: var(--brand-text); }
.ms-now-icon { line-height: 0; flex-shrink: 0; }
/* A gentle pulse on the note while the track is actually playing (not paused or loading). */
.ms-now-icon--playing { animation: ms-pulse 1.2s ease-in-out infinite; }
@keyframes ms-pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .ms-now-icon--playing { animation: none; } }

.ms-empty-list { margin: 0; padding-left: 1.25rem; }

/* A heading in a list: the album that the files after it belong to. */
.ms-row--heading { cursor: default; background: var(--bg-sunken); }
.ms-row--heading:hover { background: var(--bg-sunken); }
.ms-row-heading { font-weight: 600; min-width: 0; }

/* ── Cover tile ──
   A placeholder until real art is read: an outlined tile with a note in the accent, on no fill.
   Sized by --cover-size from whatever contains it. */
ms-cover-tile { display: block; flex-shrink: 0; width: var(--cover-size, 44px); height: var(--cover-size, 44px); }
.ms-cover-tile {
    box-sizing: border-box;
    width: 100%; height: 100%;
    border-radius: 10%;
    border: 2px solid color-mix(in oklab, var(--brand) 55%, transparent);
    background: transparent;
    font-size: calc(var(--cover-size, 44px) * 0.45);
    line-height: 0;
    color: var(--brand-text);
}

/* ── Play button ── */
ms-play-button { display: block; flex-shrink: 0; }
.ms-play-btn {
    width: max(40px, var(--ms-touch)); height: max(40px, var(--ms-touch));
    display: grid; place-items: center;
    padding: 0;
    border: none; border-radius: 50%;
    background: var(--brand); color: var(--brand-on);
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform .1s;
}
.ms-play-btn:hover { transform: scale(1.06); }
.ms-play-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.ms-play-btn wa-spinner { font-size: 1.1rem; --track-color: color-mix(in oklab, var(--brand-on) 30%, transparent); --indicator-color: var(--brand-on); }
ms-play-button[large] .ms-play-btn { width: 56px; height: 56px; font-size: 2rem; }
ms-play-button[large] .ms-play-btn wa-spinner { font-size: 1.6rem; }

/* ── The player box (player-box.ts) ──
   What's playing, floating in a corner of the stage on every page but the Player: a strip with the
   title, ↗ and ✕, over a 200 × 200 frame, YouTube's smallest player. It sits at the bottom-right of
   the stage, or at the top-right once dragged there (<ms-app data-box>), and stays inside it as the
   window turns or resizes, since the grid places it. The pages leave no room for it: it floats
   over them, and can be moved off what it covers or closed. */
ms-app { --ms-box-gap: 12px; --ms-box-width: 202px; --ms-box-strip: max(36px, var(--ms-touch)); }
/* A short window, such as a phone on its side, leaves less of a gap, so the box still fits between the bars. */
@media (max-height: 500px) { ms-app { --ms-box-gap: 6px; } }
ms-player-box {
    display: block; position: relative; z-index: 30;
    grid-area: 1 / 1; align-self: end; justify-self: end;
    margin: var(--ms-box-gap);
}
ms-app[data-box='top'] ms-player-box { align-self: start; }
/* 202 px: the 200 px frame and the box's two 1 px borders, which border-box (relayout) counts in the width. */
.ms-box {
    width: var(--ms-box-width);
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 6px 24px rgb(0 0 0 / 0.3);
    overflow: hidden;
}
/* The handle: a touch on it drags the box rather than scrolling the page under it. */
.ms-box-strip {
    height: var(--ms-box-strip); box-sizing: border-box; padding-left: 0.6rem;
    border-bottom: 1px solid var(--border);
    cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
}
.ms-box-strip:active { cursor: grabbing; }
.ms-box-title { min-width: 0; }
.ms-box-btn { flex-shrink: 0; font-size: 1.1rem; border-radius: 0; }
.ms-box-frame { width: 200px; height: 200px; box-sizing: border-box; }
.ms-box-card { --cover-size: 48px; height: 100%; box-sizing: border-box; padding: 0.5rem 0.6rem; }
.ms-box-text { min-width: 0; line-height: 1.35; }
/* The times sit close to the slider: at their full width they would leave it no room. */
.ms-box-seek .ms-player-time { width: auto; font-size: 0.75rem; }
.ms-box-seek .rl-gap-m { gap: 0.4rem; }
.ms-box-skip { font-size: 1.5rem; color: var(--text); }
.ms-box-skip:disabled { opacity: 0.35; cursor: default; }
.ms-box-skip:disabled:hover { background: none; }
/* YouTube's player is placed over this (video-surface.ts), with its corners. */
.ms-box-video { position: relative; height: 100%; background: #000; border-radius: 0 0 11px 11px; }
.ms-box-thumb { width: 100%; height: 100%; object-fit: contain; display: block; }
.ms-box-video-play { position: absolute; inset: 0; }
.ms-box-error { color: var(--danger-text); }

/* ── Now playing (the Player tab) ── */
.ms-now { --cover-size: 120px; }
.ms-now--compact { --cover-size: 72px; }
.ms-now-text { min-width: 0; }
/* On a phone ♡ and ⋯ have left the title's row, so the text would run to the edge: it keeps the
   same space on its right as between it and the cover (rl-gap-l). */
.ms-now--compact .ms-now-text { padding-right: var(--rl-space-l); }
/* A long title wraps, rather than being cut off where it matters most. On a phone it stops at two
   lines, ending in "…": a third line pushed the tabs below it down until the whole Player scrolled. */
.ms-now-title { margin: 0; overflow-wrap: anywhere; line-height: 1.25; }
.ms-now--compact .ms-now-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
/* On a phone the text keeps the same height from track to track, so the seek bar and the buttons
   under it don't move: the title always takes its two lines (2 × 1.25em), and the text the two
   lines under it (artist and album, or a station's status and place) even when one is missing. */
.ms-now--compact .ms-now-title { min-height: 2.5em; }
.ms-now--compact .ms-now-text { min-height: calc(2.5 * var(--rl-text-l) + 2 * 1.5rem + 2 * var(--rl-space-xs)); }
.ms-now-folder {
    align-self: flex-start; max-width: 100%; min-width: 0; min-height: 0; height: auto;
    padding: 0; border: none; background: none;
    color: var(--text-muted); font: inherit; text-align: left;
    cursor: pointer;
}
.ms-now-folder { min-height: var(--ms-touch); }
.ms-now-folder:hover { color: var(--text); }
.ms-now-folder:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.ms-now-folder svg { font-size: 1.1rem; }
.ms-skip-btn { width: 44px; height: 44px; font-size: 1.75rem; color: var(--text); }
.ms-skip-btn:disabled { opacity: 0.35; cursor: default; }
.ms-skip-btn:disabled:hover { background: none; }


/* The Player fills <main>: Now playing keeps the height it needs, and the Sense tabs take the rest
   (at least 18rem, 16rem on a phone so that a two-line title still fits an iPhone SE; on a shorter
   window the body under the bar scrolls instead) and scroll inside it. */
ms-player-page { display: block; height: 100%; }
.ms-player { height: 100%; box-sizing: border-box; }
.ms-player .ms-sense-host { min-height: 18rem; }
.ms-player .ms-sense-host[compact] { min-height: 16rem; }
/* Side by side, on a short, wide window (SIDE_BY_SIDE_QUERY): Now playing keeps a column of its
   own, and what to play from it takes the rest of the width and the whole height. */
.ms-player-now { flex: 0 0 min(22rem, 45%); min-height: 0; }
.ms-player-side .ms-sense-host[compact] { min-height: 0; }
/* With nothing playing, Recent takes the rest of the height and scrolls inside it. */
.ms-player-recent { min-height: 0; }
ms-sense-tabs { display: block; min-height: 0; }
.ms-sense { height: 100%; }
.ms-sense-strip { flex-shrink: 0; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); }
.ms-sense-strip::-webkit-scrollbar { display: none; }
/* Like the other native buttons here, reset what Web Awesome's button styles give them. */
.ms-sense-tab {
    display: block; flex: 0 0 auto; max-width: 14rem; min-width: 0; height: auto; min-height: max(40px, var(--ms-touch));
    padding: 0 0.9rem; margin: 0;
    border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none;
    color: var(--text-muted); font: inherit; cursor: pointer;
}
.ms-sense-tab:hover { color: var(--text); }
.ms-sense-tab--selected { color: var(--brand-text); border-bottom-color: var(--brand); font-weight: 600; }
.ms-sense-tab:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
/* Lists inside the panel scroll themselves; the panel only clips. */
.ms-sense-panel { min-height: 0; overflow: hidden; }
.ms-sense-empty { max-width: 28rem; text-align: center; }
.ms-chips { flex-shrink: 0; }
.ms-chip {
    display: block; max-width: 14rem; min-width: 0; height: auto; min-height: max(32px, var(--ms-touch));
    padding: 0 0.8rem; margin: 0;
    border: 1px solid var(--border); border-radius: 999px; background: none;
    color: var(--text); font: inherit; cursor: pointer;
}
.ms-chip:hover { background: var(--bg-sunken); }
.ms-chip--on { background: color-mix(in oklab, var(--brand) 18%, transparent); border-color: var(--brand); color: var(--brand-text); font-weight: 600; }
.ms-chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.ms-player-time { width: 3.25rem; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.ms-player-time:first-child { text-align: right; }
.ms-progress, .ms-volume { min-width: 0; --thumb-width: 14px; --thumb-height: 14px; --track-size: 4px; }
.ms-volume { width: 6.5rem; }
.ms-player-volume { flex-shrink: 0; }
.ms-player-volume .ms-icon-btn { font-size: 1.25rem; }
/* The sliders are labelled for screen readers; there is no room for visible labels. */
.ms-progress::part(label), .ms-volume::part(label) {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* ── Folder navigation ──
   Diving into a folder slides the list in from the right while the old one drifts left and dims;
   going back does the reverse. app-shell wraps the change in a view transition and sets
   <html data-nav="dive|back"> while it runs. Only the list pane moves: the tab bar and the
   player box are named so they are captured on their own and stay put, and the rest of the
   page (the header's title and back button) cross-fades.

   Opening the Player (data-nav="player") is a different animation: the page cross-fades while the
   player box's cover grows into the Player's (or shrinks back when leaving it).

   The names exist only during a transition, so nothing else is affected by them. */
html[data-nav='dive'] ms-folder-view,
html[data-nav='back'] ms-folder-view { view-transition-name: ms-list; }
html[data-nav] .ms-rail,
html[data-nav] .ms-tabbar { view-transition-name: ms-tabs; }
/* While the Player opens or closes the box comes or goes, so it cross-fades with the page instead. */
html[data-nav='dive'] ms-player-box,
html[data-nav='back'] ms-player-box { view-transition-name: ms-player; }
/* A video in the box is drawn on top, live, rather than in the page's snapshot under the named
   groups, which would cover it for the slide: nothing may cover YouTube's player while it plays. */
html[data-nav='dive'] .ms-video-host:not([hidden]),
html[data-nav='back'] .ms-video-host:not([hidden]) { view-transition-name: ms-video; }
/* One cover on screen at a time (the box's, or the Player's), so the name is never doubled. While
   the search or Settings covers the Player, the box floats above them with a cover of its own, and
   the Player's, under them, doesn't count. */
html[data-nav='player'] .ms-cover:not([inert] *) { view-transition-name: ms-cover; }

/* The page stays live under the animation, so a tap during it reaches the real new list and starts the next navigation. */
::view-transition { pointer-events: none; }

::view-transition-group(root),
::view-transition-group(ms-cover) {
    animation-duration: var(--nav-duration);
    animation-timing-function: var(--nav-ease);
}

/* These four don't move or resize, so the group's own animation has nothing to do, and the list's
   sliding images are clipped to the pane rather than drawn over the rail and header. */
::view-transition-group(ms-list),
::view-transition-group(ms-tabs),
::view-transition-group(ms-player),
::view-transition-group(ms-video) { animation: none; }
::view-transition-group(ms-list) { overflow: clip; }

/* Show only the new tab bar, player box and video: the old ones are identical. */
::view-transition-old(ms-tabs),
::view-transition-old(ms-player),
::view-transition-old(ms-video) { display: none; }
::view-transition-new(ms-tabs),
::view-transition-new(ms-player),
::view-transition-new(ms-video) { animation: none; }

/* Plus-lighter, the default, adds overlapping layers together, which would light up the strip where
   the sliding lists overlap. */
html[data-nav]::view-transition-old(ms-list),
html[data-nav]::view-transition-new(ms-list) {
    mix-blend-mode: normal;
    animation-duration: var(--nav-duration);
    animation-timing-function: var(--nav-ease);
    animation-fill-mode: both;
}
html[data-nav='dive']::view-transition-old(ms-list) { animation-name: ms-nav-recede; }
html[data-nav='dive']::view-transition-new(ms-list) { animation-name: ms-nav-from-right; }
/* Going back, the list you leave slides off the top of the one you return to. */
html[data-nav='back']::view-transition-old(ms-list) { animation-name: ms-nav-to-right; z-index: 1; }
html[data-nav='back']::view-transition-new(ms-list) { animation-name: ms-nav-return; }

@keyframes ms-nav-recede { to { transform: translateX(-30%); opacity: 0.4; } }
@keyframes ms-nav-return { from { transform: translateX(-30%); opacity: 0.4; } }
@keyframes ms-nav-from-right { from { transform: translateX(100%); } }
@keyframes ms-nav-to-right { to { transform: translateX(100%); } }
@keyframes ms-nav-fade-in { from { opacity: 0; } }
@keyframes ms-nav-fade-out { to { opacity: 0; } }

/* No sliding for people who ask for less motion: a quick cross-fade instead. */
@media (prefers-reduced-motion: reduce) {
    ::view-transition-group(root) { animation-duration: 100ms; }
    /* The cover stays where it ends up and fades, rather than travelling. */
    ::view-transition-group(ms-cover) { animation: none; }
    ::view-transition-old(ms-cover),
    ::view-transition-new(ms-cover) { animation-duration: 100ms; }
    html[data-nav]::view-transition-old(ms-list),
    html[data-nav]::view-transition-new(ms-list) {
        mix-blend-mode: plus-lighter;
        animation-duration: 100ms;
        animation-timing-function: linear;
    }
    html[data-nav]::view-transition-old(ms-list) { animation-name: ms-nav-fade-out; }
    html[data-nav]::view-transition-new(ms-list) { animation-name: ms-nav-fade-in; }
}

/* ── Installed app and touch (music-ui.md › PWA and touch) ── */
/* A pull-down at the top of a list must not reload the page in the installed app: that would stop the music. */
html, body { overscroll-behavior: none; }
/* The app doesn't zoom: a pinch threw its layout off. On every element, a touch may pan and scroll
   and nothing else. Every element, because WebKit starts touch-action afresh at each scroll
   container (<main>, the sheets), and iOS blocks a pinch only where a finger lands on a restricted
   element; iOS ignores user-scalable=no. maximum-scale=1 (index.html) does the same on Android,
   and keeps iOS from zooming into a focused text field. Double-tap doesn't zoom either, and taps
   come at once: WebKit gives a page at device width and its first scale no double-tap gesture.
   Web Awesome's sliders keep touch-action: none inside, so dragging them doesn't pan. iOS's own
   Zoom, in its accessibility settings, still works over the whole screen. */
* { touch-action: pan-x pan-y; }
/* No grey flash on tap. */
a, button, [role='tab'], [role='radio'], .ms-row { -webkit-tap-highlight-color: transparent; }

/* Notches and home indicators. The bars pad into the space the system reserves; the page behind
   them keeps its colour. Zero where there is no inset, which is everywhere but a notched phone
   or an iPad. */
.ms-rail { width: calc(80px + env(safe-area-inset-left, 0px)); padding-left: env(safe-area-inset-left, 0px); }
.ms-tabbar { padding-bottom: env(safe-area-inset-bottom, 0px); }
.ms-content { padding-right: env(safe-area-inset-right, 0px); }
ms-app[data-layout='regular'] .ms-content { padding-bottom: env(safe-area-inset-bottom, 0px); }
ms-app[data-layout='compact'] .ms-shell { padding-left: env(safe-area-inset-left, 0px); }
/* The status bar, translucent in the home-screen app, has a white clock, whatever the theme: the
   shell starts below it, behind a black strip, which the overlays in the shell stay under. */
.ms-shell { box-sizing: border-box; border-top: env(safe-area-inset-top, 0px) solid #000; }

/* Fingers need 44 px; a pointer doesn't, so a mouse on a wide window keeps the denser controls.
   --ms-touch is the floor for the size of anything tappable: 44 px on the phone layout and on any
   touch screen (an iPad in the wide layout too), nothing otherwise. The controls above read it. */
ms-app { --ms-touch: 0px; }
ms-app[data-layout='compact'] { --ms-touch: 44px; }
@media (pointer: coarse) { ms-app { --ms-touch: 44px; } }
/* Web Awesome's buttons, fields and radios are 43 px tall; this lifts them to the floor and leaves larger sizes alone. */
ms-app { --wa-form-control-height: max(var(--ms-touch), round(calc(2 * 0.75em + 1em * 1.2), 1px)); }
/* The seek and volume sliders draw a 4 px track. Padding on the slider part makes the strip you can
   press 44 px tall, and the negative margin gives the layout back, so nothing around it moves. */
.ms-progress::part(slider), .ms-volume::part(slider) { padding-block: 20px; margin-block: -16px; }

/* ── Radio, YouTube ──
   These pages scroll inside themselves, under their header, as the Dropbox list does. */
ms-add-station, ms-station-list, ms-more-like-this, ms-item-list, ms-volume-control { display: block; }
ms-volume-control { flex-shrink: 0; }
/* ── Empty lists (empty-state.ts) ──
   A list with nothing in it says so in one short line, centred in the room the list would take. */
.ms-empty-state { display: flex; align-items: center; justify-content: center; margin: 0; padding: var(--rl-space-l); text-align: center; color: var(--text-muted); }
.ms-radio-body > .ms-card, .ms-radio-notice { margin-inline: var(--rl-space-m, 0.5rem); }

/* A row that leads somewhere (a country, a genre, a playlist): the whole row is the button. Web
   Awesome styles native buttons as centred, padded flex boxes, so that is undone here. */
.ms-nav-list { --ms-row-h: max(48px, var(--ms-touch)); }
.ms-nav-row {
    width: 100%; height: var(--ms-row-h); margin: 0; padding-block: 0;
    border: none; border-bottom: 1px solid color-mix(in oklab, var(--border) 45%, transparent); border-radius: 0;
    background: none; color: inherit; font: inherit; text-align: left; justify-content: normal;
}
.ms-playlist-row { --ms-row-h: max(56px, var(--ms-touch)); }
/* How many items a playlist holds, before its chevron: figures of one width, so the counts line up. */
.ms-playlist-count { flex-shrink: 0; font-variant-numeric: tabular-nums; }
.ms-nav-row:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.ms-show-all {
    width: auto; height: auto; min-height: max(36px, var(--ms-touch)); margin: 0; padding-block: 0;
    border: none; background: none; justify-content: flex-start;
    color: var(--brand-text); font: inherit; cursor: pointer;
}
.ms-show-all svg { font-size: 1.1rem; }
.ms-show-all:hover { text-decoration: underline; }

/* The directory's ways in (Countries, Genres, Languages): links in a row that wraps on a narrow phone. */
.ms-directory-ways { flex-wrap: wrap; column-gap: var(--rl-space-l, 1rem); }
.ms-directory-ways .ms-show-all { padding-inline: 0; }
.ms-directory-search { max-width: 36rem; }

/* The radio mark in a station's row. */
.ms-row-cover { --cover-size: 36px; }
.ms-rows--compact .ms-row-cover { --cover-size: 40px; }
.ms-cover-tile .ms-cover-img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.ms-row-cover.ms-now-icon--playing { animation: ms-pulse 1.2s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .ms-row-cover.ms-now-icon--playing { animation: none; } }

/* A row's text gives way to its buttons: without min-width 0 a long name or subtitle would push ♡
   and ⋯ off the edge instead of being cut short with an ellipsis. */
.ms-row .rl-column { min-width: 0; }

/* An item that can't be played right now: shown, greyed, with the reason. */
.ms-row--unavailable { cursor: default; }
.ms-row--unavailable:hover { background: none; }
.ms-row--unavailable .ms-row-main { color: var(--text-subtle); cursor: default; }

/* ♡ and ⋯ beside the title on the Player. */
.ms-now-actions .ms-icon-btn { font-size: 1.4rem; }
/* "Live" beside a station that is playing. */
.ms-live-badge {
    flex-shrink: 0;
    padding: 0 0.4rem;
    border-radius: 4px;
    background: var(--brand);
    color: var(--brand-on);
    letter-spacing: 0.06em;
    line-height: 1.5;
}

/* ── Sheets (sheet-host.ts) ──
   A native modal <dialog>: a panel in the middle of a wide window, a sheet rising from the bottom on
   a phone. The panel's content fills it, so a tap on the backdrop is a tap on the dialog itself. */
.ms-sheet {
    width: min(28rem, calc(100vw - 2rem));
    max-height: min(80dvh, 40rem);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-elev);
    color: var(--text);
    box-shadow: 0 10px 40px rgb(0 0 0 / 0.35);
    overflow: auto;
}
.ms-sheet::backdrop { background: rgb(0 0 0 / 0.45); }
.ms-sheet--bottom {
    width: 100%; max-width: 100%;
    margin: auto 0 0;
    max-height: 85dvh;
    border-width: 1px 0 0;
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.ms-sheet--bottom[open] { animation: ms-sheet-up 200ms var(--nav-ease); }
@keyframes ms-sheet-up { from { transform: translateY(100%); } }
/* Sliding up, a sheet above the box would pass over it: it fades in instead. */
.ms-sheet--lifted[open] { animation-name: ms-sheet-fade; }
@keyframes ms-sheet-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ms-sheet--bottom[open] { animation: none; } }
/* While a video shows, a sheet takes the part of the window the video leaves, set as its inset by
   sheet-host.ts, and nothing is drawn over the video, the dimming included: it has a hole there.
   The panel is centred in that part, inside the same 1rem margins as in the whole window. The
   sheet sits at the bottom of it, across it, and no higher than 1rem under the status bar. Above
   the box it no longer meets the window's bottom, so it is rounded all round. It casts no shadow,
   which would fall on the box beside it, and on a phone on its side on the video. */
.ms-sheet--clear { inset: var(--ms-sheet-top) var(--ms-sheet-right) var(--ms-sheet-bottom) var(--ms-sheet-left); box-shadow: none; }
.ms-sheet--clear::backdrop { clip-path: var(--ms-sheet-dimming); }
.ms-sheet--clear:not(.ms-sheet--bottom) {
    width: min(28rem, calc(100% - var(--ms-sheet-left) - var(--ms-sheet-right) - 2rem));
    max-height: min(80dvh, 40rem, calc(100% - var(--ms-sheet-top) - var(--ms-sheet-bottom) - 2rem));
}
.ms-sheet--clear.ms-sheet--bottom {
    width: calc(100% - var(--ms-sheet-left) - var(--ms-sheet-right));
    max-height: min(85dvh, calc(100% - max(var(--ms-sheet-top), env(safe-area-inset-top, 0px) + 1rem) - var(--ms-sheet-bottom)));
}
.ms-sheet--lifted { border-width: 1px 0; border-radius: 16px; padding-bottom: 0; }
/* Web Awesome styles <dialog> as a flex row, which would shrink the content to fit; it takes the full width. */
.ms-sheet-body { flex: 1 1 auto; width: 100%; min-width: 0; padding: 1rem 1rem 1.25rem; }
.ms-sheet-head { min-width: 0; }
.ms-sheet-actions { justify-content: flex-end; }

.ms-menu-item {
    width: 100%; height: auto; min-height: max(44px, var(--ms-touch));
    margin: 0; padding: 0 0.5rem;
    border: none; border-radius: 8px; background: none;
    color: var(--text); font: inherit; text-align: left; justify-content: normal; cursor: pointer;
}
.ms-menu-item:hover { background: var(--bg-sunken); }
.ms-menu-item:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.ms-menu-item--danger { color: var(--danger-text); }
.ms-menu-icon { line-height: 0; font-size: 1.2rem; flex-shrink: 0; color: var(--text-muted); }
.ms-menu-item--danger .ms-menu-icon { color: inherit; }

.ms-check-row { min-height: max(44px, var(--ms-touch)); padding: 0 0.5rem; border-radius: 8px; cursor: pointer; }
.ms-check-row:hover { background: var(--bg-sunken); }
.ms-check-row input { width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--brand); flex-shrink: 0; }
.ms-coming { margin: 0; padding: 0 0.5rem; list-style: none; }


/* The picker's rows span the sheet, so each count sits at the far right. */
.ms-check-list, .ms-check-row { width: 100%; }
/* Lists of links (playlists, countries) need no room for a track number before the icon. */
.ms-nav-list .ms-row-lead { width: auto; }

/* ── YouTube video ──
   The video's <iframe> can't move once it plays (moving it reloads it), so it lives in one host on
   the body, placed by video-surface.ts over what shows the video: the Player page's stage, or the
   player box's frame. It takes their size, at least 200 px (YouTube's terms don't allow a smaller
   or hidden player), and their rounded corners, and sits just above the box. */
.ms-video-host {
    position: fixed; z-index: 31;
    background: #000;
    overflow: hidden;
}
.ms-video-host[hidden] { display: none; }
.ms-video-frame, .ms-video-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

/* The place on the Player page the video appears over. At most 400 px wide (225 px tall), so the
   tabs under it barely move when a file or a station takes its place. */
.ms-video-stage {
    width: 100%; max-width: 400px;
    aspect-ratio: 16 / 9; min-height: 200px;
    background: #000;
    border-radius: 12px;
}
/* The title row under the video ends where the video does. */
.ms-now-video { align-items: stretch; max-width: 400px; }
.ms-add-video-found { --cover-size: 72px; }
.ms-add-video-cover { border-radius: 8px; overflow: hidden; }

/* The seek bar is a block that fills what it is in, as the row it replaced did. */
ms-seek-bar { display: block; min-width: 0; }
ms-seek-bar > .rl-row { width: 100%; }
