/* ============================================================================
   GLOBAL SIDEBAR — "Quiet dock"

   This lives in a global stylesheet rather than GlobalSidebar.razor.css on
   purpose: Blazor scoped CSS rewrites every selector to `.foo[b-hash]`, and
   the scope attribute is only stamped onto elements the component renders
   itself. MudNavLink / MudMenu render their own DOM, so scoped rules targeting
   .mud-nav-link never match. Everything here is namespaced under
   .modern-sidebar instead, which gives the same containment without the trap.

   Colours come from the semantic --theme-* layer in neuro-theme.css, so the
   sidebar follows the active character *and* the active Darkness/Light mode
   with no per-theme branching below.
   ============================================================================ */

.modern-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    z-index: 100;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

    .modern-sidebar.expanded {
        width: 320px;
    }

    .modern-sidebar.collapsed {
        width: 72px;
    }

.modern-sidebar .sidebar-wrapper {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background: var(--theme-bg-surface);
    border-right: 1px solid var(--theme-border);
}

/* Reset the buttons used as nav affordances. */
.modern-sidebar button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    margin: 0;
    cursor: pointer;
}

/* ============================================================================
   BRAND HEADER
   ============================================================================ */

.modern-sidebar .sidebar-brand {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 18px 16px 14px;
}

    .modern-sidebar .sidebar-brand.rail {
        justify-content: center;
        padding: 18px 0 14px;
    }

    .modern-sidebar .brand-identity {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 10px;
        min-width: 0;
        padding: 0;
        text-align: left;
        flex: 1;
    }

.modern-sidebar .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 1px var(--theme-border);
    background: var(--theme-bg-raised);
    padding: 0;
}

    .modern-sidebar .brand-mark img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

.modern-sidebar .rail-mark {
    width: 34px;
    height: 34px;
}

.modern-sidebar .brand-copy {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.modern-sidebar .brand-text {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--theme-fg-primary);
}

.modern-sidebar .brand-mode {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--theme-primary);
}

/* Small square icon buttons used in the header and rail. */
.modern-sidebar .icon-tile {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    padding: 0;
    background: var(--theme-bg-raised);
    color: var(--theme-fg-muted);
    transition: color 0.2s ease, background 0.2s ease;
}

    .modern-sidebar .icon-tile:hover {
        color: var(--theme-primary);
        background: var(--theme-tint);
    }

    .modern-sidebar .icon-tile .mud-icon-root {
        font-size: 18px;
    }

/* ============================================================================
   NAVIGATION
   ============================================================================ */

.modern-sidebar .sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 8px 8px;
    scrollbar-width: thin;
}

    .modern-sidebar .sidebar-nav::-webkit-scrollbar {
        width: 6px;
    }

    .modern-sidebar .sidebar-nav::-webkit-scrollbar-track {
        background: transparent;
    }

    .modern-sidebar .sidebar-nav::-webkit-scrollbar-thumb {
        background: rgba(var(--ink-rgb), 0.18);
        border-radius: 3px;
    }

.modern-sidebar .nav-group {
    margin-bottom: 6px;
}

.modern-sidebar .nav-group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 8px 8px 6px;
    user-select: none;
}

.modern-sidebar .nav-group-title {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.3px;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--theme-fg-muted);
    transition: color 0.2s ease;
}

.modern-sidebar .nav-group-header:hover .nav-group-title {
    color: var(--theme-primary);
}

.modern-sidebar .nav-group-rule {
    flex: 1;
    height: 1px;
    background: var(--theme-border);
}

.modern-sidebar .nav-group-chevron {
    font-size: 16px !important;
    flex-shrink: 0;
    color: var(--theme-fg-muted);
    transition: transform 0.2s ease;
}

    .modern-sidebar .nav-group-chevron.collapsed {
        transform: rotate(-90deg);
    }

/* ---- Nav rows (MudNavLink) ---- */

.modern-sidebar .mud-navmenu {
    padding: 0;
}

.modern-sidebar .mud-nav-link {
    display: flex !important;
    align-items: center;
    gap: 12px;
    height: 38px;
    min-height: 38px;
    padding: 0 10px !important;
    margin: 0 0 2px !important;
    border-radius: 9px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    text-decoration: none;
    cursor: pointer;
    color: var(--theme-fg-secondary) !important;
    background: transparent;
    transition: background 0.15s ease, color 0.15s ease;
}

    .modern-sidebar .mud-nav-link .mud-icon-root {
        font-size: 20px !important;
        flex-shrink: 0;
        color: inherit !important;
    }

    .modern-sidebar .mud-nav-link .mud-nav-link-icon {
        color: inherit !important;
        min-width: 0;
        margin: 0;
    }

    .modern-sidebar .mud-nav-link .mud-nav-link-text {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .modern-sidebar .mud-nav-link:hover {
        background: var(--theme-tint-soft) !important;
        color: var(--theme-primary) !important;
    }

    .modern-sidebar .mud-nav-link.active {
        background: var(--theme-tint) !important;
        color: var(--theme-primary) !important;
        font-weight: 600 !important;
    }

/* "Your Playlists" row carries an inline add button. */
.modern-sidebar .nav-link-with-action {
    display: flex;
    align-items: center;
    gap: 4px;
}

    .modern-sidebar .nav-link-with-action .mud-nav-link {
        flex: 1;
        min-width: 0;
    }

.modern-sidebar .add-playlist-btn {
    flex-shrink: 0;
    color: var(--theme-fg-muted) !important;
    transition: color 0.2s ease, transform 0.2s ease;
}

    .modern-sidebar .add-playlist-btn:hover {
        color: var(--theme-primary) !important;
        transform: scale(1.1);
    }

.modern-sidebar .nav-subhead {
    margin: 10px 0 6px 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--theme-fg-muted);
}

/* ---- Recent playlist cards ---- */

.modern-sidebar .playlist-item-card {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 6px 8px;
    margin-bottom: 4px;
    border-radius: 10px;
    text-align: left;
    transition: background 0.2s ease, transform 0.2s ease;
}

    .modern-sidebar .playlist-item-card:hover {
        background: var(--theme-tint-soft);
        transform: translateX(2px);
    }

.modern-sidebar .playlist-cover {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--theme-bg-raised);
}

.modern-sidebar .playlist-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modern-sidebar .playlist-cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--theme-tint);
    color: var(--theme-fg-muted);
}

.modern-sidebar .playlist-info-nav {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.modern-sidebar .playlist-name {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
    color: var(--theme-fg-primary);
}

.modern-sidebar .playlist-tracks {
    font-size: 11px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--theme-fg-muted);
}

.modern-sidebar .load-more-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 34px;
    margin-bottom: 6px;
    border-radius: 9px;
    border: 1px dashed var(--theme-border-strong);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--theme-fg-secondary);
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

    .modern-sidebar .load-more-btn:hover {
        background: var(--theme-tint-soft);
        border-color: var(--theme-primary);
        color: var(--theme-primary);
    }

/* ---- Admin rows ---- */

/* Wrapper exists so the admin rows can become a grid on the mobile sheet. */
.modern-sidebar .admin-links {
    display: flex;
    flex-direction: column;
}

.modern-sidebar .playlist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    height: 36px;
    padding: 0 10px;
    margin-bottom: 2px;
    border-radius: 9px;
    text-align: left;
    color: var(--theme-fg-secondary);
    transition: background 0.15s ease, color 0.15s ease;
}

    .modern-sidebar .playlist-item:hover {
        background: var(--theme-tint-soft);
        color: var(--theme-primary);
    }

    .modern-sidebar .playlist-item .mud-icon-root {
        flex-shrink: 0;
        color: inherit;
    }

    .modern-sidebar .playlist-item .playlist-name {
        flex: 1;
        font-weight: 500;
        color: inherit;
    }

/* ---- Badges ---- */

.modern-sidebar .nav-with-badge {
    position: relative;
}

.modern-sidebar .nav-new-badge {
    margin-left: auto;
    padding: 3px 7px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    line-height: 1;
    color: rgb(var(--on-accent-rgb));
    background: var(--theme-primary);
}

.modern-sidebar .pending-art-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    color: rgb(var(--on-accent-rgb));
    background: var(--theme-accent);
    margin-left: auto;
    flex-shrink: 0;
}

/* ============================================================================
   FOOTER
   ============================================================================ */

.modern-sidebar .sidebar-footer {
    /* The utility row's top border lines up with the GlobalPlayer's top edge.
       The player is fixed to the bottom at --player-height, so the block below
       that border -- utility row + gap + theme strip + this padding -- has to
       add up to exactly --player-height. Expressing the padding as a calc()
       keeps the two locked together if the player height ever changes. */
    --sb-utility-h: 32px;
    --sb-tile-h: 42px;
    --sb-strip-pad: 4px;
    --sb-strip-h: calc(var(--sb-tile-h) + 2 * var(--sb-strip-pad));
    --sb-footer-gap: 8px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sb-footer-gap);
    padding: 10px;
    padding-bottom: calc(var(--player-height) - var(--sb-strip-h) - var(--sb-footer-gap) - var(--sb-utility-h));
    border-top: 1px solid var(--theme-border);
    background: var(--theme-bg-base);
    /* .sidebar-wrapper clips its overflow; the footer has to opt out or the left
       spikes of the profile card's rank frame get cut off. */
    overflow: visible;
}

/* ---- Profile ---- */

.modern-sidebar .profile-menu,
.modern-sidebar .profile-menu .mud-menu-activator {
    width: 100%;
}

/* Gap and left padding are sized so a rank frame's spikes clear both the card
   edge and the username. See css/rank-frames.css. */
.modern-sidebar .profile-card {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 8px 8px 8px 12px;
    border-radius: 12px;
    background: var(--theme-bg-raised);
    cursor: pointer;
    transition: background 0.2s ease;
}

    .modern-sidebar .profile-card:hover {
        background: var(--theme-bg-hovered);
    }

.modern-sidebar .profile-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.modern-sidebar .profile-display-name {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--theme-fg-primary);
}

.modern-sidebar .profile-sub {
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    color: var(--theme-fg-muted);
}

.modern-sidebar .profile-more {
    flex-shrink: 0;
    font-size: 18px !important;
    color: var(--theme-fg-muted);
}

/* ---- Daily tasks ---- */

/* Daily Tasks and Neurolings sit side by side in one footer row. */
.modern-sidebar .footer-entry-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
}

    .modern-sidebar .footer-entry-row .daily-tasks-entry,
    .modern-sidebar .footer-entry-row .neurolings-entry,
    .modern-sidebar .footer-entry-row .signin-entry {
        min-width: 0;
        padding: 0 10px;
    }

.modern-sidebar .neurolings-entry {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    height: 36px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--theme-border);
    background: var(--theme-tint);
    color: var(--theme-fg-primary);
    font-size: 12.5px;
    font-weight: 700;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

    .modern-sidebar .neurolings-entry:hover {
        border-color: var(--theme-primary);
        transform: translateY(-1px);
    }

.modern-sidebar .neurolings-icon {
    font-size: 18px !important;
    color: var(--theme-primary);
    flex-shrink: 0;
}

.modern-sidebar .neurolings-label {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modern-sidebar .neurolings-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    flex-shrink: 0;
    border-radius: 9px;
    background: var(--theme-accent);
    color: rgb(var(--on-accent-rgb));
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
}

.modern-sidebar .neurolings-rail {
    position: relative;
    width: 36px;
    height: 36px;
    background: var(--theme-tint);
    color: var(--theme-primary);
    border-radius: 10px;
}

    .modern-sidebar .neurolings-rail .mud-icon-root {
        font-size: 19px;
    }

.modern-sidebar .neurolings-count.rail {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 15px;
    height: 15px;
    font-size: 9px;
}

.modern-sidebar .daily-tasks-entry {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 36px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--theme-border);
    background: var(--theme-tint);
    color: var(--theme-fg-primary);
    font-size: 12.5px;
    font-weight: 700;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

    .modern-sidebar .daily-tasks-entry:hover {
        border-color: var(--theme-primary);
        transform: translateY(-1px);
    }

.modern-sidebar .daily-tasks-icon {
    font-size: 18px !important;
    color: var(--theme-primary);
}

.modern-sidebar .daily-tasks-label {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modern-sidebar .daily-tasks-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--theme-accent);
    color: rgb(var(--on-accent-rgb));
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
}

.modern-sidebar .daily-tasks-rail {
    position: relative;
    width: 36px;
    height: 36px;
    background: var(--theme-tint);
    color: var(--theme-primary);
    border-radius: 10px;
}

    .modern-sidebar .daily-tasks-rail .mud-icon-root {
        font-size: 19px;
    }

.modern-sidebar .daily-tasks-count.rail {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 15px;
    height: 15px;
    font-size: 9px;
}

.modern-sidebar .signin-entry {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 36px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--theme-border);
    background: var(--theme-tint);
    color: var(--theme-fg-primary);
    font-size: 12.5px;
    font-weight: 700;
}

    .modern-sidebar .signin-entry:hover {
        border-color: var(--theme-primary);
        color: var(--theme-primary);
    }

/* ---- Utility row ---- */

.modern-sidebar .footer-toolbar-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.modern-sidebar .footer-action-btn,
.modern-sidebar .footer-action-btn-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: var(--sb-utility-h);
    border-radius: 9px;
    background: var(--theme-bg-raised);
    color: var(--theme-fg-secondary);
    font-size: 12px;
    font-weight: 700;
    transition: background 0.2s ease, color 0.2s ease;
}

    .modern-sidebar .footer-action-btn:hover,
    .modern-sidebar .footer-action-btn-menu:hover {
        background: var(--theme-tint);
        color: var(--theme-primary);
    }

    .modern-sidebar .footer-action-btn .mud-icon-root,
    .modern-sidebar .footer-action-btn-menu .mud-icon-root {
        font-size: 18px !important;
        color: inherit !important;
    }

/* MudMenu wraps its activator button; make it fill the grid cell. */
.modern-sidebar .footer-action-btn-menu .mud-menu-activator,
.modern-sidebar .footer-action-btn-menu .mud-icon-button {
    width: 100%;
    height: 100%;
    color: inherit !important;
    border-radius: 9px;
}

/* ============================================================================
   THEME SWITCHER

   The active character stretches to show its name, the current mode and the
   mode icon; the other two collapse to a 44px face. Clicking the active
   character flips Darkness/Light, clicking another switches theme.
   ============================================================================ */

.modern-sidebar .theme-strip {
    display: flex;
    gap: 4px;
    padding: var(--sb-strip-pad);
    border-radius: 14px;
    background: var(--theme-bg-raised);
}

.modern-sidebar .theme-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 0 0 44px;
    height: var(--sb-tile-h);
    padding: 0 10px;
    border-radius: 10px;
    overflow: hidden;
    opacity: 0.45;
    background: transparent;
    transition: flex-basis 0.25s ease, opacity 0.2s ease, background 0.25s ease;
}

    .modern-sidebar .theme-tile:hover {
        opacity: 0.75;
    }

    .modern-sidebar .theme-tile.active {
        flex: 1 1 auto;
        opacity: 1;
        background: var(--theme-gradient-brand);
    }

.modern-sidebar .theme-tile-face {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.modern-sidebar .theme-tile-faces {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

    .modern-sidebar .theme-tile-faces img {
        width: 22px;
        height: 22px;
        border-radius: 50%;
        object-fit: cover;
    }

        .modern-sidebar .theme-tile-faces img:first-child {
            margin-right: -6px;
        }

.modern-sidebar .theme-tile-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
}

.modern-sidebar .theme-tile-name {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.9px;
    text-transform: uppercase;
    line-height: 1;
    white-space: nowrap;
    color: rgb(var(--on-accent-rgb));
}

.modern-sidebar .theme-tile-mode {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    line-height: 1;
    white-space: nowrap;
    color: rgba(var(--on-accent-rgb), 0.85);
}

.modern-sidebar .theme-tile-mode-icon {
    font-size: 15px !important;
    flex-shrink: 0;
    color: rgba(var(--on-accent-rgb), 0.9);
}

/* Rail: one button cycles mode, then character. */
.modern-sidebar .theme-switch-collapsed {
    position: relative;
    width: 44px;
    height: 44px;
    margin: 0 auto;
    padding: 0;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--theme-gradient-brand);
    transition: transform 0.2s ease;
}

    .modern-sidebar .theme-switch-collapsed:hover {
        transform: scale(1.06);
    }

    .modern-sidebar .theme-switch-collapsed .theme-tile-face {
        width: 28px;
        height: 28px;
        border: 1px solid rgba(var(--on-accent-rgb), 0.3);
    }

    .modern-sidebar .theme-switch-collapsed .theme-tile-faces img {
        width: 20px;
        height: 20px;
        border: 1px solid rgba(var(--on-accent-rgb), 0.3);
    }

.modern-sidebar .theme-switch-mode-badge {
    position: absolute;
    bottom: -3px;
    right: -3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--theme-bg-base);
    color: var(--theme-primary);
}

    .modern-sidebar .theme-switch-mode-badge .mud-icon-root {
        font-size: 12px !important;
    }

/* ============================================================================
   COLLAPSED RAIL (72px)
   ============================================================================ */

.modern-sidebar.collapsed:not(.mobile-open) .sidebar-nav {
    padding: 0 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.modern-sidebar.collapsed:not(.mobile-open) .nav-group,
.modern-sidebar.collapsed:not(.mobile-open) .mud-navmenu {
    width: 100%;
}

.modern-sidebar.collapsed:not(.mobile-open) .mud-nav-link {
    width: 48px;
    height: 40px;
    margin: 0 auto 4px !important;
    padding: 0 !important;
    justify-content: center !important;
    border-radius: 10px !important;
}

    .modern-sidebar.collapsed:not(.mobile-open) .mud-nav-link .mud-icon-root {
        font-size: 21px !important;
    }

    .modern-sidebar.collapsed:not(.mobile-open) .mud-nav-link .mud-nav-link-text,
    .modern-sidebar.collapsed:not(.mobile-open) .mud-nav-link span:not(.mud-nav-link-icon) {
        display: none !important;
    }

.modern-sidebar.collapsed:not(.mobile-open) .sidebar-footer {
    align-items: center;
    padding: 10px 8px;
}

.modern-sidebar.collapsed:not(.mobile-open) .profile-card {
    width: auto;
    padding: 0;
    background: transparent;
}

.modern-sidebar.collapsed:not(.mobile-open) .profile-menu,
.modern-sidebar.collapsed:not(.mobile-open) .profile-menu .mud-menu-activator {
    width: auto;
}

/* ============================================================================
   EXPAND TRIGGER (desktop, collapsed only)
   ============================================================================ */

.modern-sidebar .expand-trigger {
    position: absolute;
    right: -16px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 80px;
    padding: 0;
    z-index: 110;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 12px 12px 0;
    border: 1px solid var(--theme-border);
    border-left: none;
    background: linear-gradient(90deg, transparent 0%, var(--theme-bg-raised) 30%, var(--theme-bg-raised) 100%);
    color: var(--theme-fg-muted);
    opacity: 0.8;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

    .modern-sidebar .expand-trigger:hover {
        opacity: 1;
        width: 36px;
        transform: translateY(-50%) translateX(2px);
        border-color: var(--theme-primary);
        color: var(--theme-primary);
        background: linear-gradient(90deg, transparent 0%, var(--theme-bg-hovered) 30%, var(--theme-bg-hovered) 100%);
    }

/* ============================================================================
   MOBILE FULLSCREEN
   ============================================================================ */

@media (max-width: 1024px) {
    .modern-sidebar {
        width: 100vw !important;
        height: 100vh;
        height: 100dvh;
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        z-index: 200;
    }

        .modern-sidebar.mobile-open {
            transform: translateY(0);
        }

    .modern-sidebar .sidebar-wrapper {
        border-right: none;
    }

    .modern-sidebar .expand-trigger {
        display: none;
    }

    /* ---- Header: 58px, no mode line (the theme tile in the footer owns it) ---- */

    .modern-sidebar.mobile-open .sidebar-brand {
        padding: 16px 16px 12px;
        padding-top: max(16px, env(safe-area-inset-top, 16px));
        border-bottom: none;
    }

    .modern-sidebar.mobile-open .brand-mark {
        width: 30px;
        height: 30px;
        border-radius: 9px;
    }

    .modern-sidebar.mobile-open .brand-text {
        font-size: 15px;
        font-weight: 700;
    }

    .modern-sidebar.mobile-open .brand-mode {
        display: none;
    }

    .modern-sidebar.mobile-open .icon-tile {
        width: 34px;
        height: 34px;
        border-radius: 10px;
        color: var(--theme-fg-secondary);
    }

        .modern-sidebar.mobile-open .icon-tile .mud-icon-root {
            font-size: 20px;
        }

    /* ---- Search: a field, not a list row ---- */

    .modern-sidebar.mobile-open .mobile-search-entry {
        flex-shrink: 0;
        display: flex;
        align-items: center;
        gap: 10px;
        height: 38px;
        margin: 0 16px 10px;
        padding: 0 12px;
        border-radius: 12px;
        background: var(--theme-bg-raised);
        color: var(--theme-fg-muted);
        font-size: 14px;
        text-align: left;
    }

        .modern-sidebar.mobile-open .mobile-search-entry .mud-icon-root {
            font-size: 19px !important;
            color: inherit !important;
        }

    /* ---- Nav: two columns of 42px rows ---- */

    .modern-sidebar.mobile-open .sidebar-nav {
        padding: 0 16px 8px;
    }

    .modern-sidebar.mobile-open .nav-group {
        margin-bottom: 10px;
    }

    .modern-sidebar.mobile-open .nav-group-header {
        padding: 0 0 8px;
    }

    .modern-sidebar.mobile-open .mud-navmenu,
    .modern-sidebar.mobile-open .admin-links {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .modern-sidebar.mobile-open .mud-nav-link,
    .modern-sidebar.mobile-open .playlist-item {
        height: 42px;
        min-height: 42px;
        padding: 0 10px !important;
        margin: 0 !important;
        border-radius: 12px !important;
        font-size: 14px !important;
        gap: 10px;
        min-width: 0;
        background: var(--theme-tint-soft);
    }

        .modern-sidebar.mobile-open .mud-nav-link .mud-icon-root,
        .modern-sidebar.mobile-open .playlist-item .mud-icon-root {
            font-size: 20px !important;
        }

    .modern-sidebar.mobile-open .playlist-item .playlist-name {
        font-size: 14px;
    }

    /* Promoted, duplicated or too-tall entries are dropped from the sheet:
       Search is the field above, and the recent-playlist cards cost 3x76px
       while duplicating the Playlists page. */
    .modern-sidebar.mobile-open .nav-search-link,
    .modern-sidebar.mobile-open .nav-subhead,
    .modern-sidebar.mobile-open .playlist-item-card,
    .modern-sidebar.mobile-open .load-more-btn,
    .modern-sidebar.mobile-open .add-playlist-btn {
        display: none !important;
    }

    /* ---- Footer: one 44px row ---- */

    .modern-sidebar.mobile-open .sidebar-footer {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        padding: 10px 16px 20px;
        padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
    }

    .modern-sidebar.mobile-open .profile-menu,
    .modern-sidebar.mobile-open .profile-menu .mud-menu-activator {
        flex: 1;
        min-width: 0;
        width: auto;
    }

    .modern-sidebar.mobile-open .profile-card {
        gap: 10px;
        height: 44px;
        padding: 0 10px 0 6px;
        border-radius: 12px;
    }

    .modern-sidebar.mobile-open .profile-display-name {
        font-size: 13px;
    }

    .modern-sidebar.mobile-open .profile-sub {
        font-size: 11px;
    }

    .modern-sidebar.mobile-open .signin-entry {
        flex: 1;
        min-width: 0;
        height: 44px;
        border-radius: 12px;
        font-size: 13px;
    }

    .modern-sidebar.mobile-open .footer-tile {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        flex-shrink: 0;
        padding: 0;
        border-radius: 12px;
        background: var(--theme-tint);
        color: var(--theme-primary);
    }

        .modern-sidebar.mobile-open .footer-tile .mud-icon-root {
            font-size: 21px !important;
            color: inherit !important;
        }

    .modern-sidebar.mobile-open .footer-tile-badge {
        position: absolute;
        top: -4px;
        right: -4px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        border-radius: 8px;
        background: var(--theme-accent);
        color: rgb(var(--on-accent-rgb));
        font-size: 10px;
        font-weight: 800;
        line-height: 1;
    }

    .modern-sidebar.mobile-open .footer-more-menu {
        flex-shrink: 0;
    }

        .modern-sidebar.mobile-open .footer-more-menu .footer-tile {
            background: var(--theme-bg-raised);
            color: var(--theme-fg-secondary);
        }

    /* The theme tile reuses the rail switcher's look at the row's 44px height. */
    .modern-sidebar.mobile-open .footer-tile.theme-switch-collapsed {
        margin: 0;
        border-radius: 12px;
        background: var(--theme-gradient-brand);
    }
}

@keyframes sidebarSlideInContent {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1024px) {
    .modern-sidebar.mobile-open .sidebar-nav,
    .modern-sidebar.mobile-open .sidebar-footer {
        animation: sidebarSlideInContent 0.4s ease 0.2s both;
    }

    .modern-sidebar.mobile-open .sidebar-brand {
        animation: sidebarSlideInContent 0.3s ease both;
    }
}

@media (prefers-reduced-motion: reduce) {
    .modern-sidebar,
    .modern-sidebar * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
