/* Rink Soundboard: dark slate theme. No Bootstrap, no light backgrounds. */
:root {
    --bg: #1E222A;
    --card: #282D37;
    --text: #E2E8F0;
    --muted: #94A3B8;
    --border: #3A4150;
    --stop: #DC2626;
    --play: #CBD5E1;
    /* Fixed header height on / (see .home-header). The expanded video sits directly under it. */
    --header-h: 132px;
    /* Step 6: notch / home-bar insets (viewport-fit=cover). 0px on devices without them. */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--text);
}

h1:focus {
    outline: none;
}

.app-shell {
    /* Where an expanded video starts (e.g. "Show video" on /audiotest): below the notch / status bar.
       / overrides it to sit under its header as well. */
    --video-top: var(--safe-top);
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
}

#blazor-error-ui {
    color-scheme: dark only;
    background: #7F1D1D;
    color: #FEE2E2;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.4);
    display: none;
    left: 0;
    padding: 0.6rem calc(1.25rem + var(--safe-right)) calc(0.7rem + var(--safe-bottom)) calc(1.25rem + var(--safe-left));
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: #B32121;
    padding: 1rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred.";
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: var(--card);
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: var(--text);
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    color: var(--muted);
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

.storage-error {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 900;
    padding: calc(0.6rem + var(--safe-top)) calc(1rem + var(--safe-right)) 0.6rem calc(1rem + var(--safe-left));
    background: #7F1D1D;
    color: #FEE2E2;
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

    .storage-error span {
        flex: 1 1 auto;
    }

.storage-error-close {
    flex: 0 0 44px;
    height: 44px;
    margin: -0.5rem -0.5rem -0.5rem 0;
    background: transparent;
    border: 0;
    color: #FEE2E2;
    font-size: 1.1rem;
    cursor: pointer;
}

/* ---------- Persistent YouTube player (MainLayout, Step 2) ----------
   Collapsed hides it WITHOUT display:none (the iframe must stay alive to keep playing).
   The host keeps a real 16:9 size even when collapsed, so YouTube never sees a 0×0 player. */
.yt-wrap {
    position: fixed;
    z-index: 50;
    left: 50%;
    transform: translateX(-50%);
    width: min(100vw, calc(200px * 16 / 9));
    background: #000;
}

    .yt-wrap.collapsed {
        top: 0;
        height: 0;
        overflow: hidden;
        opacity: 0;
        pointer-events: none;
    }

    .yt-wrap.expanded {
        top: var(--video-top, 0px);
        aspect-ratio: 16 / 9;
        max-height: 200px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
    }

#yt-player-host {
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 200px;
}

    #yt-player-host iframe {
        display: block;
        width: 100%;
        height: 100%;
        border: 0;
    }

/* ---------- /audiotest diagnostics page (plain, may scroll) ---------- */
.audiotest {
    max-width: 720px;
    margin: 0 auto;
    padding: calc(1rem + var(--safe-top)) calc(1rem + var(--safe-right)) calc(3rem + var(--safe-bottom)) calc(1rem + var(--safe-left));
}

    .audiotest h1 {
        margin: 0 0 0.25rem;
        font-size: 1.4rem;
    }

    .audiotest h2 {
        margin: 0 0 0.5rem;
        font-size: 1.05rem;
    }

    .audiotest section {
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: 10px;
        padding: 0.75rem;
        margin-top: 0.75rem;
    }

    .audiotest label {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        margin-bottom: 0.5rem;
        font-size: 0.9rem;
        color: var(--muted);
    }

    .audiotest input[type=text], .audiotest input[type=number] {
        background: var(--bg);
        color: var(--text);
        border: 1px solid var(--border);
        border-radius: 6px;
        padding: 0.5rem;
        font-size: 1rem;
    }

    .audiotest input[type=file] {
        color: var(--text);
    }

    .audiotest .row {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

        .audiotest .row.wrap {
            flex-wrap: wrap;
        }

    .audiotest button {
        min-height: 44px;
        padding: 0.4rem 0.8rem;
        background: #3A4150;
        color: var(--text);
        border: 1px solid #4A5568;
        border-radius: 8px;
        font-size: 0.95rem;
        cursor: pointer;
    }

        .audiotest button:disabled {
            opacity: 0.5;
            cursor: default;
        }

        .audiotest button.stop {
            background: var(--stop);
            border-color: var(--stop);
            font-weight: 700;
        }

        .audiotest button.small {
            min-height: 0;
            padding: 0.15rem 0.5rem;
            font-size: 0.8rem;
        }

    .audiotest .muted {
        color: var(--muted);
        font-size: 0.85rem;
    }

    .audiotest .readout {
        display: grid;
        grid-template-columns: max-content 1fr;
        gap: 0.2rem 0.75rem;
        margin: 0;
        font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
        font-size: 0.85rem;
    }

        .audiotest .readout dt {
            color: var(--muted);
        }

        .audiotest .readout dd {
            margin: 0;
            word-break: break-word;
        }

    .audiotest .log {
        margin: 0.5rem 0 0;
        padding-left: 2.2rem;
        font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
        font-size: 0.78rem;
        white-space: pre-wrap;
        word-break: break-word;
    }

/* ---------- Main soundboard (/, Pages/Home.razor, Step 3) ----------
   One screen, 100dvh, no page or inner scrolling. Header has a fixed height; the grid takes the rest. */
.app-shell:has(.home) {
    /* MainLayout's persistent YouTube wrap reads this: expanded video opens directly under the header, as an overlay. */
    --video-top: calc(var(--header-h) + var(--safe-top));
}

.home {
    position: relative;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    /* Safe-area padding: header and grid stay clear of the notch and home bar; the drawer overlay still covers it. */
    padding: var(--safe-padding);
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.home button {
    font-family: inherit;
    color: var(--text);
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.home-header {
    flex: 0 0 var(--header-h);
    height: var(--header-h);
    display: flex;
    align-items: stretch;
    gap: 8px;
    padding: 8px 10px;
}

.menu-button {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.now-playing {
    position: relative;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 2px;
    padding: 5px 10px 6px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.np-top {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    height: 20px;
    padding-right: 30px; /* room for the video toggle in the corner */
}

.np-label {
    flex: none;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.np-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-weight: 800;
    font-size: 0.92rem;
}

.np-badge {
    flex: none;
    padding: 0 4px;
    border: 1px solid var(--muted);
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--muted);
}

.video-toggle {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 30px;
    height: 26px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--muted) !important;
    cursor: pointer;
}

.np-timeline {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 20px;
}

.np-time {
    flex: none;
    min-width: 2.6em;
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

    .np-time:last-child {
        text-align: right;
    }

.np-scrubber {
    flex: 1;
    min-width: 0;
    height: 20px;
    margin: 0;
    accent-color: var(--play);
    background: transparent;
}

    .np-scrubber:disabled {
        opacity: 0.4;
    }

.np-controls {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    height: 54px;
}

.ctl {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    line-height: 1;
}

.ctl-small {
    width: 44px;
    height: 44px;
    background: #3A4150;
    border: 1px solid #4A5568;
    font-size: 1.1rem;
}

.ctl-play, .ctl-stop {
    width: 54px;
    height: 54px;
    flex: 0 0 54px;
}

.ctl-play {
    flex: 0 0 54px;
}

.ctl-play {
    background: var(--play);
    border: 0;
}

/* Stop starts where it always was and stretches to the right edge of the card: the biggest target on the screen. */
.ctl-stop {
    position: relative;
    flex: 1 1 auto;
    width: auto;
    min-width: 54px;
    gap: 8px;
    background: var(--stop);
    border: 0;
    border-radius: 27px;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.35);
}

    .ctl-stop .icon-stop {
        margin-top: 0;
    }

    .ctl-stop .stop-label {
        position: static;
        font-size: 0.8rem;
    }

.icon-play {
    width: 0;
    height: 0;
    margin-left: 4px;
    border-style: solid;
    border-width: 11px 0 11px 18px;
    border-color: transparent transparent transparent #1E222A;
}

.icon-pause {
    width: 14px;
    height: 16px;
    border-left: 5px solid var(--text);
    border-right: 5px solid var(--text);
}

.icon-stop {
    width: 18px;
    height: 18px;
    margin-top: -6px;
    background: #FFFFFF;
    border-radius: 2px;
}

.stop-label {
    position: absolute;
    bottom: 7px;
    left: 0;
    right: 0;
    font-size: 0.58rem;
    font-weight: 800;
    color: #FFFFFF;
    text-align: center;
}

/* ---------- Button grid: fills the rest of the screen, every row the same height ---------- */
.sound-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(var(--rows, 4), minmax(0, 1fr));
    grid-auto-rows: 1fr;
    gap: 10px;
    padding: 0 10px 10px;
    overflow: hidden;
}

@media (min-width: 900px) {
    .sound-grid {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: none;
        grid-auto-rows: minmax(0, 1fr);
    }
}

@media (min-width: 1200px) {
    .sound-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.grid-message {
    grid-column: 1 / -1;
    margin: 0;
    padding: 0.75rem;
    background: #7F1D1D;
    color: #FEE2E2;
    border-radius: 10px;
    font-size: 0.9rem;
}

.sound-tile {
    position: relative;
    min-width: 0;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 8px;
    overflow: hidden;
    background: var(--tile, #4A5568);
    border: 0;
    border-radius: 14px;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25);
    cursor: pointer;
    transition: transform 0.06s ease-out, filter 0.06s;
}

    .sound-tile:active {
        transform: scale(0.97);
        filter: brightness(1.15);
    }

    .sound-tile.active {
        box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px rgba(226, 232, 240, 0.55);
    }

    .sound-tile.active.playing {
        box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px #E2E8F0;
    }

.tile-name {
    max-width: 100%;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: clamp(0.85rem, 4.6vw, 1.5rem);
    line-height: 1.1;
    text-align: center;
    overflow-wrap: anywhere;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.tile-count {
    font-size: 0.72rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.85);
    font-variant-numeric: tabular-nums;
}

/* ---------- Special sub-menu (replaces the grid while open; same space, never scrolls) ---------- */
.sound-grid.hidden-behind {
    display: none;
}

.special-panel {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 10px 10px;
    overflow: hidden;
}

.special-head {
    flex: 0 0 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.special-title {
    font-weight: 900;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.special-back {
    min-width: 88px;
    height: 44px;
    padding: 0 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
}

.special-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
    grid-template-rows: repeat(var(--rows, 1), minmax(44px, 1fr));
    gap: 8px;
    align-content: start;
}

    .special-grid .grid-message {
        grid-row: 1;
    }

.special-tile .tile-name {
    font-size: clamp(0.8rem, 3.8vw, 1.15rem);
    text-transform: none;
}

.special-tile.missing {
    opacity: 0.55;
}

/* ---------- Hamburger drawer: off-screen with transform; .home's overflow:hidden clips it ---------- */
.drawer-backdrop {
    position: absolute;
    inset: 0;
    z-index: 70;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.drawer {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 71;
    width: min(300px, 82vw);
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: calc(10px + var(--safe-top)) 10px calc(10px + var(--safe-bottom)) calc(10px + var(--safe-left));
    background: var(--card);
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform 0.22s ease-out, visibility 0s linear 0.22s;
}

.home.drawer-open .drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
}

.home.drawer-open .drawer {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.22s ease-out, visibility 0s;
}

.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.drawer-title {
    font-weight: 800;
    font-size: 1.05rem;
}

.drawer-close {
    width: 44px;
    height: 44px;
    background: transparent;
    border: 0;
    font-size: 1.1rem;
    cursor: pointer;
}

.drawer-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 48px;
    padding: 0 12px;
    background: #323844;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 0.98rem;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

    .drawer-item.disabled {
        opacity: 0.6;
        cursor: default;
    }

.drawer-note {
    display: block;
    font-size: 0.72rem;
    color: var(--muted);
}

.drawer-section {
    margin: 10px 2px 2px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.file-item input[type=file] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.switch {
    position: relative;
    flex: none;
    width: 50px;
    height: 30px;
    padding: 0;
    background: #4A5568;
    border: 0;
    border-radius: 15px;
    cursor: pointer;
    transition: background 0.15s;
}

    .switch span {
        position: absolute;
        top: 3px;
        left: 3px;
        width: 24px;
        height: 24px;
        background: var(--text);
        border-radius: 50%;
        transition: transform 0.15s;
    }

    .switch.on {
        background: #2F855A;
    }

        .switch.on span {
            transform: translateX(20px);
        }

    .switch:disabled {
        opacity: 0.5;
        cursor: default;
    }

/* ---------- Restore dialog ---------- */
.dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
    background: rgba(0, 0, 0, 0.65);
}

.dialog {
    width: min(420px, 100%);
    padding: 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

    .dialog h2 {
        margin: 0 0 8px;
        font-size: 1.1rem;
    }

    .dialog p {
        margin: 0 0 8px;
        line-height: 1.4;
    }

.dialog-detail {
    color: var(--muted);
    font-size: 0.88rem;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.dlg-btn {
    min-width: 88px;
    min-height: 44px;
    padding: 0 14px;
    background: #3A4150;
    border: 1px solid #4A5568;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
}

    .dlg-btn.danger {
        background: var(--stop);
        border-color: var(--stop);
    }

    .dlg-btn:disabled {
        opacity: 0.6;
    }

/* ---------- Toasts: fixed overlay, never affects layout ---------- */
.toasts {
    position: fixed;
    left: 50%;
    bottom: calc(16px + var(--safe-bottom));
    z-index: 95;
    width: min(360px, calc(100vw - 24px));
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
}

.toast {
    padding: 10px 14px;
    background: #0F1217;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
    color: var(--text);
    font-size: 0.9rem;
    text-align: center;
    animation: toast-in 0.15s ease-out;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

/* ---------- Simple centered message page (NotFound) ---------- */
.center-message {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-align: center;
    padding: calc(1rem + var(--safe-top)) calc(1rem + var(--safe-right)) calc(1rem + var(--safe-bottom)) calc(1rem + var(--safe-left));
}

    .center-message h1 {
        margin: 0;
        font-size: 1.6rem;
        font-weight: 800;
    }

    .center-message p {
        margin: 0;
        color: var(--muted);
    }

/* The manager pages have no video toggle, so an expanded video (opened on /) is shown collapsed there instead of
   covering the header. Same presentation as .yt-wrap.collapsed: the player stays alive and keeps playing. */
.app-shell:has(.manage) .yt-wrap.expanded {
    top: 0;
    height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    box-shadow: none;
}

/* ---------- Buttons & Order manager (/buttons, Pages/Buttons.razor, Step 4) ----------
   One screen at 390x844 for up to 12 buttons: rows shrink from 60px toward the 44px touch minimum.
   Only with more buttons than fit does the list itself scroll. No drag handles anywhere. */
.manage {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    padding: var(--safe-padding);
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.manage button {
    font-family: inherit;
    color: var(--text);
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.manage-header {
    position: relative;
    flex: 0 0 56px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}

.hdr-btn {
    min-width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    background: #3A4150;
    border: 1px solid #4A5568;
    border-radius: 10px;
    color: var(--text);
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

    .hdr-btn:disabled {
        opacity: 0.5;
    }

.hdr-back {
    padding: 0;
    font-size: 1.3rem;
}

.manage-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saved-flash {
    color: #86EFAC;
    font-size: 0.85rem;
    font-weight: 700;
    opacity: 0;
    transition: opacity 0.4s ease-out;
}

    .saved-flash.show {
        opacity: 1;
        transition: none;
    }

.manage-message {
    margin: 8px;
    color: #FCA5A5;
}

.button-list {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 8px;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

/* Short phones (e.g. 360x640): tighter spacing so 12 rows still fit at the 44px minimum without scrolling. */
@media (max-height: 700px) {
    .button-list {
        padding: 6px;
        gap: 3px;
    }
}

.button-row {
    flex: 0 1 60px;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 4px 0 10px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.row-swatch {
    flex: 0 0 18px;
    height: 18px;
    border-radius: 5px;
    background: var(--swatch);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.row-name {
    flex: 0 1 auto;
    min-width: 0;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.row-count {
    flex: 1 0 auto;
    color: var(--muted);
    font-size: 0.85rem;
}

.row-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 2px;
}

.row-btn {
    width: 44px;
    height: 40px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 1.05rem;
    cursor: pointer;
}

    .row-btn:active:not(:disabled) {
        background: #3A4150;
    }

    .row-btn:disabled {
        opacity: 0.25;
        cursor: default;
    }

.row-delete {
    color: #FCA5A5;
}

/* Add / Edit dialog */
.edit-dialog {
    display: flex;
    flex-direction: column;
}

.field-label {
    margin: 4px 0 6px;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
}

.text-input {
    height: 44px;
    padding: 0 12px;
    background: var(--bg);
    border: 1px solid #4A5568;
    border-radius: 10px;
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
}

    .text-input:focus {
        outline: 2px solid #94A3B8;
        outline-offset: 1px;
    }

.field-hint {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    min-height: 1.2em;
    margin: 4px 0 8px;
    color: var(--muted);
    font-size: 0.8rem;
}

.field-error {
    color: #FCA5A5;
}

.palette {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.swatch-btn {
    height: 44px;
    background: var(--swatch);
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
}

    .swatch-btn.selected {
        border-color: var(--text);
        box-shadow: 0 0 0 2px var(--bg) inset;
    }

.custom-color {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    color: var(--muted);
    font-size: 0.9rem;
}

    .custom-color input[type=color] {
        width: 52px;
        height: 36px;
        padding: 0;
        background: transparent;
        border: 1px solid #4A5568;
        border-radius: 8px;
    }

.edit-preview {
    margin-top: 12px;
    padding: 12px;
    background: var(--tile);
    border-radius: 12px;
    font-weight: 800;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.dlg-btn.primary {
    background: #475569;
    border-color: #64748B;
}

/* ---------- Song manager (/songs, Pages/Songs.razor, Step 5) ----------
   Same .manage shell as /buttons. Pills scroll sideways; the track list scrolls (this page may scroll). */
/* /songs filter: one dropdown (All by default) plus the playlist import button. */
.filter-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

.filter-label {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
}

.filter-select {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    padding: 0 32px 0 12px;
    background-color: var(--card);
    background-image: linear-gradient(45deg, transparent 50%, var(--text) 50%), linear-gradient(135deg, var(--text) 50%, transparent 50%);
    background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    color-scheme: dark;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.import-option {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    font-size: 0.9rem;
    cursor: pointer;
}

.import-option input {
    width: 22px;
    height: 22px;
    flex: none;
    accent-color: #B7791F;
}

.import-unplayable-note {
    margin: 10px 0 0;
    font-size: 0.85rem;
}

.import-list.import-unplayable {
    max-height: 18dvh;
}

.import-list {
    max-height: 30dvh;
    margin: 4px 0 0;
    padding: 6px 6px 6px 28px;
    overflow-y: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.85rem;
    line-height: 1.5;
}

.filter-import {
    flex: 0 0 auto;
    white-space: nowrap;
}

.missing-summary {
    flex: 0 0 auto;
    margin: 8px 8px 0;
    padding: 8px 10px;
    background: rgba(217, 119, 6, 0.15);
    border: 1px solid rgba(217, 119, 6, 0.55);
    border-radius: 10px;
    color: #FCD34D;
    font-size: 0.9rem;
    font-weight: 700;
}

.track-list {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 8px;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.track-empty {
    padding: 24px 8px;
    color: var(--muted);
    text-align: center;
}

.track-row {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 4px 8px 10px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
}

    .track-row.playing {
        border-color: #86EFAC;
    }

    .track-row.missing {
        border-color: rgba(217, 119, 6, 0.6);
    }

.track-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.track-title {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
    font-size: 0.75rem;
}

.badge {
    display: inline-block;
    max-width: 100%;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge-button {
    background: var(--swatch);
    color: #FFFFFF;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}

.badge-youtube {
    background: rgba(220, 38, 38, 0.18);
    border: 1px solid rgba(220, 38, 38, 0.6);
    color: #FCA5A5;
}

.badge-local {
    background: rgba(16, 185, 129, 0.16);
    border: 1px solid rgba(16, 185, 129, 0.6);
    color: #6EE7B7;
}

.badge-missing {
    align-self: flex-start;
    background: rgba(217, 119, 6, 0.18);
    border: 1px solid rgba(217, 119, 6, 0.7);
    color: #FCD34D;
    white-space: normal;
}

.track-start {
    color: var(--muted);
}

.track-actions {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 2px;
    max-width: 50%;
}

.row-btn.row-text {
    width: auto;
    min-width: 44px;
    padding: 0 8px;
    background: #3A4150;
    border-color: #4A5568;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
}

    .row-btn.row-text.stop {
        background: var(--stop);
        border-color: var(--stop);
    }

    .row-btn.row-text.reattach {
        background: rgba(217, 119, 6, 0.25);
        border-color: rgba(217, 119, 6, 0.7);
        color: #FCD34D;
    }

.songs-footer {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 12px; /* .manage already pads the home-bar inset */
    background: var(--card);
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.8rem;
}

.unused-audio {
    color: var(--text);
}

.link-btn {
    min-height: 32px;
    padding: 0 6px;
    background: transparent;
    border: none;
    color: #FCA5A5;
    font-size: 0.85rem;
    font-weight: 800;
    text-decoration: underline;
    cursor: pointer;
}

/* Add / Edit song dialog: may be taller than a phone in landscape, so it scrolls inside the backdrop. */
.song-dialog {
    max-height: calc(100dvh - 32px - var(--safe-top) - var(--safe-bottom));
    overflow-y: auto;
}

/* The Button picker is a real <select>; the ▾ makes that obvious (the native arrow is easy to miss on dark). */
.dialog select.text-input {
    padding-right: 36px;
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text) 50%), linear-gradient(135deg, var(--text) 50%, transparent 50%);
    background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
    background-size: 6px 6px;
    background-repeat: no-repeat;
    color-scheme: dark;
    cursor: pointer;
}

.source-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 4px;
}

.source-tab {
    min-height: 44px;
    padding: 0 8px;
    background: var(--bg);
    border: 1px solid #4A5568;
    border-radius: 10px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
}

    .source-tab.selected {
        background: #475569;
        border-color: #94A3B8;
    }

    .source-tab:disabled:not(.selected) {
        opacity: 0.35;
    }

.file-pick {
    position: relative;
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: var(--bg);
    border: 1px dashed #64748B;
    border-radius: 10px;
    color: var(--text);
    font-size: 0.9rem;
    overflow: hidden;
    cursor: pointer;
}

    .file-pick span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .file-pick input[type=file] {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        opacity: 0;
        cursor: pointer;
    }

.start-input {
    max-width: 140px;
}

/* Song row button dropdown: looks like the button badge, with a ▾ hint; native picker for the options. */
.row-button-select {
    max-width: 150px;
    min-height: 28px;
    padding: 2px 20px 2px 8px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    font-family: inherit;
    font-size: 0.75rem;
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #FFFFFF 50%), linear-gradient(135deg, #FFFFFF 50%, transparent 50%);
    background-position: calc(100% - 11px) 55%, calc(100% - 7px) 55%;
    background-size: 4px 4px;
    background-repeat: no-repeat;
    background-color: var(--swatch);
    color-scheme: dark;
    cursor: pointer;
}

    .row-button-select option,
    .row-button-select optgroup {
        background: var(--card);
        color: var(--text);
        text-shadow: none;
    }
