/* =================================================================================
 * KEYSTONE — Serenity Hub (#serenity-hub-panel), its controls overlay and the
 * in-game Sukha sessions tile
 * ---------------------------------------------------------------------------------
 * Replaces serenity-hub-aaa.css. The sheet: an eyebrow and title, a labelled close
 * control, a tab strip with a spectrum underline, the scrolling content and an
 * input-hint footer. The fill is drawn on ::before.
 *
 * This layer holds the shell, Themes and Music. Breathing lives in
 * breathing-library.css, Sukha sessions and the full-screen Sukha flow in
 * breathwork-sessions.css, the breathing guide in breathing-guide.css — all in the
 * same language. Behaviour: src/ui/serenity-hub/. Record:
 * docs/MENU_UI_OVERHAUL_2026-10.md.
 *
 * No backdrop-filter anywhere: the Hub opens over live WebGPU scenes. Depth comes
 * from a solid night scrim, layered fills and hairlines.
 * ============================================================================== */

#serenity-hub-panel {
    --hub-pad-x: clamp(20px, 2.6vw, 36px);
    --hub-pad-top: 22px;
    /* One card radius in every tab, one for rows and fields. */
    --hub-card-r: var(--sb-r-md);
    --hub-row-r: var(--sb-r-sm);
    /* The sheet's own colour; sticky bars paint it so content slides under cleanly. */
    --hub-sheet: rgb(19, 16, 44);
    --hub-card-fill:
        linear-gradient(180deg, rgba(var(--sb-cream-rgb), 0.04), rgba(var(--sb-cream-rgb), 0.012)),
        rgba(9, 8, 24, 0.32);
    /* The Hub's identity is mint; each tab tints its content with one spectrum hue. */
    --sb-accent-rgb: var(--sb-mint-rgb);
    --tab-rgb: var(--sb-mint-rgb);
}

#serenity-hub-panel[data-tab='themes'] { --tab-rgb: var(--sb-lavender-rgb); }
#serenity-hub-panel[data-tab='music'] { --tab-rgb: var(--sb-aqua-rgb); }
#serenity-hub-panel[data-tab='breathing'],
#serenity-hub-panel[data-tab='sessions'] { --tab-rgb: var(--sb-mint-rgb); }

/* `hidden` always wins inside these surfaces (several components set display). */
#serenity-hub-panel [hidden],
#gamepad-hints-overlay [hidden] {
    display: none !important;
}

/* ---- Scrim: solid night, no blur --------------------------------------------------- */
.serenity-hub-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1999;
    background:
        radial-gradient(90% 80% at 50% 45%, rgba(var(--sb-night-rgb), 0.62), rgba(5, 4, 14, 0.86) 100%);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--sb-dur-2) linear;
}

.serenity-hub-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ---- The sheet ------------------------------------------------------------------- */
#serenity-hub-panel.serenity-hub-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    width: min(1080px, calc(100vw - 48px));
    max-width: none;
    height: min(880px, calc(100vh - 48px));
    height: min(880px, calc(100dvh - 48px));
    max-height: none;
    overflow: visible;
    isolation: isolate;
    border: 0;
    border-radius: var(--sb-r-xl);
    background: none;
    box-shadow: none;
    color: var(--sb-text);
    font-family: var(--sb-font-text);
    transform: translate(-50%, -50%);
    translate: 0 14px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    /* Closed, the sheet leaves the Tab order and the accessibility tree once it has faded. */
    transition:
        opacity var(--sb-dur-2) linear,
        translate var(--sb-dur-3) var(--sb-ease-lock),
        visibility 0s linear var(--sb-dur-2);
}

#serenity-hub-panel.serenity-hub-panel.open {
    translate: 0 0;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition:
        opacity var(--sb-dur-2) linear,
        translate var(--sb-dur-3) var(--sb-ease-lock),
        visibility 0s;
}

#serenity-hub-panel:focus,
#serenity-hub-panel .hub-title:focus {
    outline: none;
}

/* The fill. */
#serenity-hub-panel.serenity-hub-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    border: 1px solid var(--sb-line);
    background:
        radial-gradient(70% 34% at 100% 0%, rgba(var(--tab-rgb), 0.11), transparent 70%),
        linear-gradient(180deg, rgb(27, 23, 60) 0%, var(--hub-sheet) 22%, var(--hub-sheet) 100%);
    box-shadow: inset 0 1px 0 rgba(var(--sb-cream-rgb), 0.07);
    pointer-events: none;
}

/* ---- Header: eyebrow, title, close ------------------------------------------------ */
#serenity-hub-panel .hub-panel-header {
    position: relative;
    flex: none;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding: clamp(22px, 3.6vh, 34px) var(--hub-pad-x) 18px;
    border: 0;
    background: none;
}

#serenity-hub-panel .hub-heading {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

#serenity-hub-panel .hub-eyebrow {
    --sb-accent-rgb: var(--sb-mint-rgb);
}

/* Eyebrows that wrap (phones, long session facts) keep their lines apart; the tile
   bullet stays on the first line. */
#serenity-hub-panel .sb-eyebrow,
.sukha-flow .sb-eyebrow,
#gamepad-hints-overlay .sb-eyebrow {
    align-items: flex-start;
    line-height: 1.5;
}

#serenity-hub-panel .sb-eyebrow::before,
.sukha-flow .sb-eyebrow::before,
#gamepad-hints-overlay .sb-eyebrow::before {
    margin-top: calc((1.5em - 7px) / 2);
}

#serenity-hub-panel .hub-title {
    margin: 0;
    font: 700 var(--sb-fs-title) / 1.05 var(--sb-font-display);
    letter-spacing: -0.01em;
    text-transform: none;
    color: var(--sb-text);
    background: none;
    -webkit-text-fill-color: currentColor;
    text-shadow: none;
    filter: none;
    animation: none;
}

#serenity-hub-panel .hub-title::after {
    content: none;
}

#serenity-hub-panel .hub-close-btn {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 10px;
    width: auto;
    height: auto;
    min-height: 40px;
    padding: 0 9px 0 14px;
    border-radius: 12px;
    border: 1px solid var(--sb-line-strong);
    background: rgba(var(--sb-cream-rgb), 0.04);
    color: var(--sb-text-muted);
    font: 600 0.6875rem / 1 var(--sb-font-display);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    box-shadow: none;
    cursor: pointer;
    transform: none;
    transition:
        color var(--sb-dur-2) var(--sb-ease-lock),
        background var(--sb-dur-2) var(--sb-ease-lock),
        border-color var(--sb-dur-2) var(--sb-ease-lock);
}

#serenity-hub-panel .hub-close-btn:hover {
    color: var(--sb-text);
    background: rgba(var(--sb-cream-rgb), 0.09);
    border-color: rgba(var(--sb-cream-rgb), 0.34);
    transform: none;
    box-shadow: none;
}

#serenity-hub-panel .hub-close-btn:active {
    transform: translateY(1px);
}

#serenity-hub-panel .hub-close-btn svg {
    width: 16px;
    height: 16px;
}

#serenity-hub-panel .hub-close-btn .sb-kbd {
    min-width: 20px;
    height: 20px;
    font-size: 0.625rem;
}

/* ---- Tab strip: words, tile icons, a spectrum underline under the chosen tab ------ */
#serenity-hub-panel .hub-tabs {
    position: relative;
    flex: none;
    display: flex;
    gap: 2px;
    margin: 0;
    padding: 0 var(--hub-pad-x);
    border: 0;
    border-radius: 0;
    /* The hairline is painted inside the strip so the underline can sit on it. */
    background: linear-gradient(var(--sb-line), var(--sb-line)) 0 100% / 100% 1px no-repeat;
    box-shadow: none;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}

#serenity-hub-panel .hub-tabs::-webkit-scrollbar {
    display: none;
}

#serenity-hub-panel .hub-tab[data-tab='themes'] { --tab-rgb: var(--sb-lavender-rgb); }
#serenity-hub-panel .hub-tab[data-tab='music'] { --tab-rgb: var(--sb-aqua-rgb); }
#serenity-hub-panel .hub-tab[data-tab='breathing'],
#serenity-hub-panel .hub-tab[data-tab='sessions'] { --tab-rgb: var(--sb-mint-rgb); }

#serenity-hub-panel .hub-tab {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    margin: 0;
    padding: 0 16px 2px 12px;
    border: 0;
    border-radius: 12px 12px 0 0;
    background: transparent;
    color: var(--sb-text-faint);
    font: 600 0.6875rem / 1 var(--sb-font-display);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    white-space: nowrap;
    box-shadow: none;
    cursor: pointer;
    transform: none;
    transition:
        color var(--sb-dur-2) var(--sb-ease-lock),
        background var(--sb-dur-2) var(--sb-ease-lock);
}

#serenity-hub-panel .hub-tab__icon {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--sb-line);
    color: rgba(var(--tab-rgb), 0.55);
    transition:
        color var(--sb-dur-2) var(--sb-ease-lock),
        border-color var(--sb-dur-2) var(--sb-ease-lock),
        background var(--sb-dur-2) var(--sb-ease-lock);
}

#serenity-hub-panel .hub-tab__icon svg {
    width: 16px;
    height: 16px;
    stroke-width: 1.6;
}

#serenity-hub-panel .hub-tab:hover {
    color: var(--sb-text-muted);
    background: rgba(var(--sb-cream-rgb), 0.035);
    transform: none;
}

#serenity-hub-panel .hub-tab.active {
    color: var(--sb-text);
    background: linear-gradient(180deg, rgba(var(--tab-rgb), 0) 0%, rgba(var(--tab-rgb), 0.07) 100%);
    border: 0;
    box-shadow: none;
}

#serenity-hub-panel .hub-tab.active .hub-tab__icon {
    color: rgb(var(--tab-rgb));
    border-color: rgba(var(--tab-rgb), 0.4);
    background: rgba(var(--tab-rgb), 0.1);
    filter: none;
    transform: none;
}

#serenity-hub-panel .hub-tab::after {
    content: '';
    position: absolute;
    left: 12px;
    right: 16px;
    bottom: 0;
    height: 2px;
    border-radius: 2px;
    background: var(--sb-spectrum);
    opacity: 0;
    transform: scaleX(0.2);
    transform-origin: left center;
    transition:
        opacity var(--sb-dur-1) linear,
        transform var(--sb-dur-3) var(--sb-ease-lock);
    animation: none;
}

#serenity-hub-panel .hub-tab.active::after {
    opacity: 1;
    transform: none;
}

/* The strip clips vertically, so its focus ring sits just inside the tab. */
#serenity-hub-panel .hub-tab:focus-visible {
    outline: 2px solid rgba(var(--sb-cream-rgb), 0.82);
    outline-offset: -3px;
    box-shadow: none;
}

/* ---- Content: one scroll container for every tab ---------------------------------- */
#serenity-hub-panel .hub-tab-content {
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    contain: layout paint style;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--sb-cream-rgb), 0.2) transparent;
    scrollbar-gutter: stable;
}

#serenity-hub-panel .hub-tab-content::-webkit-scrollbar {
    width: 10px;
}

#serenity-hub-panel .hub-tab-content::-webkit-scrollbar-track {
    background: transparent;
}

#serenity-hub-panel .hub-tab-content::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: 6px;
    background: rgba(var(--sb-cream-rgb), 0.2) padding-box;
}

#serenity-hub-panel .hub-tab-content::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--sb-cream-rgb), 0.34) padding-box;
}

#serenity-hub-panel .tab-panel {
    display: none;
    padding: var(--hub-pad-top) var(--hub-pad-x) 30px;
}

#serenity-hub-panel .tab-panel.active {
    display: block;
    animation: hub-tab-in 0.36s var(--sb-ease-lock) both;
}

@keyframes hub-tab-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

#serenity-hub-panel .tab-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    color: var(--sb-text-faint);
    font: 500 var(--sb-fs-body) / 1.5 var(--sb-font-text);
}

/* ---- Footer: input hints ---------------------------------------------------------- */
#serenity-hub-panel .hub-footer {
    position: relative;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 14px var(--hub-pad-x) 16px;
    border-top: 1px solid var(--sb-line);
}

/* ---- Shared content patterns ---------------------------------------------------- */
#serenity-hub-panel .hub-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

#serenity-hub-panel .sb-btn {
    --sb-btn-h: 44px;
    padding: 0 18px;
    font-size: 0.6875rem;
}

#serenity-hub-panel .sb-btn .cs-icon {
    flex: none;
    width: 18px;
    height: 18px;
}

/* =================================================================================
 * Themes: the library of worlds (ThemesTab.js, ThemeCollectionView.js)
 * The Breathing tab's shape: one featured world with its action bar, then every world
 * as artwork. A world's category gives it a hue (--tc-rgb); the theme that is on
 * carries a "Current" label.
 * ================================================================================ */
#serenity-hub-panel .themes-lib {
    display: flex;
    flex-direction: column;
    padding: 0;
    color: var(--sb-text);
    font-family: var(--sb-font-text);
}

/* Category hue: the featured world's eyebrow and bar, a quiet light behind each card. */
#serenity-hub-panel :is(.theme-card, .themes-lib__hero, .themes-lib__bar) { --tc-rgb: var(--sb-lavender-rgb); }
#serenity-hub-panel :is(.theme-card, .themes-lib__hero, .themes-lib__bar)[data-group='biomes'] { --tc-rgb: var(--sb-mint-rgb); }
#serenity-hub-panel :is(.theme-card, .themes-lib__hero, .themes-lib__bar)[data-group='meditation'] { --tc-rgb: var(--sb-gold-rgb); }
#serenity-hub-panel :is(.theme-card, .themes-lib__hero, .themes-lib__bar)[data-group='fantasy'] { --tc-rgb: var(--sb-rose-rgb); }
#serenity-hub-panel :is(.theme-card, .themes-lib__hero, .themes-lib__bar):is([data-group='urban'], [data-group='sky']) { --tc-rgb: var(--sb-sky-rgb); }
#serenity-hub-panel :is(.theme-card, .themes-lib__hero, .themes-lib__bar):is([data-group='abstract'], [data-group='atmospheric']) { --tc-rgb: var(--sb-aqua-rgb); }

/* The bar under the featured world stays at the top while the grid scrolls: focus that moves
   to a card or a filter must not land beneath it. (A margin on what is scrolled to, not padding
   on the scroller: padding would count the stuck bar itself as out of view, and focusing its
   buttons would drag the page back up.) */
#serenity-hub-panel .themes-lib__browse :is(.theme-card, button, input) {
    scroll-margin-top: 96px;
}

/* ---- The featured world --------------------------------------------------------- */
#serenity-hub-panel .themes-lib__hero {
    position: relative;
    display: grid;
    /* The art's frame is kept close to the icons' own size, so the picture stays sharp. */
    grid-template-columns: minmax(0, 0.76fr) minmax(0, 1fr);
    min-height: 232px;
    overflow: hidden;
    border-radius: var(--hub-card-r) var(--hub-card-r) 0 0;
    border: 1px solid var(--sb-line);
    border-bottom: 0;
    background: var(--hub-card-fill);
}

#serenity-hub-panel .themes-lib__hero-art {
    position: relative;
    min-height: 200px;
    overflow: hidden;
    container-type: size;
    background-color: rgba(var(--sb-night-rgb), 0.8);
}

/* Theme icons are round. The picture is as wide as the frame's diagonal, so the frame sits
   inside the circle and the art fills it edge to edge. */
#serenity-hub-panel .themes-lib__hero-pic {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 126%;
    aspect-ratio: 1;
    background: center / cover no-repeat;
    translate: -50% -50%;
}

@supports (width: hypot(1cqw, 1cqh)) {
    #serenity-hub-panel .themes-lib__hero-pic {
        width: hypot(100cqw, 100cqh);
    }
}

/* The art fades into the panel so the words sit on night, never on the picture. */
#serenity-hub-panel .themes-lib__hero-art::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(19, 16, 44, 0) 55%, rgba(19, 16, 44, 0.96) 100%);
}

#serenity-hub-panel .themes-lib__hero-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    padding: 26px 30px 24px 14px;
}

#serenity-hub-panel .themes-lib__eyebrow {
    display: inline-flex;
    align-items: baseline;
    gap: 10px;
    color: rgb(var(--tc-rgb));
    font: 600 0.8125rem / 1.45 var(--sb-font-text);
    letter-spacing: 0.01em;
}

#serenity-hub-panel .themes-lib__eyebrow::before {
    content: '';
    position: relative;
    top: -1px;
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 2px;
    background: currentColor;
}

#serenity-hub-panel .themes-lib__name {
    margin: 0;
    color: var(--sb-text);
    font: 700 var(--sb-fs-title) / 1.1 var(--sb-font-display);
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
}

#serenity-hub-panel .themes-lib__description {
    margin: 0;
    max-width: 44ch;
    color: var(--sb-text-muted);
    font: 500 var(--sb-fs-body) / 1.6 var(--sb-font-text);
    text-wrap: pretty;
}

#serenity-hub-panel .themes-lib__song {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 2px 0 0;
    color: var(--sb-text-faint);
    font: 500 var(--sb-fs-small) / 1.4 var(--sb-font-text);
}

#serenity-hub-panel .themes-lib__song .cs-icon {
    flex: none;
    width: 14px;
    height: 14px;
    color: rgba(var(--tc-rgb), 0.85);
}

/* Why its action is closed from here (a game in progress). */
#serenity-hub-panel .themes-lib__note {
    max-width: 48ch;
    margin: 0;
    padding-left: 12px;
    border-left: 2px solid var(--sb-line-strong);
    color: var(--sb-text-faint);
    font: 500 var(--sb-fs-small) / 1.5 var(--sb-font-text);
}

/* A world not collected yet: its picture behind glass, the way to it in the words. */
#serenity-hub-panel .themes-lib__hero-seal {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 1;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--sb-line-strong);
    border-radius: 9px;
    background: rgba(13, 11, 30, 0.78);
    color: var(--sb-text);
    font: 600 0.6875rem / 1.2 var(--sb-font-display);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    white-space: nowrap;
    translate: -50% -50%;
}

#serenity-hub-panel .themes-lib__hero-seal svg { width: 15px; height: 15px; }
#serenity-hub-panel .themes-lib__hero.is-locked .themes-lib__hero-seal { display: inline-flex; }
#serenity-hub-panel .themes-lib__hero.is-locked .themes-lib__hero-pic { filter: saturate(0.3) brightness(0.72); }

/* ---- Its action bar: sticky, so the action stays in reach while the grid scrolls ---- */
#serenity-hub-panel .themes-lib__bar {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 12px 16px;
    margin: 0 0 26px;
    padding: 12px 14px;
    border: 1px solid var(--sb-line);
    border-radius: 0 0 var(--hub-card-r) var(--hub-card-r);
    /* Solid: cards slide under it cleanly. */
    background:
        linear-gradient(90deg, rgba(var(--tc-rgb), 0.09), rgba(var(--tc-rgb), 0.02) 70%),
        var(--hub-sheet);
}

#serenity-hub-panel .themes-lib__use,
#serenity-hub-panel .themes-lib__explore {
    flex: none;
    min-width: 196px;
}

/* The theme that is on: the button rests as a plain label. */
#serenity-hub-panel .themes-lib__use.is-current {
    min-width: 0;
    padding: 0 6px 0 4px;
    border-color: transparent;
    background: transparent;
    color: var(--sb-text);
    box-shadow: none;
    opacity: 1;
    cursor: default;
}

#serenity-hub-panel .themes-lib__use.is-current:active {
    transform: none;
}

/* Which world the bar acts on, and where it stands. */
#serenity-hub-panel .themes-lib__line {
    flex: 1 1 0;
    min-width: 0;
    margin: 0;
    color: var(--sb-text-faint);
    font: 500 var(--sb-fs-small) / 1.4 var(--sb-font-text);
}

#serenity-hub-panel .themes-lib__line-name {
    display: block;
    overflow: hidden;
    color: var(--sb-text);
    font: 600 0.8125rem / 1.3 var(--sb-font-display);
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Where the browser can tell that the bar is stuck, the name shows only then: above it, the
   featured world already says it. (The bar's height does not change: the button sets it.) */
@supports (container-type: scroll-state) {
    @media (min-width: 701px) {
        #serenity-hub-panel .themes-lib__bar { container-type: scroll-state; }

        /* Out of sight, not out of the status line: a screen reader still hears which world. */
        #serenity-hub-panel .themes-lib__line-name {
            position: absolute;
            width: 1px;
            height: 1px;
            clip-path: inset(50%);
        }

        @container scroll-state(stuck: top) {
            #serenity-hub-panel .themes-lib__line-name {
                position: static;
                width: auto;
                height: auto;
                clip-path: none;
            }
        }
    }
}

#serenity-hub-panel .themes-lib__feedback {
    color: var(--sb-mint);
}

#serenity-hub-panel .themes-lib__feedback:not(:empty)::before {
    content: '·';
    margin: 0 7px 0 3px;
    color: var(--sb-text-faint);
}

#serenity-hub-panel .random-theme-btn {
    flex: none;
}

#serenity-hub-panel .themes-lib :is(button, input):focus-visible {
    outline: 2px solid rgba(var(--sb-cream-rgb), 0.82);
    outline-offset: 3px;
}

/* ---- Live controls (Tornado), under its featured world ------------------------------ */
#serenity-hub-panel .theme-params {
    margin: -14px 0 26px;
}

#serenity-hub-panel .theme-params-panel {
    border-radius: var(--hub-card-r);
    border: 1px solid var(--sb-line);
    background: var(--hub-card-fill);
}

#serenity-hub-panel .theme-params-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    min-height: 48px;
    margin: 0;
    padding: 0 18px;
    border: 0;
    border-radius: inherit;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

#serenity-hub-panel .theme-params-title {
    --sb-accent-rgb: var(--sb-aqua-rgb);
}

#serenity-hub-panel .theme-params-toggle__state {
    color: var(--sb-text-muted);
    font: 600 0.625rem / 1 var(--sb-font-display);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

#serenity-hub-panel .theme-params-toggle:hover .theme-params-toggle__state {
    color: var(--sb-text);
}

#serenity-hub-panel .theme-params-body {
    display: grid;
    gap: 14px;
    padding: 6px 18px 20px;
}

#serenity-hub-panel .theme-param-row {
    display: grid;
    grid-template-columns: minmax(130px, 0.8fr) minmax(0, 1.4fr) 4.5rem;
    align-items: center;
    gap: 14px;
}

#serenity-hub-panel .theme-param-label {
    color: var(--sb-text-muted);
    font: 600 var(--sb-fs-small) / 1.3 var(--sb-font-text);
}

#serenity-hub-panel .theme-param-input[type='range'] {
    width: 100%;
    accent-color: var(--sb-aqua);
}

#serenity-hub-panel .theme-param-color {
    width: 44px;
    height: 30px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid var(--sb-line-strong);
    background: transparent;
    cursor: pointer;
}

#serenity-hub-panel .theme-param-value {
    color: var(--sb-text);
    font: 600 0.75rem / 1 var(--sb-font-display);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* ---- Every world: heading, tools, grid --------------------------------------------- */
#serenity-hub-panel .themes-lib__heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 14px;
    margin: 0 0 12px;
    color: var(--sb-text);
    font: 600 var(--sb-fs-heading) / 1.2 var(--sb-font-display);
}

#serenity-hub-panel .themes-lib__heading small {
    color: var(--sb-text-faint);
    font: 500 var(--sb-fs-small) / 1.4 var(--sb-font-text);
}

#serenity-hub-panel .themes-lib__heading small > span + span::before {
    content: '·';
    margin: 0 7px 0 4px;
    color: var(--sb-text-faint);
}

#serenity-hub-panel .themes-lib__heading strong {
    color: var(--sb-text-muted);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

#serenity-hub-panel .themes-lib__new {
    color: var(--sb-gold);
}

/* The collection's progress: one tile for every world, the collected ones lit. */
#serenity-hub-panel .theme-collection__progress {
    --sb-accent-rgb: var(--sb-mint-rgb);
    margin: 0 0 16px;
}

#serenity-hub-panel .theme-collection__progress > i {
    height: 7px;
    transition: background var(--sb-dur-3) var(--sb-ease-lock);
}

#serenity-hub-panel .themes-toolbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0 0 18px;
}

#serenity-hub-panel .themes-control-bar {
    display: flex;
    align-items: center;
    gap: 12px;
}

#serenity-hub-panel .themes-search-wrap {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

#serenity-hub-panel .search-icon {
    position: absolute;
    top: 50%;
    left: 15px;
    width: 16px;
    height: 16px;
    color: var(--sb-text-faint);
    transform: translateY(-50%);
    pointer-events: none;
    transition: color var(--sb-dur-2) var(--sb-ease-lock);
}

#serenity-hub-panel .themes-search-input {
    width: 100%;
    height: 44px;
    margin: 0;
    padding: 0 44px 0 42px;
    box-sizing: border-box;
    border-radius: var(--hub-row-r);
    border: 1px solid var(--sb-line-strong);
    background: rgba(var(--sb-night-rgb), 0.45);
    color: var(--sb-text);
    font: 500 0.9375rem / 1 var(--sb-font-text);
    letter-spacing: 0;
    outline: none;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
    transition:
        border-color var(--sb-dur-2) var(--sb-ease-lock),
        background var(--sb-dur-2) var(--sb-ease-lock);
}

#serenity-hub-panel .themes-search-input::-webkit-search-cancel-button,
#serenity-hub-panel .themes-search-input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

#serenity-hub-panel .themes-search-input::placeholder {
    color: var(--sb-text-faint);
}

#serenity-hub-panel .themes-search-input:hover {
    border-color: rgba(var(--sb-cream-rgb), 0.3);
}

#serenity-hub-panel .themes-search-input:focus {
    border-color: rgba(var(--sb-cream-rgb), 0.34);
    background: rgba(var(--sb-night-rgb), 0.6);
    box-shadow: none;
}

#serenity-hub-panel .themes-search-wrap:focus-within .search-icon {
    color: var(--sb-lavender);
}

#serenity-hub-panel .themes-search-clear {
    position: absolute;
    top: 50%;
    right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--sb-text-faint);
    cursor: pointer;
    transform: translateY(-50%);
    transition: color var(--sb-dur-2) var(--sb-ease-lock), background var(--sb-dur-2) var(--sb-ease-lock);
}

#serenity-hub-panel .themes-search-clear:hover {
    color: var(--sb-text);
    background: rgba(var(--sb-cream-rgb), 0.08);
}

#serenity-hub-panel .themes-lib .themes-search-clear:focus-visible {
    outline-offset: 1px;
}

/* All worlds, the ones you have, the ones to find: one control, three cells. */
#serenity-hub-panel .theme-collection__filters {
    display: inline-flex;
    flex: none;
    gap: 2px;
    padding: 3px;
    border-radius: var(--hub-row-r);
    border: 1px solid var(--sb-line-strong);
    background: rgba(var(--sb-night-rgb), 0.45);
}

#serenity-hub-panel .collection-filter {
    min-height: 36px;
    margin: 0;
    padding: 0 14px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--sb-text-muted);
    font: 600 0.625rem / 1 var(--sb-font-display);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
    transition:
        color var(--sb-dur-2) var(--sb-ease-lock),
        background var(--sb-dur-2) var(--sb-ease-lock);
}

#serenity-hub-panel .collection-filter:hover {
    color: var(--sb-text);
}

#serenity-hub-panel .collection-filter[aria-pressed='true'] {
    color: var(--sb-text);
    background: rgba(var(--sb-cream-rgb), 0.1);
}

#serenity-hub-panel .themes-lib .collection-filter:focus-visible {
    outline-offset: 1px;
}

/* Category chips: rounded squares, the group's name and how many worlds it holds. */
#serenity-hub-panel .category-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    overflow: visible;
}

#serenity-hub-panel .category-pill {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    margin: 0;
    padding: 0 11px;
    border-radius: 9px;
    border: 1px solid var(--sb-line);
    background: rgba(var(--sb-cream-rgb), 0.025);
    color: var(--sb-text-muted);
    font: 600 0.625rem / 1 var(--sb-font-display);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
    box-shadow: none;
    cursor: pointer;
    transform: none;
    transition:
        color var(--sb-dur-2) var(--sb-ease-lock),
        background var(--sb-dur-2) var(--sb-ease-lock),
        border-color var(--sb-dur-2) var(--sb-ease-lock);
}

#serenity-hub-panel .category-pill:hover {
    color: var(--sb-text);
    border-color: var(--sb-line-strong);
    background: rgba(var(--sb-cream-rgb), 0.06);
    transform: none;
    box-shadow: none;
}

#serenity-hub-panel .category-pill[aria-pressed='true'] {
    color: var(--sb-text);
    border-color: rgba(var(--sb-lavender-rgb), 0.55);
    background: rgba(var(--sb-lavender-rgb), 0.16);
    box-shadow: none;
}

#serenity-hub-panel .category-pill .pill-count {
    min-width: 0;
    padding: 0;
    border-radius: 0;
    background: none;
    color: var(--sb-text-faint);
    font: inherit;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.06em;
}

#serenity-hub-panel .category-pill[aria-pressed='true'] .pill-count {
    color: rgba(var(--sb-cream-rgb), 0.82);
    background: none;
}

/* A save that did not go through is said plainly, above the worlds it concerns. */
#serenity-hub-panel .theme-collection__save-status {
    margin: 0 0 18px;
    padding: 2px 0 2px 12px;
    border-left: 2px solid var(--sb-gold);
    color: var(--sb-text);
    font: 500 var(--sb-fs-small) / 1.6 var(--sb-font-text);
}

/* ---- The worlds ------------------------------------------------------------------ */
#serenity-hub-panel .themes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    grid-auto-rows: auto;
    gap: 16px 14px;
}

#serenity-hub-panel .theme-card {
    --mx: 50%;
    --my: 40%;
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: visible;
    border-radius: var(--hub-card-r);
    border: 1px solid var(--sb-line);
    background: var(--hub-card-fill);
    box-shadow: none;
    cursor: pointer;
    transform: none;
    /* Off-screen cards skip layout and paint (the grid holds every theme). */
    content-visibility: auto;
    contain-intrinsic-size: auto 176px;
    transition:
        border-color var(--sb-dur-2) var(--sb-ease-lock),
        background var(--sb-dur-2) var(--sb-ease-lock);
}

#serenity-hub-panel .theme-card.is-filtered-out {
    display: none !important;
}

/* A soft light follows the pointer (theme-card-interactions.js writes --mx / --my). */
#serenity-hub-panel .theme-card::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: inherit;
    background: radial-gradient(160px circle at var(--mx) var(--my), rgba(var(--tc-rgb), 0.14), transparent 70%);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--sb-dur-2) linear;
}

#serenity-hub-panel .theme-card:hover {
    border-color: var(--sb-line-strong);
    background:
        linear-gradient(180deg, rgba(var(--sb-cream-rgb), 0.06), rgba(var(--sb-cream-rgb), 0.02)),
        rgba(9, 8, 24, 0.32);
    box-shadow: none;
    transform: none;
}

#serenity-hub-panel .theme-card:hover::before {
    opacity: 1;
}

#serenity-hub-panel .theme-card:focus-visible {
    outline: 2px solid rgba(var(--sb-cream-rgb), 0.82);
    outline-offset: 3px;
    border-color: var(--sb-line-strong);
    box-shadow: none;
}

/* The art: the round icon, cropped to the frame (the frame sits inside the circle). */
#serenity-hub-panel .theme-swatch {
    position: relative;
    z-index: 1;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border-radius: calc(var(--hub-card-r) - 1px) calc(var(--hub-card-r) - 1px) 0 0;
    /* While a thumbnail decodes: the category's light, never a blank hole. */
    background:
        radial-gradient(60% 80% at 50% 50%, rgba(var(--tc-rgb), 0.16), transparent 80%),
        rgba(var(--sb-night-rgb), 0.8);
}

#serenity-hub-panel .theme-icon-img {
    position: absolute;
    top: 50%;
    left: 50%;
    display: block;
    width: 118%;
    max-width: none;
    height: auto;
    aspect-ratio: 1;
    object-fit: cover;
    opacity: 0;
    translate: -50% -50%;
    transition:
        opacity 0.18s linear,
        scale var(--sb-dur-3) var(--sb-ease-lock);
}

#serenity-hub-panel .theme-icon-img.is-ready {
    opacity: 1;
}

#serenity-hub-panel .theme-icon-emoji {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: rgba(var(--tc-rgb), 0.9);
}

#serenity-hub-panel .theme-card:hover .theme-icon-img {
    scale: 1.04;
}

#serenity-hub-panel .theme-info {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 11px 14px 13px;
    text-align: left;
}

#serenity-hub-panel .theme-name {
    margin: 0;
    overflow: hidden;
    color: var(--sb-text);
    font: 600 0.8125rem / 1.25 var(--sb-font-display);
    letter-spacing: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* One line under the name: the world's group, or where it is found. */
#serenity-hub-panel .theme-meta {
    overflow: hidden;
    color: rgba(var(--tc-rgb), 0.82);
    font: 500 0.75rem / 1.3 var(--sb-font-text);
    font-variant-numeric: tabular-nums;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The world in the featured spot: its hue on the frame. */
#serenity-hub-panel .theme-card[aria-pressed='true'] {
    border-color: rgba(var(--tc-rgb), 0.55);
    background:
        linear-gradient(180deg, rgba(var(--tc-rgb), 0.1), rgba(var(--tc-rgb), 0.02)),
        rgba(9, 8, 24, 0.32);
}

#serenity-hub-panel .theme-swatch .active-indicator,
#serenity-hub-panel .theme-new-mark {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    padding: 5px 7px;
    border-radius: 6px;
    border: 1px solid var(--sb-line-strong);
    background: rgba(var(--sb-night-rgb), 0.72);
    color: var(--sb-text);
    font: 600 0.5625rem / 1 var(--sb-font-display);
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

/* The chosen card, while it can be used: pressing it again is the same as the bar's button
   (a double click, a second Enter, a second A on a pad). */
#serenity-hub-panel .theme-use-hint {
    position: absolute;
    right: 8px;
    bottom: 8px;
    left: 8px;
    z-index: 1;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 6px 8px;
    border-radius: 7px;
    background: rgba(var(--sb-night-rgb), 0.82);
    color: var(--sb-text);
    /* Two lines on the narrowest cards rather than a clipped one. */
    font: 600 0.5625rem / 1.35 var(--sb-font-display);
    letter-spacing: 0.14em;
    text-align: center;
    text-transform: uppercase;
}

#serenity-hub-panel .theme-card.is-usable .theme-use-hint { display: flex; }

/* Just collected: gold on its frame, and a word that it is new. */
#serenity-hub-panel .theme-new-mark {
    display: none;
    border-color: transparent;
    background: var(--sb-gold);
    color: #1d1608;
    font-weight: 700;
}

#serenity-hub-panel .theme-card.is-new:not(.active) .theme-new-mark { display: inline-flex; }
#serenity-hub-panel .theme-card.is-new:not([aria-pressed='true']) { border-color: rgba(var(--sb-gold-rgb), 0.5); }

/* A world not collected yet: shown, as a promise of where it is found. The same language as
   a breathing world: the art drained of colour, a lock on its corner, the place for a group. */
#serenity-hub-panel .theme-card.is-locked .theme-icon-img { filter: saturate(0.3) brightness(0.68); }
#serenity-hub-panel .theme-card.is-locked .theme-name { color: var(--sb-text-muted); }
#serenity-hub-panel .theme-card.is-locked .theme-meta { color: var(--sb-text-faint); font-style: italic; }
#serenity-hub-panel .theme-lock-mark {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1;
    display: none;
    place-items: center;
    width: 26px;
    height: 26px;
    border: 1px solid var(--sb-line-strong);
    border-radius: 8px;
    background: var(--hub-sheet);
    color: var(--sb-text);
}
#serenity-hub-panel .theme-card.is-locked .theme-lock-mark { display: grid; }
#serenity-hub-panel .theme-lock-mark svg { width: 14px; height: 14px; }

/* ---- Nothing found ------------------------------------------------------------- */
#serenity-hub-panel .no-themes {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 46px 20px 50px;
    border-radius: var(--hub-card-r);
    border: 1px dashed var(--sb-line-strong);
    color: var(--sb-text-muted);
    text-align: center;
}

#serenity-hub-panel .no-themes__title {
    margin: 0;
    color: var(--sb-text);
    font: 600 var(--sb-fs-heading) / 1.3 var(--sb-font-display);
}

#serenity-hub-panel .no-themes__note {
    margin: 0 0 8px;
    color: var(--sb-text-faint);
    font: 500 var(--sb-fs-small) / 1.5 var(--sb-font-text);
}

/* =================================================================================
 * Music
 * ================================================================================ */
#serenity-hub-panel .music-tab {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
    gap: 16px;
    padding: 0;
}

#serenity-hub-panel .now-playing-section,
#serenity-hub-panel .volume-section {
    min-width: 0;
}

#serenity-hub-panel .playlist-section {
    grid-column: 1 / -1;
}

#serenity-hub-panel .now-playing-card,
#serenity-hub-panel .volume-section {
    border-radius: var(--hub-card-r);
    border: 1px solid var(--sb-line);
    background: var(--hub-card-fill);
    box-shadow: none;
}

#serenity-hub-panel .now-playing-card {
    display: grid;
    grid-template-columns: minmax(0, 0.62fr) minmax(0, 1fr);
    align-items: stretch;
    height: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

/* The playing track's picture: its world's artwork, edge to edge, fading into the panel (the
   featured world of the Themes tab, at a song's size). Theme icons are round, so the picture
   is as wide as the frame's diagonal and the frame sits inside the circle. A track without a
   world keeps the note on a wash of the spectrum. */
#serenity-hub-panel .album-art {
    position: relative;
    min-height: 196px;
    overflow: hidden;
    container-type: size;
    background-color: rgba(var(--sb-night-rgb), 0.8);
}

#serenity-hub-panel .album-art::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(19, 16, 44, 0) 50%, rgba(19, 16, 44, 0.96) 100%);
    pointer-events: none;
}

#serenity-hub-panel .vinyl-disc {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background:
        radial-gradient(70% 70% at 30% 25%, rgba(var(--sb-lavender-rgb), 0.32), transparent 70%),
        radial-gradient(80% 80% at 75% 80%, rgba(var(--sb-mint-rgb), 0.24), transparent 70%),
        rgba(var(--sb-aqua-rgb), 0.1);
    color: var(--sb-cream);
    animation: none;
    transition: none;
}

#serenity-hub-panel .album-art__pic {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 160%;
    aspect-ratio: 1;
    background: center / cover no-repeat;
    translate: -50% -50%;
}

@supports (width: hypot(1cqw, 1cqh)) {
    #serenity-hub-panel .album-art__pic {
        width: hypot(100cqw, 100cqh);
    }
}

/* It breathes slowly while music plays, and never spins. */
#serenity-hub-panel .vinyl-disc.spinning .album-art__pic {
    animation: hub-art-breathe calc(var(--sb-breath) * 2) var(--sb-ease-breathe) infinite;
}

@keyframes hub-art-breathe {
    0%, 100% { scale: 1; }
    50% { scale: 1.05; }
}

#serenity-hub-panel .vinyl-disc .cs-icon {
    position: relative;
    width: 42px;
    height: 42px;
    stroke-width: 1.4;
}

#serenity-hub-panel .album-art.has-art .vinyl-disc .cs-icon {
    display: none;
}

#serenity-hub-panel .track-controls-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
    min-width: 0;
    padding: 22px 24px 22px 10px;
}

#serenity-hub-panel .track-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    color: var(--sb-text);
    text-align: left;
}

#serenity-hub-panel .track-info .sb-eyebrow {
    --sb-accent-rgb: var(--sb-aqua-rgb);
}

#serenity-hub-panel .track-title {
    margin: 0;
    overflow: hidden;
    color: var(--sb-text);
    font: 700 clamp(1.25rem, 1.8vw, 1.6rem) / 1.15 var(--sb-font-display);
    letter-spacing: -0.005em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#serenity-hub-panel .track-meta {
    margin: 0;
    color: var(--sb-text-faint);
    font: 500 var(--sb-fs-small) / 1.3 var(--sb-font-text);
    font-variant-numeric: tabular-nums;
}

#serenity-hub-panel .playback-controls-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

#serenity-hub-panel .progress-container {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    color: var(--sb-text-faint);
    font: 600 0.6875rem / 1 var(--sb-font-display);
    font-variant-numeric: tabular-nums;
}

#serenity-hub-panel .progress-bar-container {
    position: relative;
    padding: 10px 0;
    border-radius: 6px;
    cursor: pointer;
}

#serenity-hub-panel .progress-bar-container:focus-visible {
    outline: 2px solid rgba(var(--sb-cream-rgb), 0.82);
    outline-offset: 3px;
}

#serenity-hub-panel .progress-bar {
    position: relative;
    width: 100%;
    height: 4px;
    overflow: visible;
    border-radius: 2px;
    background: rgba(var(--sb-cream-rgb), 0.12);
}

#serenity-hub-panel .progress-fill {
    position: absolute;
    inset: 0 auto 0 0;
    height: 100%;
    border-radius: 2px;
    background: var(--sb-spectrum);
}

/* The playhead: a cream tile (the keystone stays for the primary action). */
#serenity-hub-panel .progress-handle {
    position: absolute;
    top: 50%;
    left: 0;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: var(--sb-cream);
    box-shadow: 0 0 0 3px rgba(var(--sb-night-rgb), 0.6), 0 0 12px rgba(var(--sb-aqua-rgb), 0.5);
    opacity: 1;
}

#serenity-hub-panel .main-controls {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
}

#serenity-hub-panel .control-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 12px;
    border: 1px solid var(--sb-line-strong);
    background: rgba(var(--sb-cream-rgb), 0.04);
    color: var(--sb-text-muted);
    box-shadow: none;
    cursor: pointer;
    transform: none;
    transition:
        color var(--sb-dur-2) var(--sb-ease-lock),
        background var(--sb-dur-2) var(--sb-ease-lock),
        border-color var(--sb-dur-2) var(--sb-ease-lock),
        transform var(--sb-dur-1) var(--sb-ease-lock);
}

#serenity-hub-panel .control-btn.secondary {
    width: 46px;
    height: 46px;
}

#serenity-hub-panel .control-btn:hover {
    color: var(--sb-text);
    background: rgba(var(--sb-cream-rgb), 0.09);
    border-color: rgba(var(--sb-cream-rgb), 0.34);
    box-shadow: none;
    transform: none;
}

#serenity-hub-panel .control-btn:active {
    transform: translateY(1px);
}

/* Play / pause: the one primary action of the Music tab. */
#serenity-hub-panel .control-btn.primary {
    width: 58px;
    height: 54px;
    border-radius: 14px;
    border-color: transparent;
    background: var(--sb-keystone);
    color: var(--sb-keystone-ink);
    box-shadow: 0 12px 32px rgba(var(--sb-coral-rgb), 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

#serenity-hub-panel .control-btn.primary:hover {
    background: #ffbb9c;
    color: var(--sb-keystone-ink);
    border-color: transparent;
    box-shadow: 0 14px 40px rgba(var(--sb-coral-rgb), 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

#serenity-hub-panel .control-btn:focus-visible {
    outline: 2px solid rgba(var(--sb-cream-rgb), 0.82);
    outline-offset: 3px;
    box-shadow: none;
}

#serenity-hub-panel .control-icon {
    display: inline-flex;
    line-height: 0;
    color: currentColor;
}

#serenity-hub-panel .control-btn.primary .cs-icon {
    fill: currentColor;
    stroke-width: 1.4;
}

/* ---- Volume ---------------------------------------------------------------------- */
#serenity-hub-panel .volume-section {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
    padding: 22px 24px;
    background:
        radial-gradient(90% 120% at 100% 0%, rgba(var(--sb-lavender-rgb), 0.08), transparent 62%),
        var(--hub-card-fill);
}

#serenity-hub-panel .volume-section .sb-eyebrow {
    --sb-accent-rgb: var(--sb-aqua-rgb);
}

#serenity-hub-panel .volume-controls-stack {
    display: grid;
    gap: 16px;
    min-width: 0;
}

#serenity-hub-panel .volume-control {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    min-width: 0;
}

#serenity-hub-panel .volume-label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: var(--sb-text-muted);
    font: 600 0.625rem / 1 var(--sb-font-display);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    cursor: pointer;
}

#serenity-hub-panel .volume-icon {
    display: inline-flex;
    color: var(--sb-aqua);
    line-height: 0;
}

#serenity-hub-panel .volume-slider-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 3.25rem;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

/* Spectrum fill to the value (MusicTab paints --fill), a cream tile as the thumb. */
#serenity-hub-panel .volume-slider {
    width: 100%;
    height: 6px;
    margin: 10px 0;
    border-radius: 3px;
    background:
        linear-gradient(90deg, var(--sb-lavender), var(--sb-aqua) 60%, var(--sb-mint)) 0 0 / var(--fill, 50%) 100% no-repeat,
        rgba(var(--sb-cream-rgb), 0.12);
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

#serenity-hub-panel .volume-slider::-webkit-slider-thumb {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 0;
    background: var(--sb-cream);
    box-shadow: 0 0 0 4px rgba(var(--sb-night-rgb), 0.55), 0 2px 10px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: transform var(--sb-dur-1) var(--sb-ease-lock);
}

#serenity-hub-panel .volume-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 0;
    background: var(--sb-cream);
    box-shadow: 0 0 0 4px rgba(var(--sb-night-rgb), 0.55), 0 2px 10px rgba(0, 0, 0, 0.4);
    cursor: pointer;
}

#serenity-hub-panel .volume-slider:hover::-webkit-slider-thumb,
#serenity-hub-panel .volume-slider:active::-webkit-slider-thumb {
    transform: scale(1.1);
}

#serenity-hub-panel .volume-slider:focus-visible {
    outline: 2px solid rgba(var(--sb-cream-rgb), 0.82);
    outline-offset: 6px;
}

#serenity-hub-panel .volume-value {
    min-width: 0;
    color: var(--sb-text);
    font: 600 0.75rem / 1 var(--sb-font-display);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

#serenity-hub-panel .volume-actions {
    display: flex;
    justify-content: flex-start;
    padding: 16px 0 0;
    border: 0;
    border-top: 1px solid var(--sb-line);
}

#serenity-hub-panel .mute-btn {
    position: static;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    width: auto;
    min-height: 40px;
    padding: 0 16px 0 12px;
    border-radius: 12px;
    border: 1px solid var(--sb-line-strong);
    background: rgba(var(--sb-cream-rgb), 0.04);
    color: var(--sb-text-muted);
    box-shadow: none;
    cursor: pointer;
    transform: none;
    transition:
        color var(--sb-dur-2) var(--sb-ease-lock),
        background var(--sb-dur-2) var(--sb-ease-lock),
        border-color var(--sb-dur-2) var(--sb-ease-lock);
}

#serenity-hub-panel .mute-btn:hover {
    color: var(--sb-text);
    background: rgba(var(--sb-cream-rgb), 0.09);
    border-color: rgba(var(--sb-cream-rgb), 0.34);
    transform: none;
}

#serenity-hub-panel .mute-btn:focus-visible {
    outline: 2px solid rgba(var(--sb-cream-rgb), 0.82);
    outline-offset: 3px;
}

#serenity-hub-panel .mute-btn.muted {
    color: var(--sb-danger);
    border-color: rgba(var(--sb-danger-rgb), 0.45);
    background: rgba(var(--sb-danger-rgb), 0.08);
}

#serenity-hub-panel .mute-icon {
    display: inline-flex;
    line-height: 0;
    color: currentColor;
}

#serenity-hub-panel .mute-text {
    font: 600 0.6875rem / 1 var(--sb-font-display);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

/* Keep the sliders on the cosmic cursor while dragging. */
body.custom-cursor-active #serenity-hub-panel .volume-slider,
body.custom-cursor-active #serenity-hub-panel .volume-slider-container,
body.custom-cursor-active #serenity-hub-panel .volume-slider::-webkit-slider-thumb,
body.custom-cursor-active #serenity-hub-panel .volume-slider::-moz-range-thumb,
body.custom-cursor-active.serenity-volume-dragging,
body.custom-cursor-active.serenity-volume-dragging * {
    cursor: none !important;
}

/* ---- Playlist ------------------------------------------------------------------- */
#serenity-hub-panel .playlist-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 12px;
}

#serenity-hub-panel .playlist-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

#serenity-hub-panel .playlist-header h3 {
    margin: 0;
    color: var(--sb-text);
    font: 600 var(--sb-fs-heading) / 1.2 var(--sb-font-display);
    letter-spacing: 0;
}

#serenity-hub-panel .track-count {
    padding: 6px 9px;
    border-radius: 7px;
    border: 1px solid var(--sb-line-strong);
    background: none;
    color: var(--sb-text-muted);
    font: 600 0.625rem / 1 var(--sb-font-display);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

#serenity-hub-panel .playlist-container {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 14px;
}

#serenity-hub-panel .playlist-item {
    position: relative;
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr) 20px;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 56px;
    margin: 0;
    padding: 6px 14px 6px 6px;
    border-radius: var(--hub-row-r);
    border: 1px solid transparent;
    background: rgba(var(--sb-cream-rgb), 0.025);
    color: var(--sb-text-muted);
    font: inherit;
    text-align: left;
    box-shadow: none;
    cursor: pointer;
    transform: none;
    transition:
        color var(--sb-dur-2) var(--sb-ease-lock),
        background var(--sb-dur-2) var(--sb-ease-lock),
        border-color var(--sb-dur-2) var(--sb-ease-lock);
}

#serenity-hub-panel .playlist-item:hover {
    color: var(--sb-text);
    border-color: transparent;
    background: rgba(var(--sb-aqua-rgb), 0.07);
    transform: none;
}

#serenity-hub-panel .playlist-item:focus-visible {
    outline: 2px solid rgba(var(--sb-cream-rgb), 0.82);
    outline-offset: 3px;
    box-shadow: none;
}

/* The track that is on: aqua light. */
#serenity-hub-panel .playlist-item.active {
    color: var(--sb-text);
    border-color: rgba(var(--sb-aqua-rgb), 0.32);
    background: linear-gradient(90deg, rgba(var(--sb-aqua-rgb), 0.16) 0%, rgba(var(--sb-aqua-rgb), 0.04) 70%, rgba(var(--sb-aqua-rgb), 0) 100%);
}

/* A row's picture: its world's artwork, cut as the Themes tab cuts its cards. */
#serenity-hub-panel .playlist-item-art {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border-radius: 7px;
    background: rgba(var(--sb-night-rgb), 0.8);
    color: var(--sb-text-faint);
}

#serenity-hub-panel .playlist-item-art img,
#serenity-hub-panel .music-collection-detail__art img {
    position: absolute;
    top: 50%;
    left: 50%;
    display: block;
    width: 118%;
    max-width: none;
    height: auto;
    aspect-ratio: 1;
    object-fit: cover;
    translate: -50% -50%;
}

#serenity-hub-panel .playlist-item.is-locked .playlist-item-art img,
#serenity-hub-panel .music-collection-detail.is-locked .music-collection-detail__art img {
    filter: saturate(0.3) brightness(0.68);
}

#serenity-hub-panel .playlist-item-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

#serenity-hub-panel .playlist-item-title {
    overflow: hidden;
    color: inherit;
    font: 600 var(--sb-fs-body) / 1.25 var(--sb-font-text);
    text-overflow: ellipsis;
    white-space: nowrap;
}

#serenity-hub-panel .playlist-item-artist {
    margin: 0;
    color: var(--sb-text-faint);
    font: 500 0.75rem / 1.2 var(--sb-font-text);
}

#serenity-hub-panel .playlist-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

#serenity-hub-panel .playlist-item-icon svg { width: 17px; height: 17px; }
#serenity-hub-panel .playlist-item.is-locked { border-color: var(--sb-line); }
#serenity-hub-panel .playlist-item.is-locked .playlist-item-title { color: var(--sb-text-muted); }
#serenity-hub-panel .playlist-item-collection {
    color: var(--sb-text-muted);
    font: 500 0.72rem / 1.5 var(--sb-font-text);
    overflow-wrap: anywhere;
}
#serenity-hub-panel .music-collection-note {
    margin: 0;
    color: var(--sb-text-muted);
    font-size: 0.84rem;
    line-height: 1.6;
}
#serenity-hub-panel .music-collection-detail {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 16px 20px 16px 16px;
    border: 1px solid var(--sb-line-strong);
    border-radius: var(--hub-card-r);
    background: rgba(var(--sb-aqua-rgb), 0.04);
    overflow-wrap: anywhere;
}
#serenity-hub-panel .music-collection-detail[hidden] { display: none; }
#serenity-hub-panel .music-collection-detail__art {
    position: relative;
    flex: none;
    width: 208px;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border-radius: var(--hub-row-r);
    background: rgba(var(--sb-night-rgb), 0.8);
}
#serenity-hub-panel .music-collection-detail__body { flex: 1 1 0; min-width: 0; }
#serenity-hub-panel .music-collection-detail__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
#serenity-hub-panel .music-collection-detail h4:focus { outline: none; }
#serenity-hub-panel .music-collection-detail .music-detail-route-note { margin: 12px 0 0; }
#serenity-hub-panel .music-collection-detail h4 {
    margin: 8px 0 12px;
    color: var(--sb-text);
    font: 600 1.2rem / 1.4 var(--sb-font-display);
}
#serenity-hub-panel .music-collection-detail p:not(.sb-eyebrow) {
    color: var(--sb-text-muted);
    font-size: 0.84rem;
    line-height: 1.6;
}

#serenity-hub-panel .playing-indicator {
    display: inline-flex;
    color: var(--sb-aqua);
    line-height: 0;
    animation: none;
}

/* ---- Scrolling: the browser only scrolls (SerenityHub toggles .is-scrolling) ------ */
#serenity-hub-panel.is-scrolling .theme-card,
#serenity-hub-panel.is-scrolling .breath-world,
#serenity-hub-panel.is-scrolling .sukha-card,
#serenity-hub-panel.is-scrolling .playlist-item {
    pointer-events: none;
    transition: none !important;
}

#serenity-hub-panel.is-scrolling .theme-card::before,
#serenity-hub-panel.is-scrolling .theme-icon-img,
#serenity-hub-panel.is-scrolling .breath-world__art {
    transition: none !important;
}

#serenity-hub-panel.is-scrolling .theme-card::before {
    opacity: 0;
}

#serenity-hub-panel.is-scrolling .theme-card:hover .theme-icon-img {
    scale: none;
}

/* =================================================================================
 * Controls overlay (/ or Select in Serenity Mode): a title card over the world, in the
 * breathing guide's language. No panel: the world dims beneath an even night, the words sit
 * centred on it, and the eyebrow wears the theme's own light (--serenity-accent). A press
 * anywhere, the key again, or ten seconds, and it is gone.
 * ================================================================================ */
#gamepad-hints-overlay.gamepad-hints {
    --hint-accent: var(--serenity-accent, var(--sb-mint-rgb));
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: grid;
    align-content: center;
    justify-items: center;
    width: auto;
    max-width: none;
    max-height: none;
    overflow-y: auto;
    box-sizing: border-box;
    padding: 56px 24px;
    border: 0;
    border-radius: 0;
    background:
        radial-gradient(ellipse 60% 50% at 50% 30%, rgba(var(--hint-accent), 0.08), transparent 70%),
        radial-gradient(ellipse 80% 80% at 50% 50%, rgba(7, 6, 22, 0.84), rgba(7, 6, 22, 0.72));
    box-shadow: none;
    color: rgb(var(--sb-cream-rgb));
    font-family: var(--sb-font-text);
    cursor: default;
    opacity: 0;
    translate: 0 0;
    transform: none;
    scrollbar-width: none;
    transition: opacity 0.45s ease;
    -webkit-font-smoothing: antialiased;
}

#gamepad-hints-overlay.gamepad-hints.visible { opacity: 1; }

#gamepad-hints-overlay .hint-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 34px;
    text-align: center;
}

#gamepad-hints-overlay .hint-head .sb-eyebrow { color: rgb(var(--hint-accent)); }
#gamepad-hints-overlay .hint-head .sb-eyebrow::before { background: currentColor; }

#gamepad-hints-overlay .hint-heading {
    margin: 0;
    font: 700 clamp(26px, 2.8vw, 38px) / 1.1 var(--sb-font-display);
    letter-spacing: -0.01em;
    text-shadow: 0 2px 22px rgba(0, 0, 0, 0.7);
}

#gamepad-hints-overlay .hint-section {
    width: min(760px, 92vw);
}

#gamepad-hints-overlay .hint-section + .hint-section {
    margin-top: 30px;
    padding-top: 0;
    border-top: 0;
}

#gamepad-hints-overlay .hint-title {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0 0 16px;
    padding: 0;
    border: 0;
    color: rgba(var(--sb-cream-rgb), 0.5);
    font: 600 0.5625rem / 1 var(--sb-font-display);
    letter-spacing: 0.22em;
    text-align: left;
    text-transform: uppercase;
}

/* A hairline runs from the section's name to the edge, as the guide's bar does. */
#gamepad-hints-overlay .hint-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, rgba(var(--sb-cream-rgb), 0.18), transparent);
}

#gamepad-hints-overlay .hint-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 40px;
    margin: 0;
    padding: 0;
    list-style: none;
}

#gamepad-hints-overlay .hint-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 0;
    border-radius: 0;
    background: none;
    color: rgba(var(--sb-cream-rgb), 0.84);
    font: 500 0.9375rem / 1.3 var(--sb-font-text);
    text-shadow: 0 1px 10px rgba(0, 0, 0, 0.7);
    transform: none;
}

#gamepad-hints-overlay .hint-keys {
    display: inline-flex;
    flex: none;
    justify-content: flex-end;
    gap: 4px;
    min-width: 64px;
}

#gamepad-hints-overlay .sb-kbd {
    min-width: 30px;
    height: 28px;
    padding: 0 8px;
    color: rgb(var(--sb-cream-rgb));
    font: 600 0.6875rem / 1 var(--sb-font-display);
    letter-spacing: 0.04em;
    text-transform: none;
}

#gamepad-hints-overlay .hint-footer {
    margin: 34px 0 0;
    padding: 0;
    border-top: 0;
    color: rgba(var(--sb-cream-rgb), 0.5);
    font: 500 0.8125rem / 1.4 var(--sb-font-text);
    font-style: normal;
    text-align: center;
}

#gamepad-hints-overlay .hint-footer .sb-kbd {
    margin: 0 3px;
    vertical-align: middle;
}

@media (max-width: 640px) {
    #gamepad-hints-overlay.gamepad-hints {
        align-content: start;
        padding: calc(var(--sb-play-inset, 16px) + var(--sb-play-tile, 40px) + 24px) 20px 32px;
    }

    #gamepad-hints-overlay .hint-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
    }

    #gamepad-hints-overlay .hint-item { font-size: 0.875rem; }
}

/* =================================================================================
 * Sukha sessions entry (#sukha-sessions-btn): never shown. Sukha sessions live in the Hub's
 * own tab (one tap on the lotus in the play rail) and in the main menu's list; a big
 * pill beside the in-game controls crowded every mode and sat over the versus chat.
 * The button stays as the Hub's programmatic route (the main menu falls back to it).
 * ================================================================================ */
#sukha-sessions-btn.sukha-sessions-entry {
    display: none;
}

/* =================================================================================
 * Sukha sessions tab: the opening row (SessionsTab.js; the catalogue itself is styled in
 * breathwork-sessions.css). The title stands beside its lede, or, once you practise,
 * beside your practice, instead of above them; on a shorter sheet the pictures give
 * height back. The first session's Begin is in view as the tab opens, at 1280 x 720 as
 * at 1600 x 900.
 * ================================================================================ */
@media (min-width: 761px) {
    #serenity-hub-panel .sukha {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        column-gap: clamp(24px, 3.4vw, 48px);
        row-gap: 18px;
    }

    #serenity-hub-panel .sukha > * {
        grid-column: 1 / -1;
        min-width: 0;
    }

    /* Eyebrow and title on the left, the lede on the right, on one baseline. */
    #serenity-hub-panel .sukha > .sukha__intro {
        display: grid;
        grid-template-columns: subgrid;
        align-items: end;
        max-width: none;
    }

    #serenity-hub-panel .sukha__intro .sb-eyebrow {
        grid-column: 1;
        grid-row: 1;
        justify-self: start;
    }

    #serenity-hub-panel .sukha__intro h2 {
        grid-column: 1;
        grid-row: 2;
        max-width: 26ch;
        margin: 12px 0 0;
    }

    #serenity-hub-panel .sukha__intro p {
        grid-column: 2;
        grid-row: 1 / span 2;
        max-width: 54ch;
        margin: 0;
        padding-bottom: 2px;
    }

    /* Returning: your practice takes the lede's place (the cards say how the rest open). */
    #serenity-hub-panel .sukha:has(> .sukha__practice:not([hidden])) > .sukha__intro {
        grid-column: 1;
        grid-template-columns: minmax(0, 1fr);
    }

    #serenity-hub-panel .sukha:has(> .sukha__practice:not([hidden])) .sukha__intro p {
        display: none;
    }

    #serenity-hub-panel .sukha > .sukha__practice:not([hidden]) {
        grid-column: 2;
        grid-row: 1;
        align-self: end;
        gap: 12px 24px;
        padding: 14px 18px;
    }
}

/* The session's world as a band: its full 16:7 where the sheet is tall, shorter on a
   laptop-height sheet. */
#serenity-hub-panel .sukha-card__art {
    max-height: max(120px, calc(46vh - 196px));
}

@media (max-height: 760px) and (min-width: 761px) {
    #serenity-hub-panel .sukha-card__body { gap: 6px; }
    #serenity-hub-panel .sukha-card h3 { margin-top: 4px; }
    #serenity-hub-panel .sukha-card__facts { margin: 6px 0 10px; }
}

/* Phones: one column; a tighter opening and a lower band keep Begin in view. */
@media (max-width: 760px) {
    #serenity-hub-panel .sukha { gap: 16px; }
    #serenity-hub-panel .sukha__intro h2 { margin: 10px 0 8px; font-size: 1.2rem; }
    #serenity-hub-panel .sukha__intro p { font-size: var(--sb-fs-small); line-height: 1.55; }
    #serenity-hub-panel .sukha-card__art { max-height: 120px; }
}

/* =================================================================================
 * Responsive
 * ================================================================================ */
@media (max-width: 1100px) {
    #serenity-hub-panel .music-tab {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-height: 760px) and (min-width: 701px) {
    #serenity-hub-panel { --hub-pad-top: 18px; }
    #serenity-hub-panel .hub-panel-header { padding-top: 20px; padding-bottom: 14px; }
    #serenity-hub-panel .hub-heading { gap: 9px; }
    #serenity-hub-panel .hub-tab { min-height: 46px; }
    /* A short sheet: the featured world gives height back to the grid. */
    #serenity-hub-panel .themes-lib__hero { min-height: 188px; }
    #serenity-hub-panel .themes-lib__hero-art { min-height: 160px; }
    #serenity-hub-panel .themes-lib__hero-body { gap: 9px; padding-top: 18px; padding-bottom: 18px; }
    #serenity-hub-panel .themes-lib__bar { margin-bottom: 20px; }
}

/* Phones: the sheet fills the screen, hints fold away (touch has no keys). */
@media (max-width: 700px) {
    #serenity-hub-panel {
        --hub-pad-x: 16px;
        --hub-pad-top: 16px;
    }

    #serenity-hub-panel.serenity-hub-panel {
        width: calc(100vw - 16px);
        height: calc(100vh - 16px);
        height: calc(100dvh - 16px);
        border-radius: var(--sb-r-lg);
    }

    #serenity-hub-panel .hub-panel-header {
        align-items: center;
        padding: 18px var(--hub-pad-x) 12px;
    }

    /* Some tabs' eyebrows wrap to two lines here. Room for both, filled from the bottom,
       keeps the title and the tab strip still as the tabs change. */
    #serenity-hub-panel .hub-heading {
        gap: 9px;
        justify-content: flex-end;
        min-height: calc(var(--sb-fs-label) * 3 + 9px + var(--sb-fs-title) * 1.05);
    }

    #serenity-hub-panel .hub-close-btn {
        width: 40px;
        padding: 0;
        justify-content: center;
    }

    #serenity-hub-panel .hub-close-btn__label,
    #serenity-hub-panel .hub-close-btn .sb-kbd {
        display: none;
    }

    /* Words only, so all four tabs fit a phone's width. */
    #serenity-hub-panel .hub-tabs { gap: 0; }

    #serenity-hub-panel .hub-tab {
        min-height: 46px;
        padding: 0 9px 2px;
        font-size: 0.5625rem;
        letter-spacing: 0.12em;
    }

    #serenity-hub-panel .hub-tab::after { left: 9px; right: 9px; }
    #serenity-hub-panel .hub-tab__icon { display: none; }

    /* The featured world stacks: its art above its words (as the Breathing tab does). */
    #serenity-hub-panel .themes-lib__hero { grid-template-columns: minmax(0, 1fr); min-height: 0; }
    #serenity-hub-panel .themes-lib__hero-art { min-height: 150px; }
    /* A wide, low frame: a little more than its width covers its diagonal. */
    #serenity-hub-panel .themes-lib__hero-pic { width: 118%; }

    #serenity-hub-panel .themes-lib__hero-art::after {
        background: linear-gradient(180deg, rgba(19, 16, 44, 0) 50%, rgba(19, 16, 44, 0.96) 100%);
    }

    #serenity-hub-panel .themes-lib__hero-body { gap: 10px; padding: 4px 18px 18px; }

    /* The bar: which world on top, then its action across the width and Random as a tile. */
    #serenity-hub-panel .themes-lib__bar { flex-wrap: wrap; gap: 10px; margin-bottom: 20px; padding: 10px 12px 12px; }
    #serenity-hub-panel .themes-lib__line { order: -1; flex: 1 1 100%; }
    #serenity-hub-panel .themes-lib__use,
    #serenity-hub-panel .themes-lib__explore { flex: 1 1 0; min-width: 0; }
    #serenity-hub-panel .random-theme-btn { width: 44px; padding: 0; }
    #serenity-hub-panel .random-theme-btn .btn-text { display: none; }

    /* The theme that is on needs no button: one row, its name. */
    #serenity-hub-panel .themes-lib__bar[data-state='current'] .themes-lib__use { display: none; }
    #serenity-hub-panel .themes-lib__bar[data-state='current'] .themes-lib__line {
        position: relative;
        order: 0;
        flex: 1 1 0;
    }

    #serenity-hub-panel .themes-control-bar {
        flex-wrap: wrap;
        gap: 10px;
    }

    #serenity-hub-panel .themes-search-wrap {
        flex: 1 1 100%;
    }

    /* Three equal cells across the width; on the narrowest phones a label takes two lines. */
    #serenity-hub-panel .theme-collection__filters { display: flex; flex: 1 1 100%; min-width: 0; }

    #serenity-hub-panel .collection-filter {
        flex: 1 1 0;
        min-width: 0;
        padding: 4px 5px;
        line-height: 1.3;
        letter-spacing: 0.08em;
        white-space: normal;
    }

    /* One scrolling row of chips instead of four wrapped ones. */
    #serenity-hub-panel .category-filter {
        flex-wrap: nowrap;
        margin: 0 calc(-1 * var(--hub-pad-x));
        padding: 0 var(--hub-pad-x) 2px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    #serenity-hub-panel .category-filter::-webkit-scrollbar { display: none; }

    #serenity-hub-panel .themes-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px 10px;
    }

    #serenity-hub-panel .theme-info { padding: 10px 12px 12px; }

    /* The playing track stacks: its art above its controls. */
    #serenity-hub-panel .now-playing-card { grid-template-columns: minmax(0, 1fr); }
    #serenity-hub-panel .album-art { min-height: 132px; }
    #serenity-hub-panel .album-art__pic { width: 118%; }

    #serenity-hub-panel .album-art::after {
        background: linear-gradient(180deg, rgba(19, 16, 44, 0) 45%, rgba(19, 16, 44, 0.96) 100%);
    }

    #serenity-hub-panel .track-controls-container { padding: 4px 18px 18px; }
    #serenity-hub-panel .vinyl-disc .cs-icon { width: 30px; height: 30px; }
    #serenity-hub-panel .main-controls { justify-content: center; }
    #serenity-hub-panel .music-collection-detail { flex-direction: column; align-items: stretch; padding: 14px; }
    #serenity-hub-panel .music-collection-detail__art { width: 100%; aspect-ratio: 16 / 7; }

    #serenity-hub-panel .volume-section { padding: 18px; }

    #serenity-hub-panel .playlist-container { grid-template-columns: minmax(0, 1fr); }

    #serenity-hub-panel .theme-param-row { grid-template-columns: minmax(0, 1fr) 4rem; }
    #serenity-hub-panel .theme-param-row .theme-param-input { grid-column: 1 / -1; grid-row: 2; }
}

/* A very short sheet (a phone on its side): a stuck bar would take half of what is left, so it
   leaves with the page. The chosen card's own "Press again to use" still applies a theme. */
@media (max-height: 480px) {
    #serenity-hub-panel .themes-lib__bar { position: static; }
}

@media (hover: none) and (pointer: coarse) {
    #serenity-hub-panel .hub-footer { display: none; }
    #serenity-hub-panel .hub-close-btn .sb-kbd { display: none; }
}

/* ---- Reduced motion: keep the lock, drop the travel and the breathing -------------- */
@media (prefers-reduced-motion: reduce) {
    #serenity-hub-panel.serenity-hub-panel,
    #serenity-hub-panel.serenity-hub-panel.open {
        translate: 0 0;
    }

    #serenity-hub-panel .tab-panel.active,
    #serenity-hub-panel .vinyl-disc.spinning .album-art__pic,
    #gamepad-hints-overlay.gamepad-hints.visible {
        animation: none !important;
    }

    #serenity-hub-panel .hub-tab::after,
    #serenity-hub-panel .theme-card,
    #serenity-hub-panel .theme-card::before,
    #serenity-hub-panel .theme-icon-img,
    #serenity-hub-panel .playlist-item,
    #serenity-hub-panel .control-btn,
    #gamepad-hints-overlay.gamepad-hints {
        transition-duration: 1ms !important;
    }

    #serenity-hub-panel .theme-card:hover .theme-icon-img {
        scale: none;
    }
}

@media (prefers-contrast: more) {
    #serenity-hub-panel.serenity-hub-panel::before { border-color: rgba(var(--sb-cream-rgb), 0.6); }
    #serenity-hub-panel .theme-card,
    #serenity-hub-panel .category-pill,
    #serenity-hub-panel .playlist-item { border-color: rgba(var(--sb-cream-rgb), 0.4); }
}

@media print {
    .serenity-hub-backdrop,
    #serenity-hub-panel,
    #gamepad-hints-overlay,
    #sukha-sessions-btn {
        display: none !important;
    }
}

/* ---- Themes tab: Serenity Mode's drift and rest (src/ui/serenity-hub/serenity-drift-panel.js)
   Shown only while Serenity Mode runs. The same choices as the world bar's chips, as pills
   a controller can reach. */
#serenity-hub-panel .themes-lib__drift {
    display: grid;
    gap: 12px;
    margin: 0 0 26px;
    padding: 16px 18px;
    border: 1px solid var(--sb-line);
    border-radius: var(--hub-card-r, var(--sb-r-md));
    background: rgba(var(--sb-cream-rgb), 0.02);
}

#serenity-hub-panel .themes-lib__drift[hidden] { display: none; }

#serenity-hub-panel .themes-lib__drift-eyebrow { margin: 0; }

#serenity-hub-panel .themes-lib__drift-row {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto;
    align-items: center;
    gap: 10px 18px;
}

#serenity-hub-panel .themes-lib__drift-label {
    display: grid;
    gap: 3px;
    margin: 0;
    color: var(--sb-text);
    font: 600 var(--sb-fs-body) / 1.3 var(--sb-font-text);
}

#serenity-hub-panel .themes-lib__drift-label small {
    color: var(--sb-text-muted);
    font: 500 var(--sb-fs-small) / 1.4 var(--sb-font-text);
}

#serenity-hub-panel .themes-lib__drift-options {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

#serenity-hub-panel .themes-lib__drift-choice {
    min-height: 34px;
    padding: 0 11px;
    border-radius: 9px;
    border: 1px solid var(--sb-line);
    background: rgba(var(--sb-cream-rgb), 0.025);
    color: var(--sb-text-muted);
    letter-spacing: 0.08em;
    cursor: pointer;
    transition:
        color var(--sb-dur-2) var(--sb-ease-lock),
        background var(--sb-dur-2) var(--sb-ease-lock),
        border-color var(--sb-dur-2) var(--sb-ease-lock);
}

#serenity-hub-panel .themes-lib__drift-choice:hover {
    color: var(--sb-text);
    border-color: var(--sb-line-strong);
    background: rgba(var(--sb-cream-rgb), 0.06);
}

#serenity-hub-panel .themes-lib__drift-choice[aria-pressed='true'] {
    color: var(--sb-text);
    border-color: rgba(var(--sb-mint-rgb), 0.55);
    background: rgba(var(--sb-mint-rgb), 0.14);
}

#serenity-hub-panel .themes-lib__drift-choice:focus-visible {
    outline: 2px solid rgba(var(--sb-cream-rgb), 0.82);
    outline-offset: 3px;
}

@media (max-width: 720px) {
    #serenity-hub-panel .themes-lib__drift-row { grid-template-columns: 1fr; }
    #serenity-hub-panel .themes-lib__drift-options { justify-content: flex-start; }
}
