/* =============================================================================
   MUZOOI DESIGN SYSTEM
   One stylesheet, every primitive. Flat naming. No !important.
   Drop this on a page with the font links and you have the whole system.
   ========================================================================== */

/* -----------------------------------------------------------------------------
   TOKENS - light theme (default)
   -------------------------------------------------------------------------- */
:root {
    /* COLORS - brand
       -subtle is now CALCULATED as a very light wash over the surface,
       so hovers and backgrounds stay barely tinted, not dark. */
    --primary:          #40026f;
    --primary-bold:     #23003e;
    --primary-subtle:   color-mix(in srgb, var(--primary) 7%, var(--surface));
    --primary-muted:    color-mix(in srgb, var(--primary) 55%, var(--surface));
    --primary-reverse:  #ffffff;

    --secondary:          #f40252;
    --secondary-bold:     #870030;
    --secondary-subtle:   color-mix(in srgb, var(--secondary) 7%, var(--surface));
    --secondary-muted:    color-mix(in srgb, var(--secondary) 55%, var(--surface));
    --secondary-reverse:  #ffffff;

    /* Brand neutrals - two warmer, brand-tinted neutrals that sit between
       the pure brand and the plain grey text/border tokens.
       brand-muted: a desaturated brand grey for secondary text and dividers.
       brand-neutral: a brand-tinted off-surface for cards that still feel on-brand. */
    --brand-muted:    #8a7890;
    --brand-neutral:  #f5f2f8;

    /* COLORS - feature accents (bold/subtle are CALCULATED from the base) */
    --feature-1:         #d4ff4b;
    --feature-1-reverse: #1f2937;
    --feature-1-bold:    color-mix(in srgb, var(--feature-1) 85%, black);
    --feature-1-subtle:  color-mix(in srgb, var(--feature-1) 22%, var(--background));

    --feature-2:         #ffb3d1;
    --feature-2-reverse: #1f2937;
    --feature-2-bold:    color-mix(in srgb, var(--feature-2) 85%, black);
    --feature-2-subtle:  color-mix(in srgb, var(--feature-2) 22%, var(--background));

    --feature-3:         #a8d8ff;
    --feature-3-reverse: #1f2937;
    --feature-3-bold:    color-mix(in srgb, var(--feature-3) 85%, black);
    --feature-3-subtle:  color-mix(in srgb, var(--feature-3) 22%, var(--background));

    --feature-4:         #ffd93d;
    --feature-4-reverse: #1f2937;
    --feature-4-bold:    color-mix(in srgb, var(--feature-4) 85%, black);
    --feature-4-subtle:  color-mix(in srgb, var(--feature-4) 22%, var(--background));

    /* COLORS - intents (subtles calculated, very light) */
    --success:         #10b981;
    --success-subtle:  color-mix(in srgb, var(--success) 10%, var(--surface));
    --success-reverse: #ffffff;
    --warning:         #f59e0b;
    --warning-subtle:  color-mix(in srgb, var(--warning) 10%, var(--surface));
    --warning-reverse: #1f2937;
    --danger:          #ef4444;
    --danger-subtle:   color-mix(in srgb, var(--danger) 10%, var(--surface));
    --danger-reverse:  #ffffff;
    --info:            #3b82f6;
    --info-subtle:     color-mix(in srgb, var(--info) 10%, var(--surface));
    --info-reverse:    #ffffff;

    /* COLORS - surfaces */
    --surface:         #ffffff;
    --surface-subtle:  #f4f4f4;
    --background:      #f4efe6;
    --background-subtle: #f8f5f0;

    /* COLORS - text and lines */
    --foreground:       #1f2937;
    --foreground-muted: #6b7280;
    --border:           #e6e6e6;

    /* TYPOGRAPHY
       Only two type families: DISPLAY and BODY.
       DISPLAY is used for every "label-for-content" style - display-xl, display-lg,
       heading-1 to 4, page / section / card / tile / overlay / empty-state / mood /
       vibe / artist / album / playlist / blog / workshop / comp / event / user /
       calendar / search-result titles and names. Every title and heading uses the
       SAME family so the system reads as one voice.
       BODY is used for running text, labels, meta, captions, help text and chips.
       MONO is for code, tokens and technical values.
       --font-heading is kept as an alias for --font-display so authors can reach
       for the semantically obvious name; the two must always resolve to the same
       family. */
    --font-display: "Archivo", system-ui, sans-serif;
    --font-heading: var(--font-display);
    --font-body:    "Bricolage Grotesque", system-ui, -apple-system, sans-serif;
    --font-mono:    ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* Font scale - multiplier applied to every type style's size.
       1 is the default. 0.9 shrinks everything, 1.1 enlarges proportionally.
       The Theme editor Typography tab exposes a slider for this. */
    --font-scale:   1;

    /* SPACING */
    --space-xs:  4px;
    --space-sm:  8px;
    --space-md:  12px;
    --space-lg:  16px;
    --space-xl:  24px;
    --space-2xl: 40px;
    --space-3xl: 64px;

    /* Z-INDEX LAYERS
       A short, strictly-ordered stack, so a rule never has to guess what sits
       above or below it. Named by role, not by number; the numbers leave room
       between layers for future additions. */
    --z-base:     1;      /* hero content, chart overlays, anything on top of its own block */
    --z-sticky:   50;     /* sticky page chrome, menu dropdowns */
    --z-tooltip:  100;    /* tooltips and popovers that must clear nearby chrome */
    --z-overlay:  10000;  /* modal backdrop + dialog body */
    --z-toast:    11000;  /* toasts, floating affordances, theme editor */
    --z-escape:   12000;  /* escape-hatch floating UI that must beat the theme editor */

    /* RADIUS */
    --radius-xs:     4px;
    --radius-sm:     8px;
    --radius-md:     12px;
    --radius-lg:     16px;
    --radius-xl:     24px;
    --radius-pill:   999px;
    --radius-circle: 50%;

    /* PER-ELEMENT radius - each family reads from its own var, so you can
       reshape one family (buttons, inputs, nav items) without touching the rest.
       Each defaults to a sensible token above. Override on :root or on a parent
       to re-skin a scope. The sticky Shape panel in the showcase writes to these. */
    --btn-radius:       var(--radius-pill);
    --field-radius:     var(--radius-pill);
    --nav-item-radius:  var(--radius-pill);
    --chip-radius:      var(--radius-pill);
    --badge-radius:     var(--radius-pill);
    --tag-radius:       var(--radius-pill);
    --card-radius:      var(--radius-lg);
    --section-radius:   var(--radius-xl);
    --icon-chip-radius: 50%;
    --tile-radius:      var(--radius-md);
    --item-radius:      var(--radius-md);
    --toolbar-radius:    var(--radius-pill);
    --tabs-radius:       var(--radius-pill);
    --tab-radius:        var(--radius-pill);
    --table-radius:      var(--radius-lg);
    --pagination-radius: var(--radius-pill);
    --thumb-radius:      var(--radius-sm);  /* small inline thumbnails and previews */
    --cover-radius:      var(--radius-md);  /* big media covers inside cards */
    --modal-radius:      var(--radius-xl);  /* overlay-modal + spotlight panels */
    --alert-radius:      var(--radius-md);  /* alert strips, toasts share this */
    --menu-radius:       var(--radius-md);  /* dropdown menus */

    /* PER-ELEMENT visual tokens
       Every primitive reads bg, text, border, padding, hover from these.
       The Theme Editor Advanced tab lets you set any of them without
       touching the global palette. Each defaults to a sensible global token,
       so overriding global colours cascades automatically unless you pin
       a per-element value. */
    /* Button - base */
    --btn-bg:            var(--primary);
    --btn-color:         var(--primary-reverse);
    --btn-border-color:  transparent;
    --btn-border-width:  1px;
    --btn-padding-x:     20px;
    --btn-height:        44px;
    --btn-bg-hover:      var(--primary-bold);
    --btn-color-hover:   var(--primary-reverse);
    /* Button variants - each a (bg, color, hover-bg, hover-color) quartet */
    --btn-primary-bg:          var(--primary);
    --btn-primary-color:       var(--primary-reverse);
    --btn-primary-bg-hover:    var(--primary-bold);
    --btn-primary-color-hover: var(--primary-reverse);
    --btn-secondary-bg:          var(--secondary);
    --btn-secondary-color:       var(--secondary-reverse);
    --btn-secondary-bg-hover:    var(--secondary-bold);
    --btn-secondary-color-hover: var(--secondary-reverse);
    --btn-success-bg:          var(--success);
    --btn-success-color:       var(--success-reverse);
    --btn-success-bg-hover:    color-mix(in srgb, var(--success) 80%, black);
    --btn-success-color-hover: var(--success-reverse);
    --btn-warning-bg:          var(--warning);
    --btn-warning-color:       var(--warning-reverse);
    --btn-warning-bg-hover:    color-mix(in srgb, var(--warning) 80%, black);
    --btn-warning-color-hover: var(--warning-reverse);
    --btn-danger-bg:          var(--danger);
    --btn-danger-color:       var(--danger-reverse);
    --btn-danger-bg-hover:    color-mix(in srgb, var(--danger) 80%, black);
    --btn-danger-color-hover: var(--danger-reverse);
    --btn-info-bg:          var(--info);
    --btn-info-color:       var(--info-reverse);
    --btn-info-bg-hover:    color-mix(in srgb, var(--info) 80%, black);
    --btn-info-color-hover: var(--info-reverse);
    --btn-outline-bg:           transparent;
    --btn-outline-color:        var(--primary);
    --btn-outline-border-color: var(--primary);
    --btn-outline-bg-hover:     var(--primary-subtle);
    --btn-outline-color-hover:  var(--primary);
    --btn-ghost-bg:           transparent;
    --btn-ghost-color:        var(--foreground);
    --btn-ghost-bg-hover:     var(--surface-subtle);
    --btn-ghost-color-hover:  var(--foreground);
    /* Field */
    --field-bg:          var(--surface);
    --field-color:       var(--foreground);
    --field-border-color:var(--border);
    --field-border-width:1px;
    --field-padding-x:   16px;
    --field-height:      44px;
    --field-focus-color: var(--primary);
    --field-bg-hover:    var(--surface-subtle);
    /* Card */
    --card-bg:           var(--surface);
    --card-color:        var(--foreground);
    --card-border-color: var(--border);
    --card-border-width: 1px;
    --card-padding:      16px;
    /* Section */
    --section-bg:        var(--surface);
    --section-color:     var(--foreground);
    --section-border-color: var(--border);
    --section-border-width: 1px;
    /* Chip */
    --chip-bg:           var(--surface-subtle);
    --chip-color:        var(--foreground-muted);
    --chip-padding-x:    10px;
    --chip-height:       24px;
    /* Nav item */
    --nav-item-bg:         transparent;
    --nav-item-color:      var(--foreground);
    --nav-item-bg-hover:   var(--surface-subtle);
    --nav-item-color-hover:var(--foreground);
    --nav-item-padding-x:  16px;
    --nav-item-height:     var(--btn-height);   /* nav items and header buttons are always one height */
    /* Item */
    --item-bg:            var(--surface);
    --item-color:         var(--foreground);
    --item-border-color:  var(--border);
    --item-border-width:  1px;
    --item-padding:       12px;
    --item-bg-hover:      var(--primary-subtle);

    /* Element tokens (v316): everything Theme > Elements edits. Each holds the
       value the component used before, so nothing changes until a theme
       overrides it. */
    --btn-font-size: 15px;
    --btn-font-weight: 650;
    --field-font-size: 15px;
    --navbar-bg: var(--surface);
    --navbar-opacity: 72%;
    --navbar-color: var(--foreground);
    --navbar-border-color: var(--border);
    --navbar-padding-x: 16px;
    --navbar-padding-y: 10px;
    --nav-item-font-size: 15px;
    --nav-item-font-weight: 600;
    --nav-item-active-bg: var(--primary);
    --nav-item-active-color: var(--primary-reverse);
    --footer-radius: var(--radius-lg);
    --footer-bg: var(--primary);
    --footer-color: var(--primary-reverse);
    --footer-padding: 28px;
    --chip-font-size: 11px;
    --chip-font-weight: 700;
    --toolbar-bg: var(--surface);
    --toolbar-border-color: var(--border);
    --toolbar-padding: 3px;
    --toolbar-gap: 4px;
    --toolbar-icon-size: 42px;
    --toolbar-icon-bg: var(--surface-subtle);
    --tab-color: var(--foreground-muted);
    --tab-hover-bg: color-mix(in srgb, var(--primary) 8%, transparent);
    --tab-active-bg: var(--primary);
    --tab-active-color: var(--primary-reverse);
    --tab-padding-x: 14px;
    --tab-padding-y: 6px;
    --tab-font-size: 13px;
    --tab-font-weight: 600;
    --tile-bg: var(--surface);
    --tile-padding: 12px;
    --tile-gap: var(--section-gap);   /* v328: between stat tiles; follows Layout > Space between sections */
    --alert-padding-x: 16px;
    --alert-padding-y: 14px;
    --alert-font-size: 14px;
    --table-head-bg: var(--surface-subtle);
    --table-head-color: var(--foreground-muted);
    --table-head-size: 12px;
    --table-cell-padding-x: 14px;
    --table-cell-padding-y: 12px;
    --table-border-color: var(--border);
    --table-row-hover: var(--primary-subtle);
    --menu-bg: var(--surface);
    --control-label-width: 220px;   /* the label column of every control panel */

    /* SIZE */
    --size-xs:  16px;
    --size-sm:  24px;
    --size-md:  32px;
    --size-lg:  48px;
    --size-xl:  64px;
    --size-2xl: 96px;
    --size-3xl: 128px;

    /* LAYOUT */
    --page-width:        1200px;   /* card-grid pages: 4 x 280px tiles max */
    --header-top:         16px;    /* space above the navbar pill */
    --header-height:      66px;    /* navbar pill height (min-height, so it never varies by page) */
    --header-space:       calc(var(--header-top) + var(--header-height));
    --page-top-gap:       24px;    /* space between the navbar and the first section */
    --page-padding:    24px;
    --section-gap:     24px;
    --section-padding: 24px;

    /* Vertical rhythm inside content */
    --paragraph-gap: 14px;   /* between <p> and other text blocks */
    --item-gap:      10px;   /* between items in a .section-body */

    /* SHADOWS - calculated against the foreground so dark theme stays subtle */
    --shadow-xs: 0 1px 2px color-mix(in srgb, var(--foreground) 8%,  transparent);
    --shadow-sm: 0 1px 3px color-mix(in srgb, var(--foreground) 12%, transparent);
    --shadow-md: 0 8px 24px color-mix(in srgb, var(--foreground) 10%, transparent);
    --shadow-lg: 0 24px 80px color-mix(in srgb, var(--foreground) 30%, transparent);

    /* OVERLAY backdrop - the dim behind modals */
    --overlay-backdrop: color-mix(in srgb, var(--foreground) 55%, transparent);

    /* ON-MEDIA - always-readable text and chip on photo or dark-gradient covers */
    --on-media:         #ffffff;
    --on-media-subtle:  color-mix(in srgb, #ffffff 20%, transparent);

    color-scheme: light;
}

/* RADIUS THEMING - overrides via <html data-radius=""> */
[data-radius="none"] {
    --radius-xs: 0; --radius-sm: 0; --radius-md: 0; --radius-lg: 0; --radius-xl: 0;
}
[data-radius="sm"] {
    --radius-xs: 2px; --radius-sm: 4px; --radius-md: 6px; --radius-lg: 10px; --radius-xl: 16px;
}
[data-radius="lg"] {
    --radius-xs: 6px; --radius-sm: 12px; --radius-md: 20px; --radius-lg: 28px; --radius-xl: 40px;
}

/* DENSITY THEMING - overrides via <html data-density=""> */
[data-density="compact"] {
    --page-padding:    16px;
    --section-gap:     16px;
    --section-padding: 16px;
    --item-gap:         6px;
    --paragraph-gap:   10px;
}
[data-density="cosy"] {
    --page-padding:    40px;
    --section-gap:     40px;
    --section-padding: 40px;
    --item-gap:        16px;
    --paragraph-gap:   20px;
}

/* DARK THEME - bases only; the -subtle tokens are calculated from these */
[data-theme="dark"] {
    --primary:          #a86cd6;
    --primary-bold:     #7e35b4;
    --primary-reverse:  #1a0030;

    --secondary:          #ff5e8a;
    --secondary-bold:     #c7004a;
    --secondary-reverse:  #2a0014;

    --brand-muted:   #a89aae;
    --brand-neutral: #221a28;

    --feature-1:         #b5e03f;
    --feature-2:         #ff8ebb;
    --feature-3:         #79b8ea;
    --feature-4:         #e6c233;

    --success:         #36cf9e;
    --success-reverse: #06201c;
    --warning:         #f5b547;
    --danger:          #ff7070;
    --danger-reverse:  #1a0808;
    --info:            #79a7f2;
    --info-reverse:    #06101e;

    --surface:           #1a1a1a;
    --surface-subtle:    #232323;
    --background:        #0b0b0c;
    --background-subtle: #141415;

    --foreground:       #f3f1ec;
    --foreground-muted: #999999;
    --border:           #2a2a2a;

    color-scheme: dark;
}

/* -----------------------------------------------------------------------------
   RESET / BASE
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--background);
    color: var(--foreground);
    font-family: var(--font-body);
    font-size: calc(15px * var(--font-scale));
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
/* Full-bleed banners use 100vw, which includes the scrollbar; clip the
   sideways overflow at the root rather than letting the page scroll. */
/* The page background is a setting (Settings > Branding > Page Background),
   emitted as --page-background by Theme::getPageBackgroundCSS(). Solid
   --background is the fallback and still paints <html> behind it. */
/* <body> is a full-height flex column: header, then <main> taking all the
   spare height, then the footer. On a short page the footer sits at the
   bottom of the window; on a long page it follows the content. A flex
   container also keeps the footer's bottom margin inside <body>, so the page
   background runs right to the bottom. */
body { display: flex; flex-direction: column; overflow-x: clip; min-height: 100vh; background: var(--page-background, var(--background)); }
body > .page-container { flex: 1 0 auto; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Paragraph rhythm - the DS opts in to this. */
.prose p + p,
.prose p + ul,
.prose p + ol,
.prose ul + p,
.prose ol + p,
.prose h2 + p,
.prose h3 + p { margin-top: var(--paragraph-gap); }
/* Headings and lists keep the same rhythm wherever prose sits (v330): a
   heading sits close to the text it introduces, with more room above it. */
.prose h2 { margin: 1.4em 0 0; }
.prose h3 { margin: 1.2em 0 0; }
.prose :is(h2, h3) + :is(p, ul, ol) { margin-top: 0.5em; }
.prose :is(ul, ol) { margin: 0; padding-left: 1.25em; }
.prose li + li { margin-top: 0.35em; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child  { margin-bottom: 0; }

/* Item rhythm - .stack puts item-gap between children */
.stack       { display: flex; flex-direction: column; gap: var(--item-gap); }
.stack-tight { gap: calc(var(--item-gap) / 2); }
.stack-loose { gap: calc(var(--item-gap) * 2); }
.inline      { display: flex; flex-direction: row;    gap: var(--item-gap); flex-wrap: wrap; align-items: center; }

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: var(--space-xl) 0;
}

::selection { background: var(--primary); color: var(--primary-reverse); }

/* -----------------------------------------------------------------------------
   FOCUS RING  - one accessible, theme-aware focus treatment for every
   interactive primitive in the DS. :focus-visible so it only shows on
   keyboard focus, not on mouse click. The outline sits OUTSIDE the element
   with a 2px offset so it never clips against a rounded corner, and is
   drawn in the primary colour so it reads as intentional on every surface.
   Applied via a single multi-selector block instead of being repeated on
   every component, so turning the ring off or restyling it is one edit.
   Form controls (input, select, textarea) get their own focus ring in the
   .field / .form-* rules, which uses a tinted box-shadow because the ring
   sits ON the chrome rather than around it. -------------------------- */
.btn:focus-visible,
.btn-icon:focus-visible,
.chip:focus-visible,
.nav-item:focus-visible,
.pagination a:focus-visible,
.pagination button:focus-visible,
.menu-item:focus-visible,
.overlay-close:focus-visible,
.tab-bar-action:focus-visible,
.song-action:focus-visible,
.vibe-action:focus-visible,
.footer-socials a:focus-visible,
.header-logo:focus-visible,
.breadcrumb a:focus-visible,
.card-song:focus-visible,
.card-album:focus-visible,
.card-artist:focus-visible,
.card-playlist:focus-visible,
.card-blog:focus-visible,
.card-workshop:focus-visible,
.card-mood:focus-visible,
.spotlight-filters .chip:focus-visible,
.color-select-trigger:focus-visible,
.color-select-option:focus-visible,
.color-picker-swatch:focus-visible,
.theme-preset:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* -----------------------------------------------------------------------------
   PAGE SHELL  .page-container, .header, .footer share this width contract
   -------------------------------------------------------------------------- */
.page-container {
    width: 100%;
    max-width: var(--page-width);
    margin: 0 auto;
    padding: var(--page-top-gap) var(--page-padding) 0;
    display: flex;
    flex-direction: column;
    gap: var(--section-gap);
}
/* A group of sections inside the page (a form that spans several sections,
   content that loads in later) keeps the same vertical rhythm as the page. */
.page-stack { display: flex; flex-direction: column; gap: var(--section-gap); }
/* A DS tab panel ([data-tab-panel]) is a page-stack too, so sections and rows
   inside a tab keep the page rhythm without each page adding a wrapper. */
[data-tab-panel] { display: flex; flex-direction: column; gap: var(--section-gap); min-width: 0; }
[data-tab-panel][hidden] { display: none; }

/* SECTION ROW - sections side by side. Same gap as the vertical rhythm, every
   section in the row stretches to the tallest (grid align-items: stretch +
   .section is a flex column whose .section-body takes the slack). Two columns
   by default, .section-row-3 for three; both drop to one column on phones. */
.section-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--section-gap);
    align-items: stretch;
}
.section-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 960px) { .section-row-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .section-row, .section-row-3 { grid-template-columns: 1fr; } }

/* -----------------------------------------------------------------------------
   HEADER  .header - navbar pill at the top of every page
   -------------------------------------------------------------------------- */
.header {
    width: 100%;
    max-width: var(--page-width);
    margin: var(--header-top) auto 0;
    padding: 0 var(--page-padding);
    position: sticky;            /* pinned: stays at the top while the page scrolls */
    top: var(--header-top);
    z-index: var(--z-sticky);    /* sits over the page and a full-bleed hero */
}
/* The navbar pill shape follows its own --navbar-radius control so the
   top-of-page chrome can be reshaped independently of nav items inside it.
   Default is pill (soft, floating) but a square or rounded shape is one
   token change away. */
.header-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: var(--header-height);
    box-sizing: border-box;
    padding: var(--navbar-padding-y) var(--navbar-padding-x);
    background: color-mix(in srgb, var(--navbar-bg) var(--navbar-opacity), transparent);
    color: var(--navbar-color);
    border: 1px solid var(--navbar-border-color);
    border-radius: var(--navbar-radius, var(--radius-pill));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.header-logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font: 800 18px/1 var(--font-display);
    color: var(--navbar-color);
}
.header-logo .emblem {
    width: 28px; height: 28px;
    border-radius: var(--radius-circle);
    background: var(--secondary);
    color: var(--secondary-reverse);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: 900 14px/1 var(--font-display);
}
.header-nav   { display: flex; align-items: center; gap: 4px; flex: 1; justify-content: center; }
.header-right { display: flex; align-items: center; gap: 8px; }

/* -----------------------------------------------------------------------------
   BUTTON  .btn
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    /* Buttons are as wide as their label, never stretched by a column flex or
       grid parent. A page that genuinely needs a wider button sets its width. */
    width: fit-content;
    max-width: 100%;
    height: var(--btn-height);
    padding: 0 var(--btn-padding-x);
    border: var(--btn-border-width) solid var(--btn-border-color);
    border-radius: var(--btn-radius);
    background: var(--btn-bg);
    color: var(--btn-color);
    font-family: inherit;
    font-size: var(--btn-font-size);
    font-weight: var(--btn-font-weight);
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 120ms, border-color 120ms, color 120ms, transform 120ms;
}
.btn:hover    { background: var(--btn-bg-hover); color: var(--btn-color-hover); text-decoration: none; }
.btn:active   { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Every variant carries a visible border matching its own background, so
   outline buttons sit on the same optical baseline as filled ones. Hover
   moves the border along with the background. */
.btn-primary        { background: var(--btn-primary-bg); color: var(--btn-primary-color); border-color: var(--btn-primary-bg); }
.btn-primary:hover  { background: var(--btn-primary-bg-hover); color: var(--btn-primary-color-hover); border-color: var(--btn-primary-bg-hover); }

.btn-secondary       { background: var(--btn-secondary-bg); color: var(--btn-secondary-color); border-color: var(--btn-secondary-bg); }
.btn-secondary:hover { background: var(--btn-secondary-bg-hover); color: var(--btn-secondary-color-hover); border-color: var(--btn-secondary-bg-hover); }

.btn-success       { background: var(--btn-success-bg); color: var(--btn-success-color); border-color: var(--btn-success-bg); }
.btn-success:hover { background: var(--btn-success-bg-hover); color: var(--btn-success-color-hover); border-color: var(--btn-success-bg-hover); }

.btn-warning       { background: var(--btn-warning-bg); color: var(--btn-warning-color); border-color: var(--btn-warning-bg); }
.btn-warning:hover { background: var(--btn-warning-bg-hover); color: var(--btn-warning-color-hover); border-color: var(--btn-warning-bg-hover); }

.btn-danger        { background: var(--btn-danger-bg); color: var(--btn-danger-color); border-color: var(--btn-danger-bg); }
.btn-danger:hover  { background: var(--btn-danger-bg-hover); color: var(--btn-danger-color-hover); border-color: var(--btn-danger-bg-hover); }

.btn-info       { background: var(--btn-info-bg); color: var(--btn-info-color); border-color: var(--btn-info-bg); }
.btn-info:hover { background: var(--btn-info-bg-hover); color: var(--btn-info-color-hover); border-color: var(--btn-info-bg-hover); }

.btn-outline       { background: var(--btn-outline-bg); color: var(--btn-outline-color); border-color: var(--btn-outline-border-color); }
.btn-outline:hover { background: var(--btn-outline-bg-hover); color: var(--btn-outline-color-hover); border-color: var(--btn-outline-border-color); }

/* Ghost keeps a border at the same width in the surface colour, so its
   footprint matches the others exactly. On hover the border tracks the bg. */
.btn-ghost       { background: var(--btn-ghost-bg); color: var(--btn-ghost-color); border-color: var(--btn-ghost-bg); }
.btn-ghost:hover { background: var(--btn-ghost-bg-hover); color: var(--btn-ghost-color-hover); border-color: var(--btn-ghost-bg-hover); }

.btn-sm        { height: 32px; padding: 0 14px; font-size: 13px; }
.btn-lg        { height: 56px; padding: 0 28px; font-size: 17px; }
.btn-icon      { width: var(--btn-height); padding: 0; border-radius: var(--radius-circle); font-size: 18px; }
/* Icons inside buttons scale with the button so the glyph is a consistent
   proportion of the button face (roughly 40%), not a tiny text-sized mark. */
.btn-icon > i, .btn-icon > svg { font-size: 18px; width: 18px; height: 18px; }
.btn-icon.btn-sm > i, .btn-icon.btn-sm > svg { font-size: 14px; width: 14px; height: 14px; }
.btn-icon.btn-lg > i, .btn-icon.btn-lg > svg { font-size: 22px; width: 22px; height: 22px; }
.btn > i, .btn > svg { font-size: inherit; }
.btn-icon.btn-sm { width: 32px; }
.btn-icon.btn-lg { width: 56px; }
/* An avatar in an icon button fills it, so the navbar account button is the
   same size and shape as the search and notification buttons beside it. */
.btn-icon > .avatar { width: 100%; height: 100%; border-radius: inherit; font-size: 16px; }

/* -----------------------------------------------------------------------------
   FORM-INPUT / FORM-SELECT / FORM-TEXTAREA  -  the base form chrome.
   These are the standalone equivalents of .field; use them when you want a
   plain input/select/textarea that still reads as a Muzooi field, without
   the .field wrapper.
   -------------------------------------------------------------------------- */
.form-input,
.form-select,
.form-textarea {
    display: block;
    width: 100%;
    height: var(--field-height);
    padding: 0 var(--field-padding-x);
    font-family: inherit;
    font-size: var(--field-font-size);
    line-height: 1;
    color: var(--field-color);
    background: var(--field-bg);
    border: var(--field-border-width) solid var(--field-border-color);
    border-radius: var(--field-radius);
    outline: none;
    transition: border-color 120ms, background 120ms, box-shadow 120ms;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
}
.form-input:hover,
.form-select:hover,
.form-textarea:hover { background: var(--field-bg-hover); }
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--field-focus-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--field-focus-color) 20%, transparent);
    background: var(--field-bg);
}
.form-input::placeholder,
.form-textarea::placeholder { color: var(--foreground-muted); }

/* Native date / time / datetime inputs render their content top-aligned by
   default because the browser lays the widget out via `display: inline-block`
   and ignores our line-height. Force the baseline to centre by matching the
   padding-block to the field-height, and reset the webkit padding so Safari
   does not add its own. */
.form-input[type="date"],
.form-input[type="time"],
.form-input[type="datetime-local"],
.form-input[type="month"],
.form-input[type="week"] {
    padding-top: 0;
    padding-bottom: 0;
    line-height: var(--field-height);
}
.form-input[type="date"]::-webkit-datetime-edit,
.form-input[type="time"]::-webkit-datetime-edit,
.form-input[type="datetime-local"]::-webkit-datetime-edit,
.form-input[type="month"]::-webkit-datetime-edit,
.form-input[type="week"]::-webkit-datetime-edit {
    padding: 0;
    line-height: var(--field-height);
}

.form-textarea {
    height: auto;
    min-height: 96px;
    padding: 12px 16px;
    line-height: 1.5;
    resize: vertical;
    /* Textareas render the SAME effective pixel radius as inputs. The cap at
       half the input height is what the browser silently applies to inputs
       under pill shape (999px against a 44px tall box = 22px effective).
       Applying the same cap here means a pill input and a pill textarea both
       render at 22px, a rounded field and a rounded textarea both render at
       12px, square is 0 - visually consistent in every shape mode, even
       though the textarea box is three times as tall. */
    border-radius: min(var(--field-radius), calc(var(--field-height) / 2));
}

/* Native select arrow stripped, DS chevron drawn on the right. */
.form-select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled { opacity: 0.6; cursor: not-allowed; }

/* Form group / label / help / error chrome lives in the FORM GROUP block below,
   which uses display:flex + gap:6px. The older margin-based rules that lived
   here have been removed to keep a single source of truth for form spacing
   and to stop two conflicting systems from shipping together. */

/* -----------------------------------------------------------------------------
   SEARCH-FIELD  .search-field - a rounded pill with an icon and chromeless input
   The wrapper carries the border and background; the input is transparent so
   there is never a "search inside a search" (two concentric input chromes).
   -------------------------------------------------------------------------- */
.search-field {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: var(--field-height);
    padding: 0 16px;
    background: var(--field-bg);
    color: var(--field-color);
    border: var(--field-border-width) solid var(--field-border-color);
    /* Follows the field shape control, so changing "Field shape" reshapes
       EVERY field-family chrome (inputs, searches, textareas, selects) in
       lockstep. Never hard-code a radius here. */
    border-radius: var(--field-radius);
    min-width: 0;
    box-sizing: border-box;
    transition: border-color 120ms, background 120ms, box-shadow 120ms;
}
.search-field:hover        { background: var(--field-bg-hover); }
.search-field:focus-within {
    border-color: var(--field-focus-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--field-focus-color) 20%, transparent);
    background: var(--field-bg);
}
.search-field-icon {
    color: var(--foreground-muted);
    font-size: 15px;
    flex-shrink: 0;
}
.search-field-input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    background: transparent;
    padding: 0;
    margin: 0;
    font: inherit;
    font-size: 15px;
    color: inherit;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}
.search-field-input::placeholder { color: var(--foreground-muted); }
/* Strip Safari/Chrome's own search-input decorations - the DS wrapper IS the chrome. */
.search-field-input::-webkit-search-decoration,
.search-field-input::-webkit-search-cancel-button,
.search-field-input::-webkit-search-results-button,
.search-field-input::-webkit-search-results-decoration { -webkit-appearance: none; display: none; }

.search-field-sm { height: 36px; padding: 0 12px; }
.search-field-sm .search-field-input { font-size: 13px; }
.search-field-sm .search-field-icon { font-size: 13px; }

/* -----------------------------------------------------------------------------
   FIELD  .field - wrapper carries the chrome; input is a transparent flex child
   This is the structural fix that solved the search-icon-overlap bug.
   -------------------------------------------------------------------------- */
.field {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: var(--field-height);
    padding: 0 var(--field-padding-x);
    background: var(--field-bg);
    color: var(--field-color);
    border: var(--field-border-width) solid var(--field-border-color);
    border-radius: var(--field-radius);
    transition: border-color 120ms, background 120ms, box-shadow 120ms;
}
.field:hover        { background: var(--field-bg-hover); }
.field:focus-within {
    border-color: var(--field-focus-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--field-focus-color) 20%, transparent);
    background: var(--field-bg);
}
.field > input,
.field > select,
.field > textarea {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    outline: none;
}
.field > input::placeholder,
.field > textarea::placeholder {
    color: var(--foreground-muted);
}
.field > .field-icon {
    color: var(--foreground-muted);
    font-size: 16px;
    flex-shrink: 0;
}
.field > .field-suffix,
.field > .field-prefix {
    color: var(--foreground-muted);
    font-size: 13px;
    flex-shrink: 0;
    font-weight: 600;
}
.field-sm       { height: 36px; padding: 0 12px; font-size: 13px; }
.field-lg       { height: 56px; padding: 0 20px; font-size: 17px; }
.field-rounded  { border-radius: var(--radius-md); }
/* Textarea wrapper: capped to match the input's effective pill radius (half
   --field-height) so a pill input and a pill textarea render visually
   identical, not one pilled and the other stadium-shaped. See the
   .form-textarea block for the full rationale. */
.field-textarea { height: auto; align-items: stretch; padding: 12px 16px; border-radius: min(var(--field-radius), calc(var(--field-height) / 2)); }
.field-textarea > textarea { min-height: 96px; resize: vertical; }
.field-invalid  { border-color: var(--danger); }
.field-invalid:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent); }

/* Select arrow - the wrapper already has the border, so hide the native UI */
.field > select {
    appearance: none;
    -webkit-appearance: none;
    background-image: none;
    cursor: pointer;
}
.field-select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 36px;
}
.field-select > select { padding-right: 0; }

/* -----------------------------------------------------------------------------
   FORM GROUP  .form-group - label, control, help text
   -------------------------------------------------------------------------- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
/* Forms are one column (v324): fields stack, with room above each label. */
:is(.form-group, .form-row, .stack-divided) + :is(.form-group, .form-row, .stack-divided) { margin-top: 10px; }
.form-label {
    font: 600 14px/1.3 var(--font-body);
    color: var(--foreground);
}
/* Info about a field: an .info-tip at the end of its label (ds_info_tip). */
.form-label > .info-tip { vertical-align: middle; margin-left: 2px; }
.form-label-required::after {
    content: " *";
    color: var(--danger);
}
.form-help {
    font: 500 12px/1.4 var(--font-body);
    color: var(--foreground-muted);
}
.form-error {
    font: 500 12px/1.4 var(--font-body);
    color: var(--danger);
}
.form-row {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
/* A control with a small button beside it (a select and its remove icon). */
.inline-field { display: flex; align-items: center; gap: 8px; }
.inline-field > :first-child { flex: 1 1 auto; min-width: 0; }
/* Many short fields (filters): a fluid grid of equal columns. */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-md); }

/* -----------------------------------------------------------------------------
   CHECK  .check - checkbox
   -------------------------------------------------------------------------- */
.check,
.radio,
.switch-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font: 500 14px/1.3 var(--font-body);
    color: var(--foreground);
    user-select: none;
}
.check > input,
.radio > input,
.switch-wrap > input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.check-box {
    width: 18px; height: 18px;
    flex-shrink: 0;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-reverse);
    font-size: 11px;
    transition: background 120ms, border-color 120ms;
}
.check > input:checked + .check-box {
    background: var(--primary);
    border-color: var(--primary);
}
.check > input:checked + .check-box::before {
    content: "";
    width: 10px;
    height: 10px;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10' fill='none'><path d='M1.5 5.5L4 8L8.5 2' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>") center no-repeat;
}
.check > input:focus-visible + .check-box {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

/* -----------------------------------------------------------------------------
   RADIO  .radio
   -------------------------------------------------------------------------- */
.radio-dot {
    width: 18px; height: 18px;
    flex-shrink: 0;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-circle);
    background: var(--surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 120ms;
}
.radio-dot::before {
    content: "";
    width: 8px; height: 8px;
    border-radius: var(--radius-circle);
    background: var(--primary);
    transform: scale(0);
    transition: transform 120ms;
}
.radio > input:checked + .radio-dot {
    border-color: var(--primary);
}
.radio > input:checked + .radio-dot::before {
    transform: scale(1);
}
.radio > input:focus-visible + .radio-dot {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

/* -----------------------------------------------------------------------------
   SWITCH  .switch
   -------------------------------------------------------------------------- */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 24px;
    flex-shrink: 0;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    transition: background 120ms, border-color 120ms;
}
.switch::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: var(--radius-circle);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: transform 120ms;
}
.switch-wrap > input:checked + .switch {
    background: var(--primary);
    border-color: var(--primary);
}
.switch-wrap > input:checked + .switch::before {
    transform: translateX(16px);
}
.switch-wrap > input:focus-visible + .switch {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

/* -----------------------------------------------------------------------------
   RANGE  native input[type=range] styled
   -------------------------------------------------------------------------- */
.range {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    height: 24px;
    background: transparent;
    cursor: pointer;
}
.range::-webkit-slider-runnable-track {
    height: 4px;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
}
.range::-moz-range-track {
    height: 4px;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
}
.range::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 20px; height: 20px;
    background: var(--surface);
    border: 2px solid var(--primary);
    border-radius: var(--radius-circle);
    margin-top: -9px;
    cursor: grab;
}
.range::-moz-range-thumb {
    width: 16px; height: 16px;
    background: var(--surface);
    border: 2px solid var(--primary);
    border-radius: var(--radius-circle);
    cursor: grab;
}

/* -----------------------------------------------------------------------------
   FILE  .file - file-upload button that looks like a button
   -------------------------------------------------------------------------- */
.file {
    position: relative;
    display: inline-flex;
}
.file > input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.file-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px 24px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--foreground-muted);
    text-align: center;
    transition: border-color 120ms, background 120ms;
    cursor: pointer;
}
.file-dropzone:hover,
.file-dropzone.is-drag {
    border-color: var(--primary);
    background: var(--primary-subtle);
    color: var(--primary);
}
.file-dropzone > i { font-size: 28px; }

/* -----------------------------------------------------------------------------
   CARD  .card - any visible panel
   -------------------------------------------------------------------------- */
.card {
    background: var(--card-bg);
    color: var(--card-color);
    border: var(--card-border-width) solid var(--card-border-color);
    border-radius: var(--card-radius);
    padding: var(--card-padding);
    /* Cards are FLUID: no imposed min-width here. Their width is controlled
       by their container (grid cell, flex item, stack). The usable-size
       floor lives on .card-grid so grid cells never shrink below it, but
       a card can still live happily inside a 160px stack without
       overflowing. */
    min-width: 0;
    box-sizing: border-box;
}
.card-elevated { box-shadow: 0 8px 24px color-mix(in srgb, var(--foreground) 8%, transparent); border-color: transparent; }
.card-outlined { background: transparent; }
.card-sm       { padding: 12px; border-radius: var(--radius-md); }
.card-lg       { padding: 32px; border-radius: var(--radius-xl); }
.card-header   { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.card-title    { font: 700 calc(20px * var(--font-scale))/1.2 var(--font-display); margin: 0; }
.card-subtitle { font: 500 calc(13px * var(--font-scale))/1.4 var(--font-body); color: var(--foreground-muted); margin: 0; }
.card-body     { font: 500 calc(15px * var(--font-scale))/1.55 var(--font-body); }

/* -----------------------------------------------------------------------------
   SECTION  .section - content container used on every page
   -------------------------------------------------------------------------- */
/* .section is a vertical flex container so that when it sits inside a grid
   row (two paired sections side by side, say) it stretches to the cell's
   full height via grid's default align-items: stretch, and the inner
   .section-body expands to fill any leftover vertical space. This gives us
   two guarantees for free:
     - sections in the same row have the same height.
     - a section-footer or trailing action row pins to the bottom even when
       the section-body is short.
   The old .section > * + * { margin-top: 20px } cascade is replaced by the
   flex `gap` so children sit at the same vertical rhythm without needing
   the margin-collapse workaround. */
.section {
    background: var(--section-bg);
    color: var(--section-color);
    border: var(--section-border-width) solid var(--section-border-color);
    border-radius: var(--section-radius);
    padding: var(--section-padding);
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}
/* Section parts - ONE structural contract across every variant:
   .section
     ├─ .section-header   (optional: title block + its row-aligned actions)
     │   ├─ .section-head   (title + subtitle)
     │   └─ .section-actions
     ├─ .section-head     (optional: title block when there are no header-aligned actions)
     ├─ .section-body     (content; grows to fill remaining height)
     ├─ .section-actions  (optional: primary actions below the content)
     └─ .section-footer
*/
.section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;            /* filters drop under the title when the row is too narrow */
    gap: 16px;
}
.section-header > .section-actions { flex-wrap: wrap; }
/* A Back button before the title (a detail pane): sits on the title's line. */
.section-header:has(> .section-back) { align-items: center; }
.section-back { flex-shrink: 0; }
.section-head     { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.section-title    { font: 700 calc(22px * var(--font-scale))/1.2 var(--font-display); letter-spacing: -0.015em; margin: 0; }
.section-subtitle { font: 500 calc(14px * var(--font-scale))/1.45 var(--font-body); color: inherit; opacity: 0.7; margin: 0; }
.section-body     { display: flex; flex-direction: column; gap: var(--item-gap); flex: 1 1 auto; min-height: 0; }
/* Row-aligned actions inside a header. */
.section-header .section-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
/* Primary actions below the content - inherit the generic 20px top gap */
.section > .section-actions      { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-footer   { padding-top: 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* BANNERS - .section-hero and .section-cta are one family, built the same
   way. Admin settings drive them through four custom properties set on the
   element (never ad hoc inline styles):
     --banner-bg       background colour or gradient
     --banner-color    text colour
     --banner-overlay  0-1 darkening over a background image
   Structure:
     .section.section-hero|section-cta  [.banner-full] [.banner-split]
       ├─ img.banner-bg          (optional background image)
       ├─ span.banner-overlay    (only with a background image)
       ├─ .banner-content        (.section-head + .section-actions)
       └─ .banner-figure > img   (optional feature image -> two columns)
   Layouts:
     default         contained in the page column, rounded like any section
     .banner-full    edge to edge across the viewport, content stays on the
                     page column
     .banner-split   text left, feature image right (stacks on phones) */
.section-hero,
.section-cta {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    border: 0;
    background: var(--banner-bg);
    color: var(--banner-color);
}
.section-hero { --banner-bg: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%); --banner-color: var(--primary-reverse); padding: 48px; }
.section-cta  { --banner-bg: var(--primary); --banner-color: var(--primary-reverse); padding: 40px 32px; text-align: center; }

.banner-bg      { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
.banner-overlay { position: absolute; inset: 0; background: var(--banner-overlay-color, #000); opacity: var(--banner-overlay, 0.5); z-index: -1; pointer-events: none; }
.banner-content { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.banner-figure  { min-width: 0; }
.banner-figure > img { display: block; width: 100%; height: auto; border-radius: var(--radius-lg); }

.banner-split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: center; gap: 40px; }
@media (max-width: 860px) { .banner-split { grid-template-columns: 1fr; } }

.banner-full {
    border-radius: 0;
    margin-inline: calc(50% - 50vw);
    padding-inline: max(var(--page-padding), calc((100vw - var(--page-width)) / 2 + var(--page-padding)));
}
/* A full-bleed banner at the top of the page runs right up to the top of
   the window, behind the navbar, and keeps its own padding below it. */
.page-container > .banner-full:first-child {
    margin-top: calc(-1 * (var(--header-space) + var(--page-top-gap)));
    padding-top: calc(var(--header-space) + 56px);
}

.section-hero .section-title    { font: 900 44px/1 var(--font-display); letter-spacing: -0.03em; }
.section-hero .section-subtitle { font-size: 17px; opacity: 0.9; max-width: 48ch; }
.section-cta  .section-title    { font-size: 28px; font-weight: 800; }
.section-cta  .section-subtitle { font-size: 15px; max-width: 42ch; margin-inline: auto; }
.section-cta  .section-actions  { justify-content: center; }
.section-hero .section-actions,
.section-cta  .section-actions  { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-hero .section-head > *,
.section-cta  .section-head > * { color: inherit; }
/* Outline buttons on a banner follow the banner text colour. */
.section-hero .btn-outline,
.section-cta  .btn-outline { background: transparent; color: inherit; border-color: currentColor; }
@media (max-width: 720px) {
    .section-hero { padding: 32px 24px; }
    .section-hero .section-title { font-size: 32px; }
}

.section-feature {
    background: var(--feature-1);
    color: var(--feature-1-reverse);
    border: 0;
}

.section-empty .section-body { align-items: center; padding: 24px; }
.section-sm { padding: 16px; border-radius: var(--radius-lg); }
.section-lg { padding: 48px; border-radius: var(--radius-xl); }

/* -----------------------------------------------------------------------------
   PAGE-HEADER  .page-header - title row at the top of a page
   -------------------------------------------------------------------------- */
.page-header {
    display: flex;
    align-items: flex-end;        /* actions sit on the bottom line of the title block */
    justify-content: space-between;
    gap: 16px;
    padding: 24px 0 0;          /* the page container's section gap sets the space to the first element */
}
.page-header-main    { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 260px; }
.page-title          { font: 800 calc(32px * var(--font-scale))/1.15 var(--font-display); letter-spacing: -0.025em; margin: 0; }
.page-subtitle       { font: 500 calc(15px * var(--font-scale))/1.4 var(--font-body); color: var(--foreground-muted); margin: 0; }
.page-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; min-width: 0; max-width: 100%; }
/* v330: the title keeps at least 260px, so on a narrow screen the actions
   (often a tab bar) wrap onto their own line instead of squeezing the title,
   and tabs that still do not fit scroll sideways. */
.page-header { flex-wrap: wrap; }
@media (max-width: 720px) {
    .page-header-actions { flex: 1 1 100%; }
    .page-header-actions > .tab-bar { max-width: 100%; }
}
.tab-bar > .tabs, .page-header-actions .tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.tab-bar > .tabs::-webkit-scrollbar, .page-header-actions .tabs::-webkit-scrollbar { display: none; }

/* -----------------------------------------------------------------------------
   FOOTER  .footer - the bottom bar
   -------------------------------------------------------------------------- */
.footer {
    width: 100%;
    max-width: var(--page-width);
    margin: 56px auto 16px;
    padding: 0 var(--page-padding);
}
.footer-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: var(--footer-padding) 24px;
    background: var(--footer-bg);
    color: var(--footer-color);
    border-radius: var(--footer-radius);
    text-align: center;
}
.footer-logo    { display: inline-flex; align-items: center; gap: 8px; font: 800 20px/1 var(--font-display); color: inherit; }
.footer-logo .emblem {
    width: 28px; height: 28px; border-radius: var(--radius-circle);
    background: var(--secondary); color: var(--secondary-reverse);
    display: inline-flex; align-items: center; justify-content: center;
    font: 900 14px/1 var(--font-display);
}
.footer-nav     { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; }
.footer-nav a   { color: inherit; opacity: 0.85; font: 500 14px/1 var(--font-body); }
.footer-nav a:hover { opacity: 1; text-decoration: none; }
.footer-socials { display: flex; gap: 10px; }
.footer-socials a {
    width: 36px; height: 36px; border-radius: var(--radius-circle);
    display: inline-flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--primary-reverse) 12%, transparent); color: inherit;
    transition: background 120ms;
}
.footer-socials a:hover { background: color-mix(in srgb, var(--primary-reverse) 22%, transparent); text-decoration: none; }
.footer-copy { font: 500 12px/1.4 var(--font-body); opacity: 0.7; }

/* -----------------------------------------------------------------------------
   ITEM  .item - a clickable row/tile
   -------------------------------------------------------------------------- */
.item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: var(--item-padding);
    border: var(--item-border-width) solid var(--item-border-color);
    border-radius: var(--item-radius);
    background: var(--item-bg);
    color: var(--item-color);
    cursor: pointer;
    transition: background 120ms, color 120ms, border-color 120ms;
    text-decoration: none;
}
.item:hover,
a.item:hover,
button.item:hover {
    background: var(--item-bg-hover, color-mix(in srgb, var(--primary) 8%, var(--item-bg)));
    color: var(--foreground);
    text-decoration: none;
}
.item:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.item-active,
.item.is-active,
.item:has(> .radio > input:checked),
.item:has(> .check > input:checked),
.item[aria-current="true"],
.item[aria-current="page"],
.item[aria-selected="true"] {
    background: var(--primary-subtle, color-mix(in srgb, var(--primary) 14%, var(--item-bg)));
    color: var(--foreground);
    border-color: var(--primary-muted, color-mix(in srgb, var(--primary) 24%, transparent));
    text-decoration: none;
    font-weight: 600;
}
.item-active:hover,
.item.is-active:hover {
    background: color-mix(in srgb, var(--primary) 20%, var(--item-bg));
}
.item-disabled,
.item[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}
.item-row  { /* default */ }
.item-tile {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
    padding: 0;
    overflow: hidden;
}
.item-tile .tile-media { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.item-tile .tile-body  { padding: 12px; }

/* -----------------------------------------------------------------------------
   CHIP  .chip - tiny uppercase label
   -------------------------------------------------------------------------- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: var(--chip-height);
    padding: 0 var(--chip-padding-x);
    border-radius: var(--chip-radius);
    background: var(--chip-bg);
    color: var(--chip-color);
    font-size: var(--chip-font-size);
    font-weight: var(--chip-font-weight);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.chip-success  { background: var(--success-subtle); color: var(--success); }
.chip-warning  { background: var(--warning-subtle); color: var(--warning); }
.chip-danger   { background: var(--danger-subtle);  color: var(--danger); }
.chip-info     { background: var(--info-subtle);    color: var(--info); }
.chip-primary  { background: var(--primary-subtle);   color: var(--primary); }
.chip-secondary{ background: var(--secondary-subtle); color: var(--secondary); }
.chip-sm       { height: 20px; padding: 0 8px; font-size: 10px; }
.chip-lg       { height: 30px; padding: 0 14px; font-size: 12px; }
/* Translucent white chip for use on media overlays (competition heroes etc.) */
.chip-overlay  { background: var(--on-media-subtle); color: var(--on-media); }

/* -----------------------------------------------------------------------------
   BADGE  .badge - number pill for counts
   -------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--badge-radius);
    background: var(--secondary);
    color: var(--secondary-reverse);
    font: 700 11px/1 var(--font-body);
}
.badge-primary { background: var(--primary); color: var(--primary-reverse); }
.badge-success { background: var(--success); color: var(--success-reverse); }
.badge-warning { background: var(--warning); color: var(--warning-reverse); }
.badge-danger  { background: var(--danger);  color: var(--danger-reverse); }
.badge-dot     { min-width: 10px; width: 10px; height: 10px; padding: 0; }

/* -----------------------------------------------------------------------------
   TAG  .tag - removable label (like email recipient chips)
   -------------------------------------------------------------------------- */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 4px 4px 10px;
    border-radius: var(--tag-radius);
    background: var(--primary-subtle);
    color: var(--primary);
    font: 500 13px/1 var(--font-body);
}
.tag-close {
    width: 20px; height: 20px;
    border: 0; background: transparent;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-circle);
    color: inherit;
    cursor: pointer;
    font-size: 10px;
    transition: background 120ms;
}
.tag-close:hover { background: color-mix(in srgb, var(--primary) 18%, transparent); }

/* -----------------------------------------------------------------------------
   ALERT  .alert
   -------------------------------------------------------------------------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: var(--alert-padding-y) var(--alert-padding-x);
    border-radius: var(--alert-radius);
    background: var(--surface-subtle);
    color: var(--foreground);
    font-size: var(--alert-font-size);
    line-height: 1.45;
}
.alert-success { background: var(--success-subtle); color: var(--success); }
.alert-warning { background: var(--warning-subtle); color: var(--warning); }
.alert-danger  { background: var(--danger-subtle);  color: var(--danger); }
.alert-info    { background: var(--info-subtle);    color: var(--info); }
/* Alert icon: sized to match the two-line block of text beside it, not to the
   font size. 20px keeps the glyph visible against the alert's body. */
.alert > i:first-child,
.alert > svg:first-child { font-size: 20px; width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.alert strong { font-weight: 700; margin-right: 4px; }

/* -----------------------------------------------------------------------------
   TOAST  .toast - transient notification
   -------------------------------------------------------------------------- */
.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    color: var(--foreground);
    border: 1px solid var(--border);
    /* Toasts share the alert family shape so a single --alert-radius change
       reshapes both the inline alerts and the floating toasts. */
    border-radius: var(--alert-radius);
    box-shadow: 0 8px 24px color-mix(in srgb, var(--foreground) 10%, transparent);
    font: 500 14px/1.4 var(--font-body);
}
.toast-stack {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: var(--z-toast);
    max-width: 360px;
}

/* -----------------------------------------------------------------------------
   NAV-ITEM  .nav-item
   -------------------------------------------------------------------------- */
.nav-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: var(--nav-item-height);
    padding: 0 var(--nav-item-padding-x);
    border-radius: var(--nav-item-radius);
    color: var(--nav-item-color);
    font-size: var(--nav-item-font-size);
    font-weight: var(--nav-item-font-weight);
    text-decoration: none;
    background: var(--nav-item-bg);
    border: 0;
    cursor: pointer;
    white-space: nowrap;
    transition: background 120ms, color 120ms;
}
.nav-item:hover { background: var(--nav-item-bg-hover); color: var(--nav-item-color-hover); text-decoration: none; }
.nav-item-active { background: var(--nav-item-active-bg); color: var(--nav-item-active-color); }
/* Icon nav items live in the same family as text nav items, so they inherit
   the nav-item shape control. The icon-chip radius is only the FALLBACK -
   when the nav-item shape is explicitly set, it wins. */
.nav-item-icon { width: var(--nav-item-height); padding: 0; justify-content: center; background: var(--surface-subtle); border-radius: var(--nav-item-radius, var(--icon-chip-radius)); }
.nav-item-icon:hover { background: var(--feature-1); color: var(--feature-1-reverse); }


/* -----------------------------------------------------------------------------
   TABS  .tabs
   -------------------------------------------------------------------------- */
.tabs {
    display: inline-flex;
    gap: 2px;
    padding: 4px;
    background: var(--surface-subtle);
    border-radius: var(--tabs-radius);
}
.tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: var(--tab-padding-y) var(--tab-padding-x);
    border-radius: var(--tab-radius);
    background: transparent;
    color: var(--tab-color);
    font: var(--tab-font-weight) var(--tab-font-size)/1 var(--font-body);
    white-space: nowrap;
    border: 0;
    cursor: pointer;
    transition: background 120ms, color 120ms, box-shadow 120ms;
}
/* Hover: clear surface tint so the pill reads as interactive, not just a text
   colour change. */
.tab:hover {
    background: var(--tab-hover-bg);
    color: var(--foreground);
}
.tab:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
/* Selected: solid surface fill with a soft shadow for lift. Works on the
   .tabs track (surface-subtle background) and inside .tab-bar / .toolbar
   (surface background) because the pill contrasts both. */
.tab-active,
.tab.tab-active,
.tab[aria-selected="true"],
.tab[aria-current="true"],
.tab[aria-current="page"] {
    background: var(--surface);
    color: var(--foreground);
    box-shadow: var(--shadow-xs);
    font-weight: 700;
}
/* Inside a .tab-bar / .toolbar (whose background IS .surface) the active
   tab is solid brand: 100% primary with its reverse text. */
.tab-bar .tab-active,
.toolbar .tab-active,
.tab-bar .tab[aria-selected="true"],
.toolbar .tab[aria-selected="true"],
.tab-bar .tab[aria-current="page"] {
    background: var(--tab-active-bg);
    color: var(--tab-active-color);
    box-shadow: none;
}
.tab-bar .tab-active:hover,
.toolbar .tab-active:hover,
.tab-bar .tab[aria-current="page"]:hover { background: color-mix(in srgb, var(--tab-active-bg) 85%, black); color: var(--tab-active-color); }
/* Counts and chips on an active tab read on the brand fill. */
.tab-bar .tab-active .chip,
.toolbar .tab-active .chip,
.tab-bar .tab[aria-current="page"] .chip { background: color-mix(in srgb, var(--tab-active-color) 22%, transparent); color: var(--tab-active-color); }

.tab-disabled,
.tab[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* -----------------------------------------------------------------------------
   TAB-BAR  .tab-bar - tabs on the left, action icons on the right.
   Includes a Search mode: clicking the search action collapses the tabs and
   expands an inline search field across the bar.
   One size only.
   -------------------------------------------------------------------------- */
/* .tab-bar and .toolbar are the same family. Same base, same sizes, same
   variants. A .tab-bar is a .toolbar whose primary content is a .tabs group;
   a .toolbar is the same shell carrying any mix of search, inputs, buttons
   and icon actions. Both get these rules, so switching the primary content
   never changes the chrome.

   One size for every tab bar and toolbar. No variants.
   Default: tighter padding around slightly larger controls so controls are
   the hero; the shell is quiet chrome around them. */
.tab-bar,
.toolbar {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--toolbar-gap);
    padding: var(--toolbar-padding);
    background: var(--toolbar-bg);
    border: 1px solid var(--toolbar-border-color);
    border-radius: var(--toolbar-radius, var(--tabs-radius));
    min-height: calc(var(--toolbar-icon-size) + var(--toolbar-padding) * 2);
    flex-wrap: wrap;
    /* overflow is NOT hidden so dropdown menus can escape. The inner
       .tab-bar-tabs clips its own transitioning content instead. */
}
.tab-bar .tabs,
.toolbar .tabs {
    background: transparent;
    padding: 0;
    gap: 2px;
}
.tab-bar-tabs {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    overflow: hidden;
    border-radius: inherit;
    transition: transform 240ms cubic-bezier(0.2, 0.7, 0.2, 1), opacity 180ms;
}
.tab-bar-actions {
    flex-shrink: 0;
    display: inline-flex;
    gap: 2px;
    align-items: center;
    transition: transform 240ms cubic-bezier(0.2, 0.7, 0.2, 1), opacity 180ms;
}
/* Every control type inside a .tab-bar or .toolbar snaps to the family height
   so the row reads as one strip, not a jumble of different sizes. */
.tab-bar-action,
.tab-bar > .btn,
.tab-bar .btn-icon,
.toolbar > .btn,
.toolbar .btn-icon {
    height: 42px;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: var(--tab-radius);
    transition: background 120ms, color 120ms, border-color 120ms;
}
.tab-bar-action,
.toolbar .btn-icon,
.tab-bar .btn-icon {
    width: 42px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--foreground-muted);
    cursor: pointer;
    font-size: 15px;
}
.tab-bar-action:hover,
.toolbar .btn-icon:hover,
.tab-bar .btn-icon:hover { background: var(--surface-subtle); color: var(--foreground); }

/* Tab items inside a .tab-bar or .toolbar pick up the same default size. */
.tab-bar .tab,
.toolbar .tab { padding: 8px 18px; font-size: 14px; height: 42px; }

/* .search-field, .form-select, .form-input and bare inputs inside a toolbar
   all snap to the same height and sit flush with the buttons. */
.tab-bar > .search-field,
.toolbar > .search-field {
    flex: 1 1 200px;
    min-width: 0;
    height: 42px;
    padding: 0 14px;
}
.tab-bar > .form-input,
.tab-bar > input:not([type="checkbox"]):not([type="radio"]):not([type="search"]),
.toolbar > .form-input,
.toolbar > input:not([type="checkbox"]):not([type="radio"]):not([type="search"]),
.toolbar > .field,
.tab-bar > .field {
    height: 42px;
    min-height: 42px;
    padding: 0 14px;
    font-size: 14px;
    width: auto;
    flex-shrink: 0;
}
/* Selects keep their chevron padding; only height and font snap to the family. */
.tab-bar > .form-select,
.tab-bar > select,
.toolbar > .form-select,
.toolbar > select {
    height: 42px;
    min-height: 42px;
    padding-top: 0;
    padding-bottom: 0;
    padding-left: 14px;
    font-size: 14px;
    width: auto;
    flex-shrink: 0;
}

/* Search-mode overlay (tab bar's search-swap pattern) */
.tab-bar-search {
    position: absolute;
    inset: 3px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    background: var(--surface);
    border-radius: inherit;
    transform: translateX(18px);
    opacity: 0;
    pointer-events: none;
    transition: transform 240ms cubic-bezier(0.2, 0.7, 0.2, 1), opacity 180ms;
}
.tab-bar-search > i {
    color: var(--foreground-muted);
    font-size: 15px;
    flex-shrink: 0;
}
.tab-bar-search > input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    outline: none;
    color: var(--foreground);
    font: 500 15px/1 var(--font-body);
}
.tab-bar-search > input::placeholder { color: var(--foreground-muted); }

.tab-bar.is-searching .tab-bar-tabs,
.tab-bar.is-searching .tab-bar-actions {
    opacity: 0;
    transform: translateX(-12px);
    pointer-events: none;
}
.tab-bar.is-searching .tab-bar-search {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

/* -----------------------------------------------------------------------------
   BREADCRUMB  .breadcrumb
   -------------------------------------------------------------------------- */
.breadcrumb {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font: 500 13px/1 var(--font-body);
    color: var(--foreground-muted);
}
.breadcrumb > a   { color: inherit; }
.breadcrumb > a:hover { color: var(--foreground); text-decoration: none; }
.breadcrumb-sep   { color: var(--border); }
.breadcrumb > .breadcrumb-current { color: var(--foreground); font-weight: 600; }

/* -----------------------------------------------------------------------------
   PAGINATION  .pagination
   -------------------------------------------------------------------------- */
.pagination {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--pagination-radius);
}
.pagination > button,
.pagination > a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--pagination-radius);
    background: transparent;
    color: var(--foreground);
    font: 600 13px/1 var(--font-body);
    cursor: pointer;
    transition: background 120ms;
}
.pagination > :hover { background: var(--surface-subtle); text-decoration: none; }
.pagination .page-active { background: var(--primary); color: var(--primary-reverse); }
.pagination .page-active:hover { background: var(--primary-bold); }

/* -----------------------------------------------------------------------------
   TILE  .tile
   -------------------------------------------------------------------------- */
.tile {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: var(--tile-padding);
    border-radius: var(--tile-radius);
    background: var(--tile-bg);
    border: 1px solid var(--border);
    text-align: left;
}
.tile-stat {
    text-align: center;
    padding: 20px 16px;
    background: var(--feature-1);
    color: var(--feature-1-reverse);
    border: 0;
}
/* Stat value uses the display-lg step of the type scale (one up from heading-1). */
.tile-stat .tile-value { font: 900 calc(44px * var(--font-scale))/1 var(--font-display); letter-spacing: -0.03em; }
.tile-stat .tile-label { font: 700 11px/1.3 var(--font-body); text-transform: uppercase; letter-spacing: 0.06em; opacity: .75; }
.tile-media {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--cover-radius);
    background: var(--surface-subtle);
}
.tile-sm { padding: 8px; }
.tile-lg { padding: 20px; }

/* -----------------------------------------------------------------------------
   AVATAR  .avatar
   -------------------------------------------------------------------------- */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border-radius: var(--radius-circle);
    background: var(--primary);
    color: var(--primary-reverse);
    font: 700 15px/1 var(--font-body);
    overflow: hidden;
    flex-shrink: 0;
}
.avatar > img { width: 100%; height: 100%; object-fit: cover; }
.avatar-xs { width: 24px; height: 24px; font-size: 10px; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-md { width: 40px; height: 40px; font-size: 15px; }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; }
.avatar-xl { width: 80px; height: 80px; font-size: 28px; }
.avatar-stack { display: inline-flex; }
.avatar-stack > .avatar { margin-left: -8px; border: 2px solid var(--surface); }
.avatar-stack > .avatar:first-child { margin-left: 0; }

/* -----------------------------------------------------------------------------
   PROGRESS  .progress - bar
   -------------------------------------------------------------------------- */
.progress {
    width: 100%;
    height: 8px;
    background: var(--surface-subtle);
    border-radius: var(--radius-pill);
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    width: var(--value, 100%);
    background: var(--primary);
    transition: width 200ms;
}
.progress-success .progress-bar { background: var(--success); }
.progress-warning .progress-bar { background: var(--warning); }
.progress-danger  .progress-bar { background: var(--danger); }
.progress-lg      { height: 12px; }

/* BAR LIST  .bar-list - magnitude by category (genre split, top sources).
   One hue, label | bar | value; the bar is a .progress whose fill takes
   --value (0-100%). */
.bar-list { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(72px, 160px) minmax(0, 1fr) auto; align-items: center; gap: 12px; font: 500 13px/1.3 var(--font-body); }
.bar-row-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row-value { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--foreground); }
.bar-row .progress-bar { border-radius: 4px; }

/* COLUMN CHART  .chart-columns - up to two series over time. Thin columns
   with 4px rounded tops on a recessive baseline, 2px gap between a pair,
   series 1 = primary, series 2 = secondary. Each column carries its value
   in data-tooltip; .chart-legend always names the series. */
.chart-columns { display: flex; align-items: flex-end; gap: 12px; height: 180px; padding-bottom: 24px; border-bottom: 1px solid var(--border); position: relative; }
.chart-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.chart-col-bars { display: flex; align-items: flex-end; justify-content: center; gap: 2px; height: 100%; width: 100%; }
.chart-bar { width: min(20px, 40%); height: var(--value, 0%); min-height: 2px; border-radius: 4px 4px 0 0; background: var(--primary); cursor: default; }
.chart-bar-2 { background: var(--secondary); }
.chart-col-label { position: absolute; bottom: -22px; font: 500 12px/1 var(--font-body); color: var(--foreground-muted); white-space: nowrap; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 16px; font: 500 13px/1 var(--font-body); color: var(--foreground-muted); }
.chart-key { display: inline-flex; align-items: center; gap: 6px; }
.chart-swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--primary); }
.chart-swatch-2 { background: var(--secondary); }
.chart-columns-dense { gap: 2px; }
.chart-columns-dense .chart-bar { width: 100%; max-width: 14px; }

/* CHAT  .chat - two-pane messaging: conversation list + thread.
   .chat
     ├─ .chat-sidebar  (.chat-sidebar-head + .chat-list of .song-row rows)
     └─ .chat-main     (.chat-head, .chat-thread of .chat-message, .chat-composer)
   A .chat-message.is-own sits right with the primary bubble. */
.chat { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); height: calc(100vh - var(--header-space, 80px) - 120px); min-height: 520px; background: var(--section-bg, var(--surface)); border: var(--section-border-width, 1px) solid var(--section-border-color, var(--border)); border-radius: var(--section-radius); overflow: hidden; }
.chat-sidebar { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); }
.chat-sidebar-head, .chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.chat-title { font: 700 17px/1.2 var(--font-display); margin: 0; }
.chat-subtitle { font: 500 13px/1.3 var(--font-body); color: var(--foreground-muted); margin: 2px 0 0; }
.chat-list { flex: 1; overflow-y: auto; padding: 8px; }
.chat-main { display: flex; flex-direction: column; min-height: 0; }
.chat-main > .state { flex: 1; justify-content: center; }
.chat-thread { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.chat-message { display: flex; gap: 10px; max-width: 75%; align-items: flex-end; }
.chat-message.is-own { flex-direction: row-reverse; margin-left: auto; }
.chat-bubble { background: var(--surface-subtle); padding: 10px 14px; border-radius: 16px 16px 16px 4px; min-width: 0; }
.chat-message.is-own .chat-bubble { background: var(--primary); color: var(--primary-reverse); border-radius: 16px 16px 4px 16px; }
.chat-sender { font: 600 12px/1.2 var(--font-body); color: var(--foreground-muted); margin-bottom: 2px; }
.chat-text { font: 500 15px/1.45 var(--font-body); white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-time { font: 500 11px/1 var(--font-body); opacity: 0.65; margin-top: 4px; }
.chat-composer { display: flex; flex-direction: row; align-items: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); flex-shrink: 0; }
.chat-composer > .form-textarea { flex: 1; resize: none; min-height: 44px; max-height: 120px; }
@media (max-width: 768px) {
    .chat { grid-template-columns: 1fr; height: auto; }
    .chat-sidebar { border-right: 0; border-bottom: 1px solid var(--border); max-height: 300px; }
    .chat-main { min-height: 420px; }
    .chat-message { max-width: 90%; }
}

/* COLOUR FIELD  .color-field - a swatch button that opens the palette, plus
   a hex input (dark overrides, brand-ref pickers). The Theme page's colour
   tokens use the SWATCH GRID below.
   PALETTE  .palette[data-view="swatches"|"list"] - the picker dialog body. */
.color-field { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.color-field-swatch { width: 40px; height: 40px; flex-shrink: 0; padding: 0; cursor: pointer; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--swatch, var(--surface-subtle)); transition: transform 120ms; }
.color-field-swatch:hover { transform: scale(1.04); }
.color-field[data-custom] > .color-field-swatch { cursor: pointer; }
.color-field-swatch:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.color-field-hex { flex: 1; min-width: 0; height: 40px; padding: 0 12px; font: 500 13px/1 var(--font-mono, ui-monospace, monospace); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--foreground); }
/* SWATCH GRID  .swatch-grid of .swatch-card - one card per colour token: a
   big swatch (opens the palette), the name and hex, and a strip of its six
   variants (base, bold, subtle, highlight, reverse, muted). */
.swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--item-gap); }
.swatch-card { display: flex; flex-direction: column; gap: 8px; padding: 10px; min-width: 0; background: var(--surface-subtle); border-radius: var(--radius-md); }
.swatch-card-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.swatch-card-head > .color-field-swatch { width: 44px; height: 44px; }
.swatch-card-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.swatch-card .color-field-hex { width: 100%; height: 28px; padding: 0 8px; }
.swatch-card-variants { display: grid; grid-template-columns: repeat(6, 1fr); height: 12px; border-radius: var(--radius-xs); overflow: hidden; border: 1px solid var(--border); }
.swatch-card-variant { display: block; background: var(--swatch, transparent); }

/* LOGO PREVIEW  .logo-preview - an uploaded logo shown whole (contain, never
   cropped) on the background it is made for. .logo-preview-dark previews a
   dark-mode logo on the foreground colour. */
.logo-preview { display: flex; align-items: center; justify-content: center; min-height: 112px; padding: 16px; border-radius: var(--radius-md); background: var(--surface-subtle); border: 1px solid var(--border); }
.logo-preview-dark { background: var(--foreground); color: var(--background); }
.logo-preview > img { display: block; max-width: 100%; max-height: 80px; width: auto; height: auto; object-fit: contain; }
.logo-preview > p { margin: 0; color: inherit; opacity: 0.7; }

.palette { display: flex; flex-direction: column; gap: 16px; }
.palette-group { display: flex; flex-direction: column; gap: 6px; }
.palette-sub { font: 600 12px/1.3 var(--font-body); color: var(--foreground-muted); margin-top: 4px; }
.palette-swatch { border: 0; background: transparent; cursor: pointer; border-radius: var(--radius-sm); color: var(--foreground-muted); font: 600 10px/1.2 var(--font-body); }
.palette-swatch:hover { background: var(--surface-subtle); }
.palette-chip { display: block; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--swatch, var(--surface-subtle)); }
.palette[data-view="swatches"] .palette-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.palette[data-view="swatches"] .palette-swatch { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px; }
.palette-name { font: 600 11px/1.2 var(--font-body); color: var(--foreground-muted); text-transform: capitalize; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.palette[data-view="swatches"] .palette-chip { width: 100%; height: 28px; }
.palette[data-view="swatches"] .palette-label { display: none; }
.palette[data-view="swatches"] .palette-hex { opacity: 0.7; font-size: 9px; }
.palette[data-view="list"] .palette-grid { display: flex; flex-direction: column; gap: 2px; }
.palette[data-view="list"] .palette-swatch { display: grid; grid-template-columns: 36px 1fr 100px; align-items: center; gap: 12px; padding: 6px 8px; width: 100%; text-align: left; font-size: 13px; color: var(--foreground); }
.palette[data-view="list"] .palette-chip { width: 36px; height: 24px; }
.palette[data-view="list"] .palette-label { display: flex; align-items: baseline; gap: 8px; }
.palette[data-view="list"] .palette-name { font-weight: 600; }
.palette[data-view="list"] .palette-variant { font-size: 11px; color: var(--foreground-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.palette[data-view="list"] .palette-hex { font: 500 11px/1 var(--font-mono, ui-monospace, monospace); color: var(--foreground-muted); text-align: right; }

/* -----------------------------------------------------------------------------
   SPINNER  .spinner
   -------------------------------------------------------------------------- */
.spinner {
    display: inline-block;
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: var(--radius-circle);
    animation: spin 700ms linear infinite;
}
.spinner-sm { width: 14px; height: 14px; border-width: 1.5px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* -----------------------------------------------------------------------------
   SKELETON  .skeleton - loading placeholder
   -------------------------------------------------------------------------- */
.skeleton {
    background: linear-gradient(90deg, var(--surface-subtle) 25%, var(--border) 50%, var(--surface-subtle) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.4s ease-in-out infinite;
    border-radius: var(--radius-sm);
}
.skeleton-text   { height: 14px; width: 100%; }
.skeleton-title  { height: 20px; width: 60%; }
.skeleton-circle { border-radius: var(--radius-circle); }
@keyframes skeleton { to { background-position: -200% 0; } }

/* -----------------------------------------------------------------------------
   KBD  .kbd - keyboard shortcut
   -------------------------------------------------------------------------- */
.kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: var(--surface);
    color: var(--foreground-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font: 600 11px/1 var(--font-mono);
    box-shadow: 0 1px 0 var(--border);
}

/* -----------------------------------------------------------------------------
   TABLE  .table - wrap in .table-wrap to get the --table-radius chrome
   -------------------------------------------------------------------------- */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--table-radius);
    overflow: hidden;
}
.table {
    width: 100%;
    border-collapse: collapse;
    font: 500 14px/1.4 var(--font-body);
}
.table th, .table td {
    padding: var(--table-cell-padding-y) var(--table-cell-padding-x);
    text-align: left;
    border-bottom: 1px solid var(--table-border-color);
}
.table tr:last-child td { border-bottom: 0; }
.table th {
    font-weight: 700;
    color: var(--table-head-color);
    font-size: var(--table-head-size);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--table-head-bg);
}
.table-striped tbody tr:nth-child(even) { background: var(--surface-subtle); }
/* Matrix table: a label column plus narrow, centred checkbox columns (one per
   channel or option), e.g. notification settings. */
.table .col-check { width: 1%; white-space: nowrap; text-align: center; padding-left: 24px; padding-right: 24px; }
/* Row selection and drag handle columns: as narrow as their control. */
.table .col-select { width: 1%; padding-right: 0; }
.table .col-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .col-center { text-align: center; }
.table .col-select input { display: block; margin: 0; }
.table .col-drag { width: 1%; white-space: nowrap; padding-left: 12px; padding-right: 0; }
.table .col-check > .check { justify-content: center; }
.table-cell-title { font-weight: 600; color: var(--foreground); }
.table-matrix td { vertical-align: middle; }
.table-hover tbody tr:hover { background: var(--table-row-hover); }

/* -----------------------------------------------------------------------------
   MENU  .menu - dropdown menu list
   -------------------------------------------------------------------------- */
.menu {
    display: flex;
    flex-direction: column;
    padding: 6px;
    background: var(--menu-bg);
    border: 1px solid var(--border);
    border-radius: var(--menu-radius);
    box-shadow: var(--shadow-md);
    min-width: 200px;
    z-index: var(--z-sticky);
    animation: ds-fade-in-down 160ms ease-out both;
}
.menu[hidden] { display: none; }
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--foreground);
    font: 500 14px/1.3 var(--font-body);
    cursor: pointer;
    background: transparent;
    border: 0;
    text-align: left;
    width: 100%;
}
.menu-item:hover { background: var(--surface-subtle); text-decoration: none; }
.menu-item:disabled { opacity: 0.5; cursor: default; background: transparent; }
/* The one highlighted action in a menu, such as Submit a song at the top of
   the account menu. */
.menu-item-primary { background: var(--primary); color: var(--primary-reverse); font-weight: 700; }
.menu-item-primary:hover { background: var(--primary-bold); color: var(--primary-reverse); }
.menu-item-danger { color: var(--danger); }
.menu-item-danger:hover { background: var(--danger-subtle); }
.menu-divider { height: 1px; background: var(--border); margin: 4px 0; }
.menu-label { padding: 6px 10px 2px; font: 700 11px/1 var(--font-body); color: var(--foreground-muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* -----------------------------------------------------------------------------
   TOOLTIP  [data-tooltip]  - CSS-only label that appears on hover or keyboard
                              focus. Directional with [data-tooltip-side].
   POPOVER  [data-popover]  - Richer card-style tooltip (same trigger model,
                              lighter chrome, soft shadow, multi-line body).
   Both use ::before for the arrow and ::after for the panel, animate in, and
   appear on hover AND :focus-visible so keyboard users see them too.
   -------------------------------------------------------------------------- */
[data-tooltip], [data-popover] { position: relative; }

[data-tooltip]::after,
[data-tooltip]::before {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    transition: opacity 120ms ease, transform 120ms ease;
    z-index: var(--z-tooltip);
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    padding: 7px 11px;
    background: var(--foreground);
    color: var(--background);
    border-radius: var(--radius-sm);
    font: 500 12px/1.3 var(--font-body);
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    max-width: 280px;
}
[data-tooltip]::before {
    content: "";
    width: 0; height: 0;
    border: 5px solid transparent;
}

/* Default placement: top */
[data-tooltip]::after                       { bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px); }
[data-tooltip]::before                      { bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%) translateY(4px); border-top-color: var(--foreground); }
[data-tooltip][data-tooltip-side="bottom"]::after  { bottom: auto; top: calc(100% + 8px); transform: translateX(-50%) translateY(-4px); }
[data-tooltip][data-tooltip-side="bottom"]::before { bottom: auto; top: calc(100% + 3px); transform: translateX(-50%) translateY(-4px); border-top-color: transparent; border-bottom-color: var(--foreground); }
[data-tooltip][data-tooltip-side="right"]::after   { bottom: auto; top: 50%; left: calc(100% + 8px); transform: translateY(-50%) translateX(-4px); }
[data-tooltip][data-tooltip-side="right"]::before  { bottom: auto; top: 50%; left: calc(100% + 3px); transform: translateY(-50%) translateX(-4px); border-top-color: transparent; border-right-color: var(--foreground); }
[data-tooltip][data-tooltip-side="left"]::after    { bottom: auto; top: 50%; left: auto; right: calc(100% + 8px); transform: translateY(-50%) translateX(4px); }
[data-tooltip][data-tooltip-side="left"]::before   { bottom: auto; top: 50%; left: auto; right: calc(100% + 3px); transform: translateY(-50%) translateX(4px); border-top-color: transparent; border-left-color: var(--foreground); }

[data-tooltip]:hover::after,
[data-tooltip]:hover::before,
[data-tooltip]:focus-visible::after,
[data-tooltip]:focus-visible::before { opacity: 1; }
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after,
[data-tooltip]:hover::before,
[data-tooltip]:focus-visible::before { transform: translateX(-50%) translateY(0); }
[data-tooltip][data-tooltip-side="right"]:hover::after,
[data-tooltip][data-tooltip-side="right"]:focus-visible::after,
[data-tooltip][data-tooltip-side="right"]:hover::before,
[data-tooltip][data-tooltip-side="right"]:focus-visible::before,
[data-tooltip][data-tooltip-side="left"]:hover::after,
[data-tooltip][data-tooltip-side="left"]:focus-visible::after,
[data-tooltip][data-tooltip-side="left"]:hover::before,
[data-tooltip][data-tooltip-side="left"]:focus-visible::before { transform: translateY(-50%) translateX(0); }

/* Popover - richer, with a title/body, surface colouring */
[data-popover]::after,
[data-popover]::before {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    transition: opacity 140ms ease, transform 140ms ease;
    z-index: var(--z-tooltip);
}
[data-popover]::after {
    content: attr(data-popover);
    padding: 12px 14px;
    background: var(--surface);
    color: var(--foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font: 500 13px/1.4 var(--font-body);
    box-shadow: var(--shadow-lg);
    width: max-content;
    max-width: 280px;
    white-space: normal;
}
[data-popover]::before {
    content: "";
    width: 10px; height: 10px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    border-top: 1px solid var(--border);
    transform: translateX(-50%) rotate(45deg);
}

[data-popover]::after                       { bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%) translateY(4px); }
[data-popover]::before                      { bottom: calc(100% + 5px); left: 50%; transform: translateX(-50%) rotate(225deg); }
[data-popover][data-popover-side="bottom"]::after  { bottom: auto; top: calc(100% + 10px); transform: translateX(-50%) translateY(-4px); }
[data-popover][data-popover-side="bottom"]::before { bottom: auto; top: calc(100% + 5px); transform: translateX(-50%) rotate(45deg); }
[data-popover][data-popover-side="right"]::after   { bottom: auto; top: 50%; left: calc(100% + 10px); transform: translateY(-50%) translateX(-4px); }
[data-popover][data-popover-side="right"]::before  { bottom: auto; top: 50%; left: calc(100% + 5px); transform: translateY(-50%) rotate(-45deg); }
[data-popover][data-popover-side="left"]::after    { bottom: auto; top: 50%; left: auto; right: calc(100% + 10px); transform: translateY(-50%) translateX(4px); }
[data-popover][data-popover-side="left"]::before   { bottom: auto; top: 50%; left: auto; right: calc(100% + 5px); transform: translateY(-50%) rotate(135deg); }

[data-popover]:hover::after,
[data-popover]:hover::before,
[data-popover]:focus-visible::after,
[data-popover]:focus-visible::before { opacity: 1; }
[data-popover]:hover::after,
[data-popover]:focus-visible::after { transform: translateX(-50%) translateY(0); }
[data-popover][data-popover-side="right"]:hover::after,
[data-popover][data-popover-side="right"]:focus-visible::after,
[data-popover][data-popover-side="left"]:hover::after,
[data-popover][data-popover-side="left"]:focus-visible::after { transform: translateY(-50%) translateX(0); }

/* -----------------------------------------------------------------------------
   SLIDER  .slider - custom JS slider (range input is .range above)
   -------------------------------------------------------------------------- */
.slider { position: relative; display: block; width: 100%; height: 24px; padding: 10px 0; cursor: pointer; touch-action: none; }
.slider-track { position: relative; width: 100%; height: 4px; background: var(--surface-subtle); border: 1px solid var(--border); border-radius: var(--radius-pill); }
.slider-fill  { position: absolute; inset: -1px auto -1px 0; background: var(--primary); border-radius: var(--radius-pill); }
.slider-thumb { position: absolute; top: 50%; width: 20px; height: 20px; background: var(--surface); border: 2px solid var(--primary); border-radius: var(--radius-circle); transform: translate(-50%, -50%); cursor: grab; }
.slider-thumb:active { cursor: grabbing; }

/* -----------------------------------------------------------------------------
   ICON  .icon - borderless / bordered / filled
   -------------------------------------------------------------------------- */
.icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    line-height: 1;
    color: inherit;
    background: transparent;
    border: 0;
}
.icon-xs { font-size: 16px; }
.icon-sm { font-size: 20px; }
.icon-md { font-size: 24px; }
.icon-lg { font-size: 32px; }
.icon-xl { font-size: 48px; }

.icon-bordered {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--icon-chip-radius);
    color: var(--foreground);
    background: var(--surface);
}
.icon-bordered.icon-xs { width: 24px; height: 24px; }
.icon-bordered.icon-sm { width: 32px; height: 32px; }
.icon-bordered.icon-md { width: 40px; height: 40px; }
.icon-bordered.icon-lg { width: 56px; height: 56px; }
.icon-bordered.icon-xl { width: 80px; height: 80px; }

.icon-filled {
    width: 48px; height: 48px;
    border-radius: var(--icon-chip-radius);
    background: var(--feature-1);
    color: var(--feature-1-reverse);
}
.icon-filled.icon-xs { width: 28px; height: 28px; font-size: 13px; }
.icon-filled.icon-sm { width: 36px; height: 36px; font-size: 16px; }
.icon-filled.icon-md { width: 48px; height: 48px; font-size: 20px; }
.icon-filled.icon-lg { width: 72px; height: 72px; font-size: 32px; }
.icon-filled.icon-xl { width: 96px; height: 96px; font-size: 40px; box-shadow: 0 6px 24px color-mix(in srgb, var(--feature-1) 24%, transparent); }
.icon-filled-primary   { background: var(--primary);           color: var(--primary-reverse); }
.icon-filled-secondary { background: var(--secondary);         color: var(--secondary-reverse); }
.icon-filled-success   { background: var(--success);   color: var(--success-reverse); }
.icon-filled-warning   { background: var(--warning);   color: var(--warning-reverse); }
.icon-filled-danger    { background: var(--danger);    color: var(--danger-reverse); }
.icon-filled-info      { background: var(--info);      color: var(--info-reverse); }

/* -----------------------------------------------------------------------------
   EMPTY-STATE  .empty-state  - DEPRECATED. The DS state block is .state
   (.state-empty / .state-loading / .state-error, rendered by ds_state() and
   DS.tile.state()). Kept only for legacy pages that still emit .empty-state;
   delete once every page is rebuilt.
   -------------------------------------------------------------------------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
    color: var(--foreground);
    width: 100%;
    padding: 24px;
}
.empty-state-icon {
    width: 96px;
    height: 96px;
    border-radius: var(--radius-circle);
    background: var(--feature-1);
    color: var(--feature-1-reverse);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    box-shadow: 0 6px 24px color-mix(in srgb, var(--feature-1) 24%, transparent);
}
.empty-state-title   { font: 700 20px/1.2 var(--font-display); margin: 0; }
.empty-state-message { font: 500 15px/1.55 var(--font-body); color: var(--foreground-muted); max-width: 48ch; margin: 0; }

/* -----------------------------------------------------------------------------
   OVERLAY  .overlay - full-screen darkening + modal
   -------------------------------------------------------------------------- */
.overlay {
    position: fixed; inset: 0;
    background: var(--overlay-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: var(--z-overlay);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}
.overlay[hidden] { display: none; }
.overlay-modal {
    width: 100%; max-width: 480px;
    display: flex; flex-direction: column; gap: 0;
    max-height: calc(100vh - 48px);
    background: var(--surface);
    color: var(--foreground);
    border-radius: var(--modal-radius);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}
.overlay-head  { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px 0; }
.overlay-title { font: 800 22px/1.2 var(--font-display); margin: 0; }
.overlay-body  { padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 14px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.overlay-close {
    width: 32px; height: 32px; border: 0; background: transparent; cursor: pointer;
    border-radius: var(--radius-circle); color: var(--foreground-muted); font-size: 18px;
    display: inline-flex; align-items: center; justify-content: center;
}
.overlay-close:hover { background: var(--surface-subtle); color: var(--foreground); }
.overlay-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px 24px 24px;
    border-top: 1px solid var(--border);
    background: var(--surface-subtle);
}
.overlay-foot > * { flex-shrink: 0; }

/* -----------------------------------------------------------------------------
   OVERLAY variants
   .overlay-hero  - add a tall, coloured strip at the top with the heading in it.
                    Pairs with the auth flow where the modal is the whole screen's
                    focus and the header is a short visual statement.
   .overlay-modal-lg / .overlay-modal-xl - wider panels for forms with two fields
                    side by side or long content.
   -------------------------------------------------------------------------- */
.overlay-modal.overlay-modal-hero > .overlay-head {
    padding: 112px 32px 48px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--primary-reverse);
    border-radius: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    position: relative;
}
.overlay-modal.overlay-modal-hero > .overlay-head > .overlay-title {
    color: inherit;
    font: 900 32px/1.1 var(--font-display);
    letter-spacing: -0.02em;
}
.overlay-modal.overlay-modal-hero > .overlay-head > .overlay-subtitle {
    color: inherit;
    opacity: 0.88;
    font: 500 14px/1.4 var(--font-body);
    margin: 0;
}
.overlay-modal.overlay-modal-hero > .overlay-head > .overlay-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}
.overlay-modal.overlay-modal-hero > .overlay-head > .overlay-close:hover {
    background: rgba(255, 255, 255, 0.3);
    color: #fff;
}
.overlay-modal.overlay-modal-hero > .overlay-body {
    padding: 28px 32px 20px;
    gap: 16px;
}
.overlay-modal.overlay-modal-hero > .overlay-foot {
    padding: 14px 32px 20px;
}

/* Colour variants for the hero strip, in case the auth modal isn't always
   primary (e.g. a success state uses success). */
.overlay-modal.overlay-modal-hero.overlay-modal-hero-success > .overlay-head { background: linear-gradient(135deg, var(--success), var(--feature-1)); color: var(--success-reverse, var(--foreground)); }
.overlay-modal.overlay-modal-hero.overlay-modal-hero-danger  > .overlay-head { background: linear-gradient(135deg, var(--danger),  var(--secondary)); color: var(--danger-reverse,  #fff); }

/* Spotlight search variant */
.overlay-spotlight {
    align-items: flex-start;
    padding-top: 14vh;
}
.overlay-spotlight .overlay-modal {
    max-width: 640px;
}
.spotlight-input {
    display: flex; align-items: center; gap: 14px;
    padding: 0 20px;
    height: 60px;
    border-bottom: 1px solid var(--border);
}
.spotlight-input > i { color: var(--foreground-muted); font-size: 18px; }
.spotlight-input > input {
    flex: 1; min-width: 0;
    border: 0; background: transparent;
    font: 500 17px/1 var(--font-body);
    color: var(--foreground);
    outline: none;
}
.spotlight-list { max-height: 50vh; overflow-y: auto; padding: 8px; }

/* Richer spotlight - default state shows a Top Ten header + rank rows */
.spotlight-section-label {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px 6px;
    font: 700 10px/1 var(--font-body);
    color: var(--foreground-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.spotlight-section-label .chip { text-transform: none; letter-spacing: 0; }

/* -----------------------------------------------------------------------------
   SEARCH-RESULT  .search-result - a row in a search results list
   -------------------------------------------------------------------------- */
.search-result {
    display: flex;
    gap: 14px;
    padding: 12px;
    border-radius: var(--item-radius);
    background: var(--surface);
    border: 1px solid var(--border);
    align-items: center;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: background 120ms, border-color 120ms;
}
.search-result:hover { background: var(--primary-subtle); text-decoration: none; }
.search-result-rank {
    width: 32px; height: 32px;
    border-radius: var(--radius-circle);
    background: var(--primary);
    color: var(--primary-reverse);
    display: inline-flex; align-items: center; justify-content: center;
    font: 800 13px/1 var(--font-body);
    flex-shrink: 0;
}
.search-result-rank.is-top3 { background: var(--secondary); color: var(--secondary-reverse); }
.search-result-cover {
    width: 48px; height: 48px;
    border-radius: var(--thumb-radius);
    background: linear-gradient(135deg, var(--feature-2), var(--feature-3));
    flex-shrink: 0;
    overflow: hidden;
}
.search-result-cover > img { width: 100%; height: 100%; object-fit: cover; }
.search-result-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.search-result-title  { font: 700 15px/1.3 var(--font-display); color: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result-artist { font: 500 13px/1.3 var(--font-body); color: inherit; opacity: 0.7; }
.search-result-meta   { display: flex; align-items: center; gap: 12px; margin-top: 4px; font: 500 11px/1 var(--font-body); color: inherit; opacity: 0.6; }
.search-result-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.search-result mark {
    background: color-mix(in srgb, var(--feature-4) 60%, transparent);
    color: var(--foreground);
    padding: 0 2px;
    border-radius: 3px;
}

/* Empty-and-default search state header */
.spotlight-empty {
    padding: 40px 24px;
    text-align: center;
    color: var(--foreground-muted);
}
.spotlight-empty > i { font-size: 28px; margin-bottom: 10px; display: block; }

/* Spotlight filter chips row */
.spotlight-filters {
    display: flex; gap: 6px; padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}
.spotlight-filters .chip {
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--foreground-muted);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 600;
    font-size: 12px;
    height: 28px;
    padding: 0 12px;
}
.spotlight-filters .chip.is-active {
    background: var(--primary);
    color: var(--primary-reverse);
    border-color: var(--primary);
}

/* -----------------------------------------------------------------------------
   THEME EDITOR  .theme-editor - a slide-in panel for live visual rebranding
   -------------------------------------------------------------------------- */
.theme-editor {
    position: fixed;
    top: 0; right: 0;
    width: 440px; max-width: 100vw;
    height: 100vh;
    background: var(--surface);
    border-left: 1px solid var(--border);
    z-index: var(--z-toast);
    display: flex; flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: ds-slide-in-right 300ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.theme-editor[hidden] { display: none; }
.theme-editor-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.theme-editor-title { font: 800 17px/1 var(--font-display); margin: 0; }
.theme-editor-mode { display: flex; }
.theme-editor-nav {
    display: flex; gap: 2px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    background: var(--background-subtle);
}
.theme-editor-nav a {
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    font: 600 12px/1 var(--font-body);
    color: var(--foreground-muted);
    white-space: nowrap;
    text-decoration: none;
}
.theme-editor-nav a:hover { background: var(--surface); color: var(--foreground); text-decoration: none; }
.theme-editor-nav a.is-active { background: var(--primary); color: var(--primary-reverse); }
.theme-editor-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex; flex-direction: column; gap: 24px;
}
.theme-editor-section { display: flex; flex-direction: column; gap: 10px; }
.theme-editor-section[hidden] { display: none; }
.theme-editor-section > h3 { font: 800 15px/1 var(--font-body); margin: 0; }
.theme-editor-section > p  { font: 500 13px/1.45 var(--font-body); color: var(--foreground-muted); margin: 0; }
.theme-editor-foot {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex; justify-content: space-between; gap: 10px;
}

/* Theme preset card */
.theme-preset-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.theme-preset {
    display: flex; flex-direction: column; gap: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    cursor: pointer;
    text-align: left;
    transition: border-color 120ms, transform 120ms;
    font-family: inherit;
    color: inherit;
}
.theme-preset:hover { transform: translateY(-1px); border-color: var(--primary-muted); }
.theme-preset.is-active { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 30%, transparent); }
.theme-preset-swatches { display: flex; gap: 2px; height: 20px; border-radius: var(--radius-xs); overflow: hidden; }
.theme-preset-swatches > span { flex: 1; }
/* Shape-preset previews don't need a container overflow-clip because each
   swatch is a standalone capsule with its own radius; give the row some
   breathing gap and a slightly taller height so the radii read clearly. */
.theme-preset-swatches.theme-preset-shapes { gap: 6px; height: 22px; overflow: visible; border-radius: 0; }
.theme-preset-name { font: 700 13px/1 var(--font-display); color: var(--foreground); }
.theme-preset-desc { font: 500 11px/1.3 var(--font-body); color: var(--foreground-muted); }

/* Token row - a label + a color input + the token name */
.token-row {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 0;
}
.token-row-swatch {
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}
.token-row-swatch > input[type="color"] {
    position: absolute; inset: 0;
    opacity: 0; cursor: pointer;
    width: 100%; height: 100%;
    border: 0;
}
.token-row-name { font: 600 12px/1.2 var(--font-mono); color: var(--foreground); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.token-row-hex  { font: 500 11px/1 var(--font-mono); color: var(--foreground-muted); }

/* Custom CSS area */
.theme-css-area {
    width: 100%;
    min-height: 200px;
    padding: 12px;
    background: var(--background-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font: 500 12px/1.5 var(--font-mono);
    color: var(--foreground);
    resize: vertical;
    outline: none;
}
.theme-css-area:focus { border-color: var(--primary); }

/* Advanced-only sections hide in simple mode */
.theme-editor[data-mode="simple"] .is-advanced-only { display: none; }

/* Elements editor section headers (one per variant) */
.elements-section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 16px;
    padding: 8px 0 4px;
    border-top: 1px solid var(--border);
}
.elements-section-header:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.elements-section-title {
    font: 700 11px/1 var(--font-body);
    color: var(--foreground-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.elements-section-toggle {
    width: 28px; height: 28px; padding: 0;
}
.elements-section-body {
    display: flex; flex-direction: column;
}

/* -----------------------------------------------------------------------------
   TOOLBAR  .toolbar  -  base rules live with .tab-bar above (same family).
   This block adds the one toolbar-only utility.
   -------------------------------------------------------------------------- */
.toolbar-grow { flex: 1; min-width: 0; }

/* -----------------------------------------------------------------------------
   TYPOGRAPHY utility classes
   -------------------------------------------------------------------------- */
/* Display and Heading share --font-display. Body text uses --font-body.
   Every size multiplies by --font-scale so the whole scale resizes together. */
.display-xl { font: 900 calc(56px * var(--font-scale))/1.0  var(--font-display); letter-spacing: -0.035em; }
.display-lg { font: 900 calc(44px * var(--font-scale))/1.0  var(--font-display); letter-spacing: -0.03em; }
.heading-1  { font: 800 calc(32px * var(--font-scale))/1.15 var(--font-display); letter-spacing: -0.025em; }
.heading-2  { font: 800 calc(24px * var(--font-scale))/1.2  var(--font-display); letter-spacing: -0.02em; }
.heading-3  { font: 700 calc(20px * var(--font-scale))/1.25 var(--font-display); letter-spacing: -0.015em; }
.heading-4  { font: 700 calc(17px * var(--font-scale))/1.3  var(--font-display); letter-spacing: -0.01em; }
.text-lg    { font: 500 calc(17px * var(--font-scale))/1.55 var(--font-body); }
.text-base  { font: 450 calc(15px * var(--font-scale))/1.55 var(--font-body); }
.text-sm    { font: 500 calc(13px * var(--font-scale))/1.45 var(--font-body); }
.text-xs    { font: 600 calc(12px * var(--font-scale))/1.4  var(--font-body); letter-spacing: 0.02em; }
.mono-sm    { font: 500 calc(12px * var(--font-scale))/1.45 var(--font-mono); }

/* Text colours */
.text-muted   { color: var(--foreground-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }
.text-info    { color: var(--info); }

/* =============================================================================
   ANIMATION LIBRARY
   Keyframes + utility classes. Compose them with a duration modifier.
     .anim-fade-in            default 300ms ease-out
     .anim-fade-in.anim-fast  150ms
     .anim-fade-in.anim-slow  600ms
   Containers with .anim-stagger > * get a 60ms delay per child, up to 10.
   Any element with .anim-on-view holds opacity: 0 until it scrolls in.
   Respect prefers-reduced-motion.
   ========================================================================== */

@keyframes ds-fade-in       { from { opacity: 0 } to { opacity: 1 } }
@keyframes ds-fade-in-up    { from { opacity: 0; transform: translateY(12px) } to { opacity: 1; transform: translateY(0) } }
@keyframes ds-fade-in-down  { from { opacity: 0; transform: translateY(-12px) } to { opacity: 1; transform: translateY(0) } }
@keyframes ds-slide-in-right{ from { opacity: 0; transform: translateX(16px) } to { opacity: 1; transform: translateX(0) } }
@keyframes ds-slide-in-left { from { opacity: 0; transform: translateX(-16px) } to { opacity: 1; transform: translateX(0) } }
@keyframes ds-scale-in      { from { opacity: 0; transform: scale(0.95) } to { opacity: 1; transform: scale(1) } }
@keyframes ds-pop           { 0% { transform: scale(0.85) } 60% { transform: scale(1.06) } 100% { transform: scale(1) } }
@keyframes ds-bounce        { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-8px) } }
@keyframes ds-pulse         { 0%, 100% { transform: scale(1); opacity: 1 } 50% { transform: scale(1.04); opacity: 0.85 } }
@keyframes ds-shake         { 0%, 100% { transform: translateX(0) } 20%, 60% { transform: translateX(-4px) } 40%, 80% { transform: translateX(4px) } }
@keyframes ds-float         { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-6px) } }
@keyframes ds-shimmer       { from { background-position: 200% 0 } to { background-position: -200% 0 } }
@keyframes ds-wiggle        { 0%, 100% { transform: rotate(0) } 25% { transform: rotate(-3deg) } 75% { transform: rotate(3deg) } }

/* PING - a halo that radiates out from the element and fades. Uses box-shadow
   so the element's own background keeps its colour. --ping-color defaults to
   a translucent primary; variants swap it. If parent clips with overflow:hidden
   the ring is cut off, so place .anim-ping inside something unclipped. */
@keyframes ds-ping {
    0%        { box-shadow: 0 0 0 0 var(--ping-color); }
    70%, 100% { box-shadow: 0 0 0 16px transparent; }
}

/* BREATHE - subtle in-place scale pulse */
@keyframes ds-breathe {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.04); }
}

/* GLOW - soft shadow that pulses in intensity */
@keyframes ds-glow {
    0%, 100% { box-shadow: 0 0 0 0 var(--glow-color); }
    50%      { box-shadow: 0 0 18px 4px var(--glow-color); }
}

/* FLASH - quick opacity flicker for attention */
@keyframes ds-flash {
    0%, 100% { opacity: 1; }
    20%, 60% { opacity: 0.35; }
}

/* SLIDE from top / bottom - edge-anchored entrances */
@keyframes ds-slide-in-up    { from { opacity: 0; transform: translateY(20px) } to { opacity: 1; transform: translateY(0) } }
@keyframes ds-slide-in-down  { from { opacity: 0; transform: translateY(-20px) } to { opacity: 1; transform: translateY(0) } }

/* FADE OUT - companion to the fade-in entrances */
@keyframes ds-fade-out       { from { opacity: 1 } to { opacity: 0 } }
@keyframes ds-fade-out-down  { from { opacity: 1; transform: translateY(0) } to { opacity: 0; transform: translateY(12px) } }

/* Durations - attach to any .anim-* class */
.anim-fast    { animation-duration: 300ms; }
.anim-slow    { animation-duration: 900ms; }
.anim-slower  { animation-duration: 1400ms; }

/* Common fill/easing - 600ms default so entrances feel settled, not snappy.
   Use .anim-fast (300ms) for interactions, .anim-slow (900ms) for heroes. */
.anim-fade-in,
.anim-fade-in-up,
.anim-fade-in-down,
.anim-slide-in-right,
.anim-slide-in-left,
.anim-scale-in,
.anim-pop {
    animation-duration: 600ms;
    animation-fill-mode: both;
    animation-timing-function: cubic-bezier(0.2, 0.7, 0.2, 1);
}

.anim-fade-in         { animation-name: ds-fade-in; }
.anim-fade-in-up      { animation-name: ds-fade-in-up; }
.anim-fade-in-down    { animation-name: ds-fade-in-down; }
.anim-slide-in-right  { animation-name: ds-slide-in-right; }
.anim-slide-in-left   { animation-name: ds-slide-in-left; }
.anim-scale-in        { animation-name: ds-scale-in; }
.anim-pop             { animation-name: ds-pop; animation-duration: 240ms; }

/* Continuous animations - loop while the user allows motion */
.anim-bounce   { animation: ds-bounce 1200ms ease-in-out var(--anim-iteration); }
.anim-pulse    { animation: ds-pulse 1400ms ease-in-out var(--anim-iteration); }
.anim-float    { animation: ds-float 2400ms ease-in-out var(--anim-iteration); }
.anim-wiggle   { animation: ds-wiggle 800ms ease-in-out var(--anim-iteration); }
.anim-breathe  { animation: ds-breathe 2200ms ease-in-out var(--anim-iteration); }
.anim-flash    { animation: ds-flash 1400ms ease-in-out var(--anim-iteration); }

/* Ping - radiating halo. Default uses primary; variants swap the colour. */
.anim-ping {
    --ping-color: color-mix(in srgb, var(--primary) 45%, transparent);
    animation: ds-ping 1400ms cubic-bezier(0, 0, 0.2, 1) var(--anim-iteration);
}
.anim-ping-primary   { --ping-color: color-mix(in srgb, var(--primary)   45%, transparent); }
.anim-ping-secondary { --ping-color: color-mix(in srgb, var(--secondary) 45%, transparent); }
.anim-ping-success   { --ping-color: color-mix(in srgb, var(--success)   45%, transparent); }
.anim-ping-warning   { --ping-color: color-mix(in srgb, var(--warning)   50%, transparent); }
.anim-ping-danger    { --ping-color: color-mix(in srgb, var(--danger)    45%, transparent); }
.anim-ping-info      { --ping-color: color-mix(in srgb, var(--info)      45%, transparent); }
.anim-ping-feature-1 { --ping-color: color-mix(in srgb, var(--feature-1) 55%, transparent); }
.anim-ping-feature-2 { --ping-color: color-mix(in srgb, var(--feature-2) 55%, transparent); }

/* Glow - soft shadow pulse. Same colour variants. */
.anim-glow {
    --glow-color: color-mix(in srgb, var(--primary) 40%, transparent);
    animation: ds-glow 2000ms ease-in-out var(--anim-iteration);
}
.anim-glow-primary   { --glow-color: color-mix(in srgb, var(--primary)   40%, transparent); }
.anim-glow-secondary { --glow-color: color-mix(in srgb, var(--secondary) 40%, transparent); }
.anim-glow-success   { --glow-color: color-mix(in srgb, var(--success)   40%, transparent); }
.anim-glow-warning   { --glow-color: color-mix(in srgb, var(--warning)   50%, transparent); }
.anim-glow-danger    { --glow-color: color-mix(in srgb, var(--danger)    40%, transparent); }
.anim-glow-info      { --glow-color: color-mix(in srgb, var(--info)      40%, transparent); }

/* Edge-anchored entrance slides */
.anim-slide-in-up,
.anim-slide-in-down,
.anim-fade-out,
.anim-fade-out-down {
    animation-duration: 300ms;
    animation-fill-mode: both;
    animation-timing-function: cubic-bezier(0.2, 0.7, 0.2, 1);
}
.anim-slide-in-up   { animation-name: ds-slide-in-up; }
.anim-slide-in-down { animation-name: ds-slide-in-down; }
.anim-fade-out      { animation-name: ds-fade-out; }
.anim-fade-out-down { animation-name: ds-fade-out-down; }

/* One-shot attention animations */
.anim-shake    { animation: ds-shake 420ms ease-in-out; animation-fill-mode: both; }

/* Stagger - each child gets ~140ms more delay than the one before. */
.anim-stagger > *:nth-child(1)  { animation-delay:    0ms; }
.anim-stagger > *:nth-child(2)  { animation-delay:  140ms; }
.anim-stagger > *:nth-child(3)  { animation-delay:  280ms; }
.anim-stagger > *:nth-child(4)  { animation-delay:  420ms; }
.anim-stagger > *:nth-child(5)  { animation-delay:  560ms; }
.anim-stagger > *:nth-child(6)  { animation-delay:  700ms; }
.anim-stagger > *:nth-child(7)  { animation-delay:  840ms; }
.anim-stagger > *:nth-child(8)  { animation-delay:  980ms; }
.anim-stagger > *:nth-child(9)  { animation-delay: 1120ms; }
.anim-stagger > *:nth-child(10) { animation-delay: 1260ms; }

/* Reveal on scroll - the JS flips .is-in when the element intersects */
.anim-on-view            { opacity: 0; transform: translateY(12px); transition: opacity 400ms ease-out, transform 400ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.anim-on-view.is-in      { opacity: 1; transform: translateY(0); }

/* Hover lifts - sit on anything and animate up on hover */
.hover-lift             { transition: transform 160ms, box-shadow 160ms; }
.hover-lift:hover       { transform: translateY(-2px); box-shadow: 0 8px 24px color-mix(in srgb, var(--foreground) 10%, transparent); }
.hover-scale            { transition: transform 160ms; }
.hover-scale:hover      { transform: scale(1.03); }

/* Respect reduced-motion via a token swap - no !important needed because
   every animation here reads from these tokens. */
:root {
    --anim-duration:   300ms;
    --anim-iteration:  infinite;
}
@media (prefers-reduced-motion: reduce) {
    :root {
        --anim-duration:   1ms;
        --anim-iteration:  1;
    }
}

/* =============================================================================
   LOADING / PAGE TRANSITIONS
   ========================================================================== */

/* Full-page entrance: the page fades up on load, and every .section inside
   .page-enter staggers in. Add class="page-enter" to <body> or to the page shell.
   Durations slowed and stagger stretched so the content arrives in a readable
   cascade instead of a near-simultaneous flash. */
.page-enter { animation: ds-fade-in 700ms ease-out both; }
.page-enter .section,
.page-enter .page-header,
.page-enter .card,
.page-enter .header-inner,
.page-enter .footer-inner {
    animation: ds-fade-in-up 800ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.page-enter > * > :nth-child(1),
.page-enter .page-container > :nth-child(1)  { animation-delay:   0ms; }
.page-enter > * > :nth-child(2),
.page-enter .page-container > :nth-child(2)  { animation-delay: 140ms; }
.page-enter > * > :nth-child(3),
.page-enter .page-container > :nth-child(3)  { animation-delay: 260ms; }
.page-enter > * > :nth-child(4),
.page-enter .page-container > :nth-child(4)  { animation-delay: 380ms; }
.page-enter > * > :nth-child(5),
.page-enter .page-container > :nth-child(5)  { animation-delay: 500ms; }
.page-enter > * > :nth-child(6),
.page-enter .page-container > :nth-child(6)  { animation-delay: 620ms; }
.page-enter > * > :nth-child(7),
.page-enter .page-container > :nth-child(7)  { animation-delay: 740ms; }
.page-enter > * > :nth-child(8),
.page-enter .page-container > :nth-child(8)  { animation-delay: 860ms; }

/* Top-of-page loading bar - toggle DS.startLoading() / stopLoading() */
.loading-bar {
    position: fixed; top: 0; left: 0; right: 0;
    height: 3px;
    background: color-mix(in srgb, var(--primary) 20%, transparent);
    overflow: hidden;
    z-index: var(--z-toast);
    pointer-events: none;
}
.loading-bar::before {
    content: "";
    position: absolute; top: 0; bottom: 0; left: 0;
    width: 30%;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    animation: ds-loading-bar 1200ms ease-in-out infinite;
}
@keyframes ds-loading-bar {
    0%   { left: -30%; }
    100% { left: 100%; }
}

/* Loading dots - inline three-dot bouncer */
.loading-dots {
    display: inline-flex; align-items: center; gap: 4px;
}
.loading-dots > span {
    width: 6px; height: 6px;
    border-radius: var(--radius-circle);
    background: var(--primary);
    animation: ds-dots 900ms ease-in-out infinite both;
}
.loading-dots > span:nth-child(2) { animation-delay: 150ms; }
.loading-dots > span:nth-child(3) { animation-delay: 300ms; }
@keyframes ds-dots {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%           { transform: scale(1);   opacity: 1; }
}

/* Loading screen - full-page centered loader, fades out when removed */
.loading-screen {
    position: fixed; inset: 0; z-index: var(--z-escape);
    background: var(--background);
    display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 16px;
    animation: ds-fade-in 200ms ease-out;
}
.loading-screen.is-leaving { animation: ds-fade-in 300ms ease-in reverse both; }
.loading-screen-logo {
    width: 56px; height: 56px;
    border-radius: var(--radius-circle);
    background: var(--primary);
    color: var(--primary-reverse);
    display: inline-flex; align-items: center; justify-content: center;
    font: 900 24px/1 var(--font-display);
    animation: ds-pulse 1200ms ease-in-out infinite;
}
.loading-screen-text { font: 500 13px/1 var(--font-body); color: var(--foreground-muted); }

/* -----------------------------------------------------------------------------
   CARD FAMILY  .card-* - content cards for every Muzooi surface
   Each one extends .card by overriding what it needs.
   -------------------------------------------------------------------------- */

/* GRID helper - lay cards out on a responsive grid.
   TWO standard tile widths across the whole DS: default (wide) and small.
   Every content card (song, album, artist, playlist, blog, mood, vibe grid)
   renders at the default width so grids read as one system. .card-grid-sm is
   reserved for dense secondary lists (admin, skeletons, inline rows).
   The minmax floor is the card's usable-size floor: grid cells never shrink
   below it, so cards never become unusable, but at wider viewports every cell
   scales up to 1fr. This is where the "usable minimum width" rule lives, NOT
   on .card itself (which would cause overflow in narrower containers). */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--item-gap);
}
.card-grid-sm { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
/* File grid: small cards, three across in the media library column. */
.card-grid-files { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
/* Kept as an alias for the few places that already used it; identical to the
   default now so songs, blogs, playlists and vibes render at one width. */
.card-grid-lg { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* -------- SONG card: square cover + artist avatar + title + artist + play -------- */
.card-song {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    cursor: pointer;
    transition: transform 160ms, box-shadow 160ms;
}
.card-song:hover { transform: translateY(-2px); box-shadow: 0 8px 24px color-mix(in srgb, var(--foreground) 10%, transparent); }
/* Song media is 16:9 to match the YouTube preview aspect that most songs
   are sourced from. SoundCloud and other-source songs crop into the same
   frame so the grid reads as one shape per row. */
.song-media { position: relative; aspect-ratio: 16 / 9; background: var(--surface-subtle); }
.song-media > img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Artist avatar on a song card: small circle on the top-left. Optional — the
   live song tile shows it only when a creator avatar is set. */
.song-artist-avatar {
    position: absolute; left: 10px; top: 10px;
    width: 32px; height: 32px;
    border-radius: var(--radius-circle);
    border: 2px solid var(--surface);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--primary-reverse);
    display: inline-flex; align-items: center; justify-content: center;
    font: 800 12px/1 var(--font-display);
    overflow: hidden;
    box-shadow: 0 4px 10px color-mix(in srgb, var(--foreground) 20%, transparent);
}
.song-artist-avatar > img { width: 100%; height: 100%; object-fit: cover; }

.song-body    { padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.song-title   { font: 700 14px/1.3 var(--font-display); color: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-artist  { font: 500 12px/1.3 var(--font-body); color: inherit; opacity: 0.7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-stats   { display: flex; align-items: center; gap: 10px; margin-top: 6px; font: 500 11px/1 var(--font-body); color: inherit; opacity: 0.7; }

/* Platform badge (YouTube, SoundCloud, Spotify) sits top-LEFT - matches the
   live song tile which anchors the source identifier there. Keep the fill
   neutral dark so the cover reads cleanly; brand colours hit as the badge
   icon tint if a variant is set. */
.song-platform {
    position: absolute; left: 10px; top: 10px;
    width: 28px; height: 28px;
    border-radius: var(--radius-circle);
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px;
    pointer-events: none;
}
.song-platform > :is(i, svg) { width: 1em; height: 1em; }
.song-platform.song-platform-youtube    > :is(i, svg) { color: #ff2929; }
.song-platform.song-platform-soundcloud > :is(i, svg) { color: #ff8c47; }
.song-platform.song-platform-spotify    > :is(i, svg) { color: #1ed760; }
.song-platform.song-platform-apple      > :is(i, svg) { color: #fa2d48; }

/* PLAYABLE MEDIA  .song-media-playable - the same .song-media with a centred
   play control. Clicking swaps it for .song-media-player (the platform embed
   filling the same 16:9 frame). .song-media-brand is the artwork-less
   placeholder for audio platforms; .song-media-empty when nothing can play. */
.song-media { overflow: hidden; }
.song-media-playable { cursor: pointer; }
.song-media-play {
    position: absolute; left: 50%; top: 50%;
    width: 56px; height: 56px;
    margin: -28px 0 0 -28px;
    border-radius: var(--radius-circle);
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 20px;
    pointer-events: none;
    transition: background 140ms, transform 140ms;
}
.song-media-play > :is(i, svg) { width: 1em; height: 1em; margin-left: 3px; }
.song-media-playable:hover .song-media-play,
.song-media-playable:focus-visible .song-media-play { background: var(--primary); color: var(--primary-reverse); transform: scale(1.06); }
.song-media-score {
    position: absolute; right: 10px; top: 10px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font: 700 12px/1.2 var(--font-body);
}
.song-media-brand,
.song-media-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    font: 700 14px/1.2 var(--font-body);
}
.song-media-brand { background: var(--brand, var(--surface-subtle)); color: #fff; }
.song-media-brand-icon { font-size: 40px; width: 40px; height: 40px; }
.song-media-brand > .song-media-play { display: none; }
.song-media-empty { color: var(--foreground-muted); }
.song-media-empty > :is(i, svg) { font-size: 28px; width: 28px; height: 28px; }
.song-media-player > iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Song actions row sits at the bottom of the card body. First item is the
   thumbs-up count (also interactive), then edit, flag, spacer, open-arrow.
   All children share the same icon-button sizing so they read as one strip. */
.song-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.song-actions-spacer { flex: 1; }
.song-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 10px;
    border: 0;
    background: transparent;
    color: var(--foreground-muted);
    /* Inline button-family control, so it tracks --btn-radius. */
    border-radius: var(--btn-radius);
    font: 600 13px/1 var(--font-body);
    cursor: pointer;
    transition: background 120ms, color 120ms;
}
.song-action:hover { background: var(--surface-subtle); color: var(--foreground); }
.song-action > i { font-size: 14px; }
/* The thumbs-up count sits first and reads as the primary vote affordance. */
.song-action.song-action-vote { font-weight: 700; color: var(--foreground); }
.song-action.song-action-vote.is-voted { color: var(--primary); }

/* -------- ARTIST card: wide hero image across the top with a small logo mark
   bottom-left and a genre chip top-right; underneath, the artist name, member
   date, and a strip of three feature-coloured stat tiles (releases, videos,
   views). Matches the content the live artist page renders. -------- */
.card-artist {
    padding: 0;
    overflow: hidden;
    display: flex; flex-direction: column;
    min-height: 260px;
}
.artist-hero {
    aspect-ratio: 32 / 27; /* 3x taller than the old 32:9 strip */
    background: linear-gradient(135deg, var(--feature-2), var(--feature-3));
    background-size: cover;
    background-position: center;
    position: relative;
}
.artist-hero > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.artist-hero-logo {
    position: absolute; left: 16px; top: 16px;
    width: 48px; height: 48px;
    border-radius: var(--radius-circle);
    background: rgba(255, 255, 255, 0.92);
    color: var(--foreground);
    display: inline-flex; align-items: center; justify-content: center;
    font: 800 18px/1 var(--font-display);
    overflow: hidden;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--foreground) 20%, transparent);
}
.artist-hero-logo > img { width: 100%; height: 100%; object-fit: cover; }
.artist-hero-genre {
    position: absolute; right: 16px; top: 16px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font: 700 11px/1 var(--font-body);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.artist-body {
    padding: 16px 20px 20px;
}
.artist-name  { font: 800 20px/1.2 var(--font-display); color: var(--primary); margin: 0 0 4px; letter-spacing: -0.015em; }
.artist-meta  { font: 500 13px/1.3 var(--font-body); color: var(--foreground-muted); margin-bottom: 14px; }
.artist-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
/* The three stats are proper .tile.tile-stat tiles (rectangular surfaces with
   radius), not pills. Each carries a feature colour. */
.artist-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 14px 10px;
    border-radius: var(--tile-radius, var(--radius-md));
    font: 500 11px/1.2 var(--font-body);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    gap: 4px;
}
.artist-stat > strong {
    display: block;
    font: 800 22px/1.1 var(--font-display);
}
.artist-stat.artist-stat-releases { background: var(--feature-1); color: var(--feature-1-reverse); }
.artist-stat.artist-stat-videos   { background: var(--feature-2); color: var(--feature-2-reverse); }
.artist-stat.artist-stat-views    { background: var(--feature-3); color: var(--feature-3-reverse); }

/* -------- ALBUM card: square cover + title + artist + year chip -------- */
.card-album {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.album-cover { aspect-ratio: 1; background: var(--surface-subtle); }
.album-cover > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-body  { padding: 12px 14px; }
.album-title { font: 700 14px/1.3 var(--font-display); color: inherit; margin: 0 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.album-artist{ font: 500 12px/1.3 var(--font-body); color: inherit; opacity: 0.7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.album-year  { font: 600 11px/1 var(--font-mono); color: inherit; opacity: 0.55; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 6px; display: inline-block; }

/* -------- PLAYLIST card: wide cover with a dark "N songs" chip in the
   bottom-right, title in the primary colour, "by Creator" line, and a stats
   row with play count and heart count. Matches the content the live playlists
   page renders. -------- */
.card-playlist {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.playlist-cover {
    aspect-ratio: 8 / 9; /* 2x taller than the old 16:9 */
    background: linear-gradient(135deg, var(--feature-2), var(--feature-3));
    background-size: cover;
    background-position: center;
    position: relative;
    display: block;
}
/* Creator avatar sits top-right on the cover so each tile credits its curator
   without taking footer space. */
.playlist-creator-avatar {
    position: absolute; right: 12px; top: 12px;
    width: 36px; height: 36px;
    border-radius: var(--radius-circle);
    border: 2px solid rgba(255, 255, 255, 0.92);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--primary-reverse);
    display: inline-flex; align-items: center; justify-content: center;
    font: 800 13px/1 var(--font-display);
    overflow: hidden;
    box-shadow: 0 2px 10px color-mix(in srgb, var(--foreground) 24%, transparent);
    text-decoration: none;
}
.playlist-creator-avatar > img { width: 100%; height: 100%; object-fit: cover; }
.playlist-cover > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.playlist-count-chip {
    position: absolute; right: 12px; bottom: 12px;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font: 700 11px/1 var(--font-body);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    pointer-events: none;
}
.playlist-mosaic {
    aspect-ratio: 16 / 9;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 0;
}
.playlist-mosaic > div { background: var(--surface-subtle); }
.playlist-mosaic > div:nth-child(1) { background: linear-gradient(135deg, var(--feature-1), var(--feature-2)); }
.playlist-mosaic > div:nth-child(2) { background: linear-gradient(135deg, var(--feature-3), var(--feature-4)); }
.playlist-mosaic > div:nth-child(3) { background: linear-gradient(135deg, var(--primary), var(--secondary)); }
.playlist-mosaic > div:nth-child(4) { background: linear-gradient(135deg, var(--feature-2), var(--feature-1)); }
.playlist-body  { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 2px; }
.playlist-title { font: 800 16px/1.3 var(--font-display); color: var(--primary); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -0.01em; }
.playlist-author { font: 500 13px/1.3 var(--font-body); color: var(--foreground-muted); margin: 2px 0 10px; }
.playlist-author > a { color: var(--primary); font-weight: 600; }
.playlist-stats {
    display: flex;
    align-items: center;
    gap: 14px;
    font: 500 13px/1 var(--font-body);
    color: var(--foreground-muted);
}
.playlist-stats > span { display: inline-flex; align-items: center; gap: 6px; }
.playlist-meta  { font: 500 12px/1.3 var(--font-body); color: inherit; opacity: 0.7; }

/* -------- BLOG / POST card: wide cover + title + excerpt + meta -------- */
.card-blog {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.blog-cover { aspect-ratio: 16 / 9; background: var(--surface-subtle); position: relative; }
.blog-cover > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.blog-cover > .chip { position: absolute; top: 12px; left: 12px; }
.blog-body    { padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.blog-title   { font: 700 17px/1.3 var(--font-display); color: inherit; margin: 0; letter-spacing: -0.01em; }
.blog-excerpt { font: 500 14px/1.5 var(--font-body); color: inherit; opacity: 0.75; margin: 0; }
.blog-meta    { display: flex; align-items: center; gap: 8px; font: 500 12px/1 var(--font-body); color: inherit; opacity: 0.7; margin-top: 4px; }
.blog-meta::before { content: "·"; opacity: 0; }
.blog-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; position: relative; z-index: 2; }

/* -------- MOOD card: a two-part tile for a mood or auto-playlist. Colour-filled
   hero with an icon + name on top, neutral info strip with stats and actions
   beneath. The colour variants paint ONLY the hero, so the info strip stays on
   the quiet DS surface. Used on the moods page. (Previously .card-vibe; the
   .card-vibe name now belongs to the vote-page hero tile below.) -------- */
.card-mood {
    padding: 0;
    border: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    cursor: pointer;
    transition: transform 160ms, box-shadow 160ms;
    background: var(--surface);
    color: var(--foreground);
}
.card-mood:hover { transform: translateY(-2px); box-shadow: 0 8px 24px color-mix(in srgb, var(--foreground) 10%, transparent); }
.mood-hero {
    aspect-ratio: 4 / 3;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: linear-gradient(135deg, var(--feature-1), var(--feature-2));
    color: var(--feature-1-reverse);
    position: relative;
}
.mood-icon     { font-size: 36px; opacity: 0.55; }
.mood-name     { font: 900 24px/1.05 var(--font-display); letter-spacing: -0.02em; margin: 0; color: inherit; }
.mood-subtitle { font: 500 12px/1.3 var(--font-body); opacity: 0.8; margin-top: 4px; color: inherit; }

/* Colour variants paint the HERO only. */
.card-mood.card-mood-primary   > .mood-hero { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: var(--primary-reverse); }
.card-mood.card-mood-feature-1 > .mood-hero { background: linear-gradient(135deg, var(--feature-1), var(--feature-2)); color: var(--feature-1-reverse); }
.card-mood.card-mood-feature-2 > .mood-hero { background: linear-gradient(135deg, var(--feature-2), var(--feature-4)); color: var(--feature-2-reverse); }
.card-mood.card-mood-feature-3 > .mood-hero { background: linear-gradient(135deg, var(--feature-3), var(--primary)); color: var(--feature-3-reverse); }
.card-mood.card-mood-feature-4 > .mood-hero { background: linear-gradient(135deg, var(--feature-4), var(--secondary)); color: var(--feature-4-reverse); }

.mood-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px 10px 14px;
    min-height: 56px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}
.mood-info-meta {
    display: inline-flex;
    align-items: baseline;
    gap: 16px;
    font: 500 13px/1.3 var(--font-body);
    color: var(--foreground-muted);
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
}
.mood-info-meta > span { display: inline-flex; align-items: baseline; gap: 6px; }
.mood-info-meta strong { color: var(--foreground); font-weight: 700; }
.mood-info-actions {
    display: inline-flex;
    gap: 2px;
    align-items: center;
    flex-shrink: 0;
}

/* -------- VIBE card: the vote page tile. Media on top (cover image with a
   platform badge top-right), content area with song title, artist, submission
   date and like/dislike counts, then a row of three large vote controls:
   thumbs-down, skip, thumbs-up. -------- */
.card-vibe {
    padding: 0;
    /* Same light outline as every other card in the family. */
    border: var(--card-border-width) solid var(--card-border-color);
    border-radius: var(--card-radius);
    background: var(--surface);
    color: var(--foreground);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 160ms, box-shadow 160ms;
}
.card-vibe:hover { transform: translateY(-2px); box-shadow: 0 8px 24px color-mix(in srgb, var(--foreground) 10%, transparent); }
/* Vibe tiles have more room to breathe than the grid-sized song/artist cards,
   so they come in two larger sizes. Default stays at .card-vibe (same width
   as .card-grid-lg), .card-vibe-lg bumps it ~35% and .card-vibe-xl ~60%.
   The media aspect-ratio and body paddings scale with the size via tokens. */
.card-vibe-lg  { max-width: 560px; margin: 0 auto; }
.card-vibe-xl  { max-width: 720px; margin: 0 auto; }
.card-vibe-lg  .vibe-content-title,
.card-vibe-xl  .vibe-content-title { font-size: 24px; }
.card-vibe-xl  .vibe-content-title { font-size: 28px; }
.card-vibe-lg  .vibe-content,
.card-vibe-xl  .vibe-content { padding: 28px 28px 14px; }
.card-vibe-xl  .vibe-actions { padding: 20px 28px 32px; gap: 28px; }
.card-vibe-xl  .vibe-action  { width: 64px; height: 64px; font-size: 24px; }
.vibe-media {
    aspect-ratio: 16 / 9;
    background: var(--surface-subtle);
    background-size: cover;
    background-position: center;
    position: relative;
}
.vibe-media > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vibe-media > .song-media { height: 100%; aspect-ratio: auto; }
/* Media-type badge (YouTube etc) sits top-right of the cover. */
.vibe-media-badge {
    position: absolute; right: 12px; top: 12px;
    width: 32px; height: 32px;
    border-radius: var(--radius-circle);
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 14px;
    pointer-events: none;
}
.vibe-content {
    padding: 20px 20px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: center;
}
.vibe-content-title    { font: 800 20px/1.25 var(--font-display); color: var(--foreground); margin: 0; }
.vibe-content-artist   { font: 500 14px/1.3 var(--font-body); color: var(--foreground-muted); margin-top: 2px; }
.vibe-content-submitted{ font: 500 13px/1.3 var(--font-body); color: var(--foreground-muted); margin-top: 8px; }
.vibe-content-stats {
    display: inline-flex;
    justify-content: center;
    gap: 22px;
    margin-top: 12px;
    font: 600 14px/1 var(--font-body);
    color: var(--foreground-muted);
}
.vibe-content-stats > span,
.vibe-content-stats > button { display: inline-flex; align-items: center; gap: 8px; }
.vibe-content-stats > .is-up   { color: var(--foreground); }
.vibe-content-stats > .is-up   > i { color: var(--success); }
.vibe-content-stats > .is-down > i { color: var(--danger); }
/* Share is a text-free action that sits alongside the up/down counts so it
   reads as a peer of them, not a separate affordance. */
.vibe-content-stats > .vibe-share {
    border: 0; background: transparent; cursor: pointer;
    color: var(--foreground-muted);
    padding: 0;
    font: inherit;
    transition: color 120ms;
}
.vibe-content-stats > .vibe-share:hover { color: var(--primary); }
/* The three vote controls on the vote page. Circular buttons, same height,
   centred, sitting directly on the tile surface (no grey shelf). */
.vibe-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 16px 20px 24px;
    background: transparent;
}
.vibe-action {
    width: 56px; height: 56px;
    border: 0;
    border-radius: var(--radius-circle);
    background: var(--surface-subtle);
    color: var(--foreground-muted);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 22px;
    cursor: pointer;
    transition: transform 120ms, background 120ms, color 120ms;
}
.vibe-action:hover  { transform: scale(1.05); }
.vibe-action:active { transform: scale(0.96); }
.vibe-action.vibe-action-down { background: var(--danger-subtle, color-mix(in srgb, var(--danger) 18%, transparent)); color: var(--danger); }
.vibe-action.vibe-action-down:hover { background: var(--danger); color: var(--danger-reverse, #fff); }
.vibe-action.vibe-action-pass { background: var(--surface-subtle); color: var(--foreground); }
.vibe-action.vibe-action-pass:hover { background: var(--foreground); color: var(--surface); }
.vibe-action.vibe-action-up   { background: var(--success-subtle, color-mix(in srgb, var(--success) 18%, transparent)); color: var(--success); }
.vibe-action.vibe-action-up:hover   { background: var(--success); color: var(--success-reverse, #fff); }

/* VIBE ACTIONS: pressed  .vibe-action[aria-pressed="true"] - the song's
   current vibe, solid in its colour, outside the queue. */
.vibe-action-down[aria-pressed="true"] { background: var(--danger); color: var(--danger-reverse, #fff); }
.vibe-action-pass[aria-pressed="true"] { background: var(--foreground); color: var(--surface); }
.vibe-action-up[aria-pressed="true"]   { background: var(--success); color: var(--success-reverse, #fff); }
.vibe-content-note { font: 500 13px/1.4 var(--font-body); color: var(--foreground-muted); margin: 10px 0 0; }

/* VIBE TABS  .vibe-tabs - the vibe footer. A standard .tab-bar whose five
   tabs (Queue, Your vibes, Likes, Passes, Dislikes) share the width; each is
   a large icon and its count. The active tab is the list the card shows. */
.vibe-tabs > .tabs { flex: 1 1 auto; display: flex; }
.vibe-tabs .vibe-tab { flex: 1 1 0; justify-content: center; gap: 10px; height: 48px; font: 700 16px/1 var(--font-display); }
.vibe-tabs .vibe-tab > :is(i, svg) { font-size: 20px; width: 20px; height: 20px; }
.vibe-tabs .vibe-tab-up   > :is(i, svg) { color: var(--success); }
.vibe-tabs .vibe-tab-down > :is(i, svg) { color: var(--danger); }
.vibe-tab-count { font-variant-numeric: tabular-nums; }
.vibe-tabs .vibe-tab.tab-active > :is(i, svg) { color: inherit; }
@media (max-width: 480px) { .vibe-tabs .vibe-tab { gap: 6px; padding: 0 6px; font-size: 14px; } .vibe-tabs .vibe-tab > :is(i, svg) { font-size: 17px; width: 17px; height: 17px; } }

/* VIBE DONE  .vibe-done - the queue-finished celebration: state, progress,
   totals as big tiles. */
.vibe-done .state-icon { color: var(--warning); }

/* VIBE STACK  .vibe-stack - card + its playback toolbar as one unit */
.vibe-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* -------- WORKSHOP card: thumb + title + stats + actions (horizontal) -------- */
.card-workshop {
    display: flex;
    gap: 14px;
    padding: 14px;
    align-items: center;
}
.workshop-thumb {
    width: 64px; height: 64px;
    border-radius: var(--thumb-radius);
    background: linear-gradient(135deg, var(--feature-2), var(--feature-3));
    object-fit: cover;
    flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--feature-2-reverse);
    font-size: 24px;
}
.workshop-body    { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.workshop-title   { font: 700 15px/1.3 var(--font-display); color: inherit; margin: 0; }
.workshop-meta    { font: 500 12px/1.3 var(--font-body); color: inherit; opacity: 0.7; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.workshop-progress{ margin-top: 6px; }
.workshop-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* -------- COMPETITION card: hero image, overlaid title + chips -------- */
.card-competition {
    padding: 0;
    overflow: hidden;
    position: relative;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--on-media);
}
.card-competition > img { width: 100%; height: 100%; object-fit: cover; display: block; position: absolute; inset: 0; }
.card-competition::after {
    content: "";
    position: absolute; inset: 0;
    background: linear-gradient(to top, color-mix(in srgb, black 75%, transparent) 0%, transparent 60%);
    pointer-events: none;
}
.comp-body  { position: absolute; bottom: 0; left: 0; right: 0; padding: 20px; z-index: var(--z-base); }
.comp-chips { display: flex; gap: 6px; margin-bottom: 8px; }
.comp-title { font: 800 22px/1.2 var(--font-display); margin: 0; letter-spacing: -0.015em; color: inherit; }
.comp-meta  { font: 500 13px/1.3 var(--font-body); opacity: 0.85; margin-top: 4px; color: inherit; }

/* -------- EVENT card: date block + title + venue (gracefully narrows) -------- */
.card-event {
    display: flex;
    gap: 14px;
    padding: 14px;
    align-items: center;
    flex-wrap: wrap;
}
.event-date {
    width: 56px;
    text-align: center;
    padding: 6px 4px;
    border-radius: var(--radius-sm);
    background: var(--primary-subtle);
    color: var(--primary);
    flex-shrink: 0;
}
.event-date .event-month { font: 700 10px/1 var(--font-body); text-transform: uppercase; letter-spacing: 0.08em; display: block; }
.event-date .event-day   { font: 800 22px/1 var(--font-display); display: block; margin-top: 2px; }
.event-body   { flex: 1 1 140px; min-width: 0; }
.event-title  { font: 700 15px/1.3 var(--font-display); color: inherit; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-venue  { font: 500 13px/1.3 var(--font-body); color: inherit; opacity: 0.7; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* -------- USER card: avatar + name + bio + follow (gracefully narrows) -------- */
.card-user {
    display: flex;
    gap: 14px;
    padding: 14px;
    align-items: center;
    flex-wrap: wrap;
}
.card-user > .avatar { flex-shrink: 0; }
.user-body { flex: 1 1 140px; min-width: 0; }
.user-name  { font: 700 15px/1.3 var(--font-display); color: inherit; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-handle{ font: 500 12px/1.3 var(--font-body); color: inherit; opacity: 0.6; margin-left: 4px; }
.user-bio   { font: 500 13px/1.4 var(--font-body); color: inherit; opacity: 0.7; margin-top: 6px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-user > .btn { flex-shrink: 0; margin-left: auto; }

/* When the card is narrow enough that the text + button no longer fit,
   the wrap takes effect and the button drops below on its own line. */
@media (max-width: 340px) {
    .card-event, .card-user { align-items: flex-start; }
}

/* -----------------------------------------------------------------------------
   COLOR-SELECT  .color-select - dropdown listing every DS colour token
   -------------------------------------------------------------------------- */
.color-select { position: relative; display: inline-block; width: 100%; max-width: 320px; }
.color-select-trigger {
    display: flex; align-items: center; gap: 10px;
    width: 100%; height: 44px; padding: 0 12px 0 10px;
    background: var(--surface); color: var(--foreground);
    border: 1px solid var(--border);
    /* A select trigger is in the FIELD family, so it tracks --field-radius
       and reshapes in lockstep with every other input, select, search and
       textarea when the Field shape control changes. */
    border-radius: var(--field-radius);
    cursor: pointer;
    font: 500 14px/1 var(--font-body);
    text-align: left;
    transition: border-color 120ms, background 120ms;
}
.color-select-trigger:hover { background: var(--surface-subtle); }
.color-select-trigger .swatch-dot {
    width: 24px; height: 24px; border-radius: var(--radius-circle);
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.color-select-trigger .color-select-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 13px; }
.color-select-trigger .color-select-caret { color: var(--foreground-muted); font-size: 12px; }
.color-select-panel {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    /* The dropdown panel is a menu, so it tracks --menu-radius. */
    border-radius: var(--menu-radius);
    box-shadow: 0 8px 24px color-mix(in srgb, var(--foreground) 10%, transparent);
    padding: 6px;
    max-height: 360px;
    overflow-y: auto;
    z-index: var(--z-tooltip);
}
.color-select-group-label {
    padding: 8px 10px 4px;
    font: 700 10px/1 var(--font-body);
    color: var(--foreground-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.color-select-option {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
    border: 0;
    width: 100%;
    text-align: left;
}
.color-select-option:hover { background: var(--surface-subtle); }
.color-select-option.is-selected { background: var(--primary-subtle); }
.color-select-option .swatch-dot { width: 20px; height: 20px; border-radius: var(--radius-circle); border: 1px solid var(--border); flex-shrink: 0; }
.color-select-option-name { font: 500 13px/1 var(--font-mono); color: var(--foreground); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* -----------------------------------------------------------------------------
   COLOR-PICKER  .color-picker - swatch grid + custom hex input
   -------------------------------------------------------------------------- */
.color-picker {
    display: flex; flex-direction: column; gap: 14px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    max-width: 360px;
}
.color-picker-group { display: flex; flex-direction: column; gap: 6px; }
.color-picker-label { font: 700 10px/1 var(--font-body); color: var(--foreground-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.color-picker-swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.color-picker-swatch {
    width: 100%; aspect-ratio: 1;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 100ms;
    position: relative;
}
.color-picker-swatch:hover { transform: scale(1.08); }
.color-picker-swatch.is-selected::after {
    content: "";
    position: absolute; inset: 2px;
    border: 2px solid var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: 0 0 0 2px var(--foreground);
}
.color-picker-custom { display: flex; gap: 8px; align-items: center; }
.color-picker-preview { width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--border); flex-shrink: 0; }
.color-picker-hex { flex: 1; }
.color-picker-toggle { display: flex; justify-content: center; margin: -4px 0; }

/* -----------------------------------------------------------------------------
   CALENDAR  .calendar - day / week / month views
   -------------------------------------------------------------------------- */
.calendar {
    background: var(--surface);
    color: var(--foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.calendar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}
.calendar-title { font: 800 17px/1 var(--font-display); margin: 0; letter-spacing: -0.01em; }
.calendar-controls { display: flex; align-items: center; gap: 6px; }
.calendar-body { padding: 8px; }

/* MONTH view: 7 columns, day cells */
.calendar-month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar-month .cal-dow {
    text-align: center;
    padding: 8px 4px;
    font: 700 10px/1 var(--font-body);
    color: var(--foreground-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.calendar-month .cal-day {
    aspect-ratio: 1;
    padding: 6px;
    border-radius: var(--radius-sm);
    background: transparent;
    display: flex; flex-direction: column; align-items: flex-start;
    gap: 2px;
    cursor: pointer;
    color: var(--foreground);
    transition: background 120ms;
    border: 0;
    text-align: left;
    font: inherit;
}
.calendar-month .cal-day:hover { background: var(--surface-subtle); }
.calendar-month .cal-day.cal-other { color: var(--foreground-muted); opacity: 0.4; }
.calendar-month .cal-day.cal-today {
    background: var(--primary-subtle);
    color: var(--primary);
    font-weight: 700;
}
.calendar-month .cal-day.cal-selected {
    background: var(--primary);
    color: var(--primary-reverse);
}
.calendar-month .cal-day .cal-num { font: 600 13px/1 var(--font-body); }
.calendar-month .cal-day .cal-dot {
    width: 5px; height: 5px;
    border-radius: var(--radius-circle);
    background: var(--secondary);
    margin-top: auto;
}

/* WEEK view: 7 columns tall */
.calendar-week {
    display: grid;
    grid-template-columns: 56px repeat(7, 1fr);
    gap: 2px;
    overflow: hidden;
}
.calendar-week .cal-timecol { padding: 8px 6px; font: 500 11px/1 var(--font-mono); color: var(--foreground-muted); text-align: right; }
.calendar-week .cal-head {
    text-align: center;
    padding: 8px 4px;
    border-radius: var(--radius-sm);
    background: var(--surface-subtle);
}
.calendar-week .cal-head-dow { font: 700 10px/1 var(--font-body); color: var(--foreground-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.calendar-week .cal-head-num { font: 800 18px/1.2 var(--font-body); color: var(--foreground); margin-top: 4px; }
.calendar-week .cal-head.is-today .cal-head-num { color: var(--primary); }
.calendar-week .cal-slot {
    min-height: 44px;
    border-top: 1px dashed var(--border);
    padding: 2px;
    position: relative;
}
.calendar-week .cal-event {
    position: absolute; inset: 2px;
    background: var(--primary);
    color: var(--primary-reverse);
    border-radius: var(--radius-sm);
    padding: 4px 6px;
    font: 600 11px/1.2 var(--font-body);
    overflow: hidden;
}
.calendar-week .cal-event-info      { background: var(--info);    color: var(--info-reverse); }
.calendar-week .cal-event-success   { background: var(--success); color: var(--success-reverse); }
.calendar-week .cal-event-secondary { background: var(--secondary); color: var(--secondary-reverse); }

/* DAY view: hour rows */
.calendar-day { display: grid; grid-template-columns: 56px 1fr; gap: 2px; }
.calendar-day .cal-timecol { padding: 8px 6px; font: 500 11px/1 var(--font-mono); color: var(--foreground-muted); text-align: right; }
.calendar-day .cal-slot {
    min-height: 44px;
    border-top: 1px dashed var(--border);
    padding: 2px;
    position: relative;
}
.calendar-day .cal-event {
    position: absolute; inset: 2px;
    background: var(--primary);
    color: var(--primary-reverse);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font: 600 12px/1.3 var(--font-body);
    overflow: hidden;
}

/* =============================================================================
   LAYER 2  COMPONENTS - compositions of primitives.
   Everything below is built from primitives above with no new colours and no
   new radii - all skin and shape tokens come from the layer above, so the
   Theme editor reshapes components in lockstep with the primitives inside
   them. Names stay flat: .component .component-part.
   ========================================================================== */

/* -----------------------------------------------------------------------------
   FILTER BAR  .filter-bar - one row of controls for a listing page. The whole
   bar is one full-width .tab-bar: tabs slot into .tab-bar-tabs, the search +
   view-selector live in .tab-bar-actions on the right. No stacked second row
   of chips: a listing page should read as one strip of chrome, with secondary
   options tucked behind the view-selector ellipsis.
   -------------------------------------------------------------------------- */
.filter-bar { width: 100%; }
.filter-bar > .tab-bar,
.filter-bar > .toolbar { width: 100%; }

/* -----------------------------------------------------------------------------
   PAGINATION BAR  .pagination-bar - page numbers + prev/next + page-size +
   result count, as one row. Plain .pagination gives you the number strip;
   this adds the surrounding chrome.
   -------------------------------------------------------------------------- */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 4px;
    flex-wrap: wrap;
}
.pagination-bar-count { font: 500 13px/1 var(--font-body); color: var(--foreground-muted); }
.pagination-bar-size  { display: inline-flex; align-items: center; gap: 8px; font: 500 13px/1 var(--font-body); color: var(--foreground-muted); }

/* -----------------------------------------------------------------------------
   SONG ROW  .song-row - horizontal song in a list. Sibling to .card-song;
   use the card for grids, the row for ranked lists and dense tables. Cover
   square on the left, title + artist in the middle, meta + actions on the
   right. Ranks are optional via .song-row-rank.
   -------------------------------------------------------------------------- */
.song-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.song-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    background: var(--surface);
    color: var(--foreground);
    border-radius: var(--item-radius);
    transition: background 120ms;
    text-decoration: none;
    min-width: 0;
}
.song-row:hover { background: var(--surface-subtle); text-decoration: none; }
.song-row-rank {
    width: 24px;
    flex-shrink: 0;
    font: 800 14px/1 var(--font-display);
    color: var(--foreground-muted);
    text-align: center;
}
.song-row-cover {
    width: 44px; height: 44px;
    flex-shrink: 0;
    border-radius: var(--thumb-radius);
    background: var(--surface-subtle);
    background-size: cover; background-position: center;
}
.song-row-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.song-row-title  { font: 700 14px/1.3 var(--font-display); color: inherit; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-row-artist { font: 500 12px/1.3 var(--font-body);    color: var(--foreground-muted); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-row-meta {
    display: inline-flex;
    gap: 14px;
    align-items: center;
    flex-shrink: 0;
    color: var(--foreground-muted);
    font: 600 12px/1 var(--font-body);
}
.song-row-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.song-row-actions {
    display: inline-flex;
    gap: 2px;
    align-items: center;
    flex-shrink: 0;
}

/* -----------------------------------------------------------------------------
   MEDIA PLAYER  .player - compact bottom-strip player. Play / pause, cover
   + title, scrubber, time, volume. Sits inside a sticky footer slot or as
   a page-top strip. Keyboard-accessible via normal button + slider primitives.
   -------------------------------------------------------------------------- */
.player {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    background: var(--surface);
    color: var(--foreground);
    border: 1px solid var(--border);
    border-radius: var(--toolbar-radius);
    min-height: 60px;
}
.player-controls { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; }
.player-track {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1 1 auto;
    min-width: 0;
}
.player-cover {
    width: 40px; height: 40px;
    border-radius: var(--thumb-radius);
    flex-shrink: 0;
    background: var(--surface-subtle);
    background-size: cover; background-position: center;
}
.player-meta { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.player-title  { font: 700 13px/1.3 var(--font-display); color: inherit; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-artist { font: 500 12px/1.3 var(--font-body);    color: var(--foreground-muted); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-scrub { display: flex; align-items: center; gap: 10px; flex: 2 1 240px; min-width: 0; }
.player-scrub-time { font: 500 11px/1 var(--font-mono); color: var(--foreground-muted); flex-shrink: 0; }
.player-scrub > .slider { flex: 1; }
.player-volume { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 140px; min-width: 0; }

/* -----------------------------------------------------------------------------
   COMMENT  .comment - a single comment with avatar, name, time, body and
   actions. .comment-thread stacks comments with reply nesting. .comment-composer
   is the textarea + submit pair at the bottom of a thread.
   -------------------------------------------------------------------------- */
.comment-thread { display: flex; flex-direction: column; gap: 14px; }
.comment {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    background: var(--surface);
    color: var(--foreground);
    border-radius: var(--item-radius);
}
.comment-avatar { flex-shrink: 0; }
.comment-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.comment-head { display: inline-flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.comment-name { font: 700 14px/1.2 var(--font-display); color: var(--foreground); margin: 0; }
.comment-time { font: 500 12px/1 var(--font-body);      color: var(--foreground-muted); }
.comment-text { font: 500 14px/1.5 var(--font-body);    color: var(--foreground); margin: 0; }
.comment-actions { display: inline-flex; gap: 2px; margin-top: 2px; }
.comment-action {
    display: inline-flex; align-items: center; gap: 6px;
    height: 28px; padding: 0 10px;
    border: 0; background: transparent;
    color: var(--foreground-muted);
    border-radius: var(--btn-radius);
    font: 600 12px/1 var(--font-body);
    cursor: pointer;
    transition: background 120ms, color 120ms;
}
.comment-action:hover { background: var(--surface-subtle); color: var(--foreground); }
.comment-action.is-active { color: var(--primary); }
.comment-replies {
    margin-top: 10px;
    padding-left: 12px;
    border-left: 2px solid var(--border);
    display: flex; flex-direction: column; gap: 10px;
}
.comment-composer {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px;
    background: var(--surface-subtle);
    border-radius: var(--item-radius);
}
.comment-composer-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.comment-composer-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* -----------------------------------------------------------------------------
   STAT STRIP  .stat-strip - horizontal row of .tile.tile-stat items that
   scales with width. One flat row on wide screens, wraps on narrow ones.
   Use for the "at a glance" numbers at the top of a dashboard, profile or
   artist page.
   -------------------------------------------------------------------------- */
.stat-strip {
    display: flex;
    gap: var(--tile-gap);
    flex-wrap: wrap;
}
.stat-strip > .tile { flex: 1 1 160px; min-width: 0; }
/* Two by two: big tiles in pairs (e.g. the vibe totals). */
.stat-strip-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* -----------------------------------------------------------------------------
   FORM SECTION  .form-section - titled group of fields inside a larger form.
   A form page uses several of these stacked under a page-header.
   -------------------------------------------------------------------------- */
.form-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
    background: var(--surface);
    border-radius: var(--card-radius);
}
.form-section-head { display: flex; flex-direction: column; gap: 4px; }
.form-section-title    { font: 700 18px/1.2  var(--font-display); color: var(--foreground); margin: 0; letter-spacing: -0.01em; }
.form-section-subtitle { font: 500 13px/1.45 var(--font-body);    color: var(--foreground-muted); margin: 0; max-width: 60ch; }
.form-section-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* -----------------------------------------------------------------------------
   AUTH FORM  .auth-form - the composed sign-in / sign-up / reset form. Hero
   header, large fields, primary CTA, footer links. Same bones as the auth
   modal but sized to live on its own page too.
   -------------------------------------------------------------------------- */
.auth-form {
    position: relative;
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--surface);
    border-radius: var(--card-radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}
.auth-form-head {
    padding: 96px 32px 48px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--primary-reverse);
    display: flex; flex-direction: column; gap: 6px;
}
.auth-form-title    { font: 900 28px/1.1  var(--font-display); color: inherit; margin: 0; letter-spacing: -0.02em; }
.auth-form-subtitle { font: 500 14px/1.4  var(--font-body);    color: inherit; opacity: 0.88; margin: 0; }
.auth-form-body { display: flex; flex-direction: column; gap: 14px; padding: 24px 32px; }
.auth-form-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 32px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-subtle);
    font: 500 13px/1 var(--font-body);
    color: var(--foreground-muted);
}

/* -----------------------------------------------------------------------------
   STATE BLOCKS  - empty, loading, error. Each fills a container the same way
   so you can swap between them with one class change. .state-* is the row
   that goes inside .card / .section when its contents are not ready.
   -------------------------------------------------------------------------- */
.state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 48px 24px;
    text-align: center;
}
.state-icon {
    width: 64px; height: 64px;
    border-radius: var(--icon-chip-radius);   /* Theme > Elements > Icon circles */
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 28px;
    background: var(--surface-subtle);
    color: var(--foreground-muted);
    margin-bottom: 4px;
}
.state-empty  .state-icon { background: var(--secondary);               color: var(--secondary-reverse); }
.state-loading .state-icon { background: var(--primary-subtle);          color: var(--primary); }
.state-error  .state-icon { background: var(--danger-subtle);           color: var(--danger); }
.state-title    { font: 800 18px/1.2  var(--font-display); margin: 0; color: var(--foreground); }
.state-message  { font: 500 14px/1.45 var(--font-body);    margin: 0; color: var(--foreground-muted); max-width: 44ch; }
.state-actions  { display: inline-flex; gap: 8px; margin-top: 10px; }

/* Skeleton rows / grid - shaped placeholders while real content loads.
   .skeleton-row and .skeleton-grid use the existing .skeleton primitive. */
.skeleton-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
}
.skeleton-row > .skeleton-circle { width: 44px; height: 44px; flex-shrink: 0; }
.skeleton-row-text { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.skeleton-row-text > .skeleton:nth-child(1) { height: 12px; width: 60%; }
.skeleton-row-text > .skeleton:nth-child(2) { height: 10px; width: 40%; }
.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--item-gap);
}
.skeleton-card {
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 12px;
    display: flex; flex-direction: column; gap: 10px;
}
.skeleton-card > .skeleton:nth-child(1) { height: 160px; border-radius: var(--cover-radius); }
.skeleton-card > .skeleton:nth-child(2) { height: 14px; width: 70%; }
.skeleton-card > .skeleton:nth-child(3) { height: 12px; width: 45%; }

/* =============================================================================
   ANIMATION LIBRARY  - reusable one-off animations for celebration, exit and
   motion-of-delight moments. Each is a keyframe + a utility class; JS
   helpers in ds.js wire them up to live elements (confetti burst, firework,
   rocket blast off, swipe-away) and clean up afterwards.
   ========================================================================== */

/* SWIPE AWAY  .anim-swipe-right / .anim-swipe-left - the arc exit used on
   vibe cards after a vote. Travels off to the side in a shallow arc,
   rotating and fading as it goes. Add the class, listen for animationend,
   remove the element. */
@keyframes ds-swipe-right {
    0%   { transform: translate(0, 0) rotate(0); opacity: 1; }
    40%  { transform: translate(40%, -30px) rotate(8deg); opacity: 1; }
    100% { transform: translate(160%, 40px) rotate(18deg); opacity: 0; }
}
@keyframes ds-swipe-left {
    0%   { transform: translate(0, 0) rotate(0); opacity: 1; }
    40%  { transform: translate(-40%, -30px) rotate(-8deg); opacity: 1; }
    100% { transform: translate(-160%, 40px) rotate(-18deg); opacity: 0; }
}
.anim-swipe-right { animation: ds-swipe-right 600ms cubic-bezier(0.4, 0, 0.6, 1) forwards; }
.anim-swipe-left  { animation: ds-swipe-left  600ms cubic-bezier(0.4, 0, 0.6, 1) forwards; }

/* CONFETTI particle  - each particle is a small coloured square that drifts
   out from the burst point and falls under gravity. The JS helper spawns
   N particles with randomised trajectories (CSS vars --dx/--dy/--rot) and
   this keyframe plays them. */
@keyframes ds-confetti {
    0%   { transform: translate(0, 0) rotate(0); opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}
.confetti-burst {
    position: fixed;
    pointer-events: none;
    z-index: var(--z-toast);
    inset: 0;
}
.confetti-piece {
    position: absolute;
    width: 10px; height: 14px;
    border-radius: 2px;
    animation: ds-confetti 1200ms cubic-bezier(0.2, 0.6, 0.4, 1) forwards;
    will-change: transform, opacity;
}

/* FIREWORK  - a single burst that expands and fades, like a confetti burst
   but arranged as a ring rather than a shower. */
@keyframes ds-firework {
    0%   { transform: translate(0, 0) scale(0.2); opacity: 1; }
    60%  { opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 0; }
}
.firework-burst { position: fixed; pointer-events: none; z-index: var(--z-toast); inset: 0; }
.firework-spark {
    position: absolute;
    width: 6px; height: 6px;
    border-radius: 50%;
    animation: ds-firework 900ms cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
    will-change: transform, opacity;
    box-shadow: 0 0 6px currentColor;
}

/* ROCKET  - an element lifts off and arcs out of frame, leaving a trail of
   sparks. The main element uses .anim-rocket; the trail sparks are spawned
   by the JS helper. */
@keyframes ds-rocket {
    0%   { transform: translate(0, 0) rotate(0); }
    30%  { transform: translate(-8px, -30vh) rotate(-6deg); }
    100% { transform: translate(60vw, -140vh) rotate(-24deg); opacity: 0; }
}
@keyframes ds-rocket-trail {
    0%   { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.3) translateY(60px); }
}
.anim-rocket { animation: ds-rocket 1400ms cubic-bezier(0.4, 0, 0.6, 1) forwards; will-change: transform, opacity; }
.rocket-trail {
    position: fixed;
    pointer-events: none;
    z-index: var(--z-toast);
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--feature-4);
    box-shadow: 0 0 10px var(--feature-4);
    animation: ds-rocket-trail 600ms ease-out forwards;
}

/* PULSE RING  .anim-pulse-ring - a quick ring expanding from an element,
   used for "accepted" / "added" micro-feedback, smaller than a firework. */
@keyframes ds-pulse-ring {
    0%   { transform: scale(0.6); opacity: 0.6; }
    100% { transform: scale(2.4); opacity: 0; }
}
.pulse-ring {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 2px solid var(--primary);
    animation: ds-pulse-ring 700ms ease-out forwards;
    pointer-events: none;
}

/* -----------------------------------------------------------------------------
   SITE CHROME EXTRAS - header logo swap, nav dropdown menus, mobile nav,
   on-primary buttons and a few row helpers. Ported from muzooi-site.css so
   pages rebuilt on the DS can load ds.css alone.
   -------------------------------------------------------------------------- */
.header-logo-img  { height: 32px; width: auto; display: block; }
.header-logo-dark { display: none; }
[data-theme="dark"] .header-logo-light { display: none; }
[data-theme="dark"] .header-logo-dark  { display: block; }

.nav-dropdown  { position: relative; display: inline-flex; }
.nav-caret     { font-size: 0.7em; margin-left: 4px; opacity: 0.7; }
.nav-menu      { position: absolute; top: calc(100% + 6px); left: 0; min-width: 220px; }
.nav-menu-wide { min-width: 340px; max-height: 480px; overflow-y: auto; }
.header-right .nav-dropdown > .nav-menu { left: auto; right: 0; }
.nav-menu-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--foreground); padding: 10px 10px 6px; }
.nav-menu-head .text-muted,
.nav-menu-head .text-xs { display: block; margin-top: 2px; }
.nav-badge  { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px; }

.header-mobile-toggle { display: none; }
@media (max-width: 860px) {
    .header-nav { display: none; }
    .header-mobile-toggle { display: inline-flex; }
    body.nav-mobile-open .header-nav { display: flex; flex-direction: column; position: fixed; top: 72px; left: 16px; right: 16px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); z-index: 1000; gap: 2px; }
    body.nav-mobile-open .header-nav .nav-item { width: 100%; justify-content: flex-start; }
    body.nav-mobile-open .nav-dropdown { width: 100%; }
    body.nav-mobile-open .nav-menu { position: static; width: 100%; box-shadow: none; border: 0; margin: 0; }
    .header-signin { display: none; }                         /* Sign in moves into the menu on phones */
    body.nav-mobile-open .nav-item-mobile { display: flex; }  /* ...and shows there */
}
.nav-item-mobile { display: none; }

.btn.btn-on-primary { background: var(--surface); color: var(--primary); border-color: var(--surface); }
.btn.btn-on-primary:hover { background: color-mix(in srgb, var(--surface) 92%, black); color: var(--primary); }
.btn.btn-outline.btn-outline-on-primary { background: transparent; border-color: var(--surface); color: var(--surface); }
.btn.btn-outline.btn-outline-on-primary:hover { background: color-mix(in srgb, var(--surface) 15%, transparent); color: var(--surface); }

.inline.inline-space-between    { justify-content: space-between; }
.inline.footer-divider-row      { margin: 4px 0 12px; }
.empty-state.empty-state-pad-xl { padding: 48px 24px; }
.form-footer-row { justify-content: flex-end; padding-top: var(--space-md); border-top: 1px solid var(--border); }
.overlay-modal.overlay-modal-lg { max-width: 720px; }

/* -----------------------------------------------------------------------------
   MEDIA FALLBACKS - when a song, post or contest has no image, its media
   slot gets one of four token gradients, picked by id so a tile keeps the
   same colour between visits. Works on any media slot (.song-media,
   .song-row-cover, .blog-cover, .card-competition).
   -------------------------------------------------------------------------- */
.media-fallback-1 { background: linear-gradient(135deg, var(--feature-2), var(--feature-3)); }
.media-fallback-2 { background: linear-gradient(135deg, var(--primary), var(--secondary)); }
.media-fallback-3 { background: linear-gradient(135deg, var(--feature-4), var(--feature-1)); }
.media-fallback-4 { background: linear-gradient(135deg, var(--feature-3), var(--primary)); }

/* Row covers hold an <img> the same way card media does. */
.song-row-cover { overflow: hidden; display: inline-flex; align-items: center; justify-content: center; }
.song-row-cover > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.song-row-cover-icon  { background: var(--info-subtle); color: var(--info); }

/* WHOLE-TILE LINK - a tile's primary link (title link) stretches over the
   whole card, so clicking anywhere opens it. Buttons and secondary links in
   the tile sit above the stretched link and keep working. */
.tile-link { color: inherit; text-decoration: none; }
.tile-link::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.tile-link:hover { text-decoration: none; }
.card-song .song-actions,
.card-blog .blog-meta { position: relative; z-index: 2; }
.card-blog, .card-competition { position: relative; }
.comp-title .tile-link::after { z-index: 2; }

/* QUOTE card - a featured review or testimonial. */
/* RATING  .rating - stars. Static (display) or .rating-input (buttons).
   .rating-star.is-on is filled; the count sits after in .rating-count. */
.rating { display: inline-flex; align-items: center; gap: 2px; color: var(--warning); font-size: 16px; line-height: 1; }
.rating-star { color: var(--border); }
.rating-star.is-on { color: var(--warning); }
.rating-count { margin-left: 6px; font: 600 13px/1 var(--font-body); color: var(--foreground-muted); }
.rating-input { gap: 4px; font-size: 26px; }
.rating-input > .rating-star { border: 0; background: transparent; padding: 0; cursor: pointer; font: inherit; line-height: 1; transition: color 100ms, transform 100ms; }
.rating-input > .rating-star:hover { transform: scale(1.12); }
.rating-input:hover > .rating-star { color: var(--warning); }
.rating-input > .rating-star:hover ~ .rating-star { color: var(--border); }

/* REVIEW CARD  .card-review - one review: who/what + date, stars, criteria
   chips, the comment, an optional creator response, and actions. */
.card-review { display: flex; flex-direction: column; gap: 12px; }
.review-head { display: flex; align-items: flex-start; gap: 12px; }
.review-head-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.review-title { font: 700 16px/1.3 var(--font-display); margin: 0; }
.review-title > a { color: inherit; text-decoration: none; }
.review-title > a:hover { color: var(--primary); }
.review-sub, .review-date { font: 500 13px/1.3 var(--font-body); color: var(--foreground-muted); }
.review-date { white-space: nowrap; }
.review-text { font: 500 15px/1.55 var(--font-body); margin: 0; white-space: pre-line; }
.review-text-empty { color: var(--foreground-muted); font-style: italic; }
.review-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.review-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.card-review.is-muted { opacity: 0.6; }
/* Replies sit inside the parent post, indented, as plain posts (no card chrome). */
.post-replies { display: flex; flex-direction: column; gap: 12px; padding-left: 24px; }
.post-replies > .card-review { border: 0; padding: 0; background: transparent; }
div.review-text { white-space: normal; }

.card-quote   { display: flex; gap: 16px; align-items: flex-start; }
.quote-body   { display: flex; flex-direction: column; gap: 10px; min-width: 0; flex: 1; }
.quote-text   { font: italic 500 16px/1.5 var(--font-body); color: var(--foreground); margin: 0; }
.quote-meta   { font: 500 13px/1.4 var(--font-body); color: var(--foreground-muted); margin: 0; }
.avatar-feature { background: var(--feature-1); color: var(--feature-1-reverse); }

/* Contest card meta row: entries left, countdown right. */
.comp-meta-row { display: flex; justify-content: space-between; gap: 12px; }

/* Stat tiles in a feature colour (stat strip). */
.tile-feature-1 { background: var(--feature-1); color: var(--feature-1-reverse); }
.tile-feature-2 { background: var(--feature-2); color: var(--feature-2-reverse); }
.tile-feature-3 { background: var(--feature-3); color: var(--feature-3-reverse); }
.tile-feature-4 { background: var(--feature-4); color: var(--feature-4-reverse); }
.tile-brand     { background: var(--primary);   color: var(--primary-reverse); }

/* Filter bar helpers: fluid search beside the tabs, menu anchored to its toggle. */
.search-field-inline { width: 100%; max-width: 240px; }
.menu-anchor { position: relative; }
.menu-anchor > .menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: var(--z-dropdown, 50); }

/* AUTH: modal + page placement.
   The sign-in modal is the same .auth-form as the /login page, sitting in a
   bare overlay panel (the form brings its own surface, radius and shadow).
   .auth-form-compact trims the hero header for the modal. */
.overlay-modal-auth { position: relative; max-width: 460px; background: transparent; box-shadow: none; overflow: visible; }
.auth-form-compact .auth-form-head { padding: 48px 32px 32px; }
.auth-form-close {
    position: absolute; top: 12px; right: 12px; z-index: var(--z-base);
    color: var(--primary-reverse);
}
.auth-form-close:hover { background: color-mix(in srgb, var(--primary-reverse) 18%, transparent); color: var(--primary-reverse); }
.auth-form-foot a { font-weight: 600; }
.auth-page { padding-block: 48px; }
.auth-form-fields { display: flex; flex-direction: column; gap: 14px; }

/* SEARCH RESULT icon cover (artists / people without an image, competitions). */
.search-result-cover-icon { display: inline-flex; align-items: center; justify-content: center; background: var(--primary-subtle); color: var(--primary); font-size: 18px; }
.search-result.is-active { background: var(--primary-subtle); }

/* NOTIFICATION row in the navbar menu: a .menu-item with an icon avatar,
   title, optional message and time. Unread rows get a subtle fill. */
.notification-item { align-items: flex-start; gap: 12px; padding: 10px; }
.notification-item.is-unread { background: var(--primary-subtle); }
.notification-body    { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notification-title   { font: 600 14px/1.3 var(--font-body); color: var(--foreground); }
.notification-message { font: 500 13px/1.4 var(--font-body); color: var(--foreground-muted); }
.notification-meta    { font: 500 12px/1.2 var(--font-body); color: var(--foreground-muted); }

/* KEY-VALUE LIST  .kv-list - label on the left, value on the right, one row
   per fact, hairline between rows. <dl class="kv-list"><div class="kv-row">
   <dt>Label</dt><dd>Value</dd></div>...</dl>  ds_kv_list() renders it. */
.kv-list { margin: 0; display: flex; flex-direction: column; }
.kv-row  { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 10px 0; border-top: 1px solid var(--border); }
.kv-row:first-child { border-top: 0; padding-top: 0; }
.kv-row > dt { margin: 0; font: 500 13px/1.4 var(--font-body); color: var(--foreground-muted); }
.kv-row > dd { margin: 0; font: 600 14px/1.4 var(--font-body); color: var(--foreground); text-align: right; min-width: 0; overflow-wrap: anywhere; }

/* SETTING ROW  .setting-row - a labelled on/off setting: title + hint on the
   left, a .switch on the right. The whole row is the label, so clicking
   anywhere toggles it. ds_setting_switch() renders it. */
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--border); cursor: pointer; }
.setting-row:first-child { border-top: 0; padding-top: 0; }
.setting-text  { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.setting-title { font: 600 15px/1.3 var(--font-body); color: var(--foreground); }
.setting-hint  { font: 500 13px/1.4 var(--font-body); color: var(--foreground-muted); }
.setting-row > .switch-wrap { flex-shrink: 0; }

/* DIVIDED STACK  .stack-divided - a vertical list of blocks with a hairline
   between each (changelog entries, feed items). */
.stack-divided { display: flex; flex-direction: column; }
.stack-divided > * + * { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 16px; }

/* Toast icon colour by type (DS.toast sets .toast-success etc.). */
.toast-icon { color: var(--primary); }
.toast-success .toast-icon { color: var(--success); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-danger  .toast-icon { color: var(--danger); }
.toast-info    .toast-icon { color: var(--info); }
.toast { transition: opacity 200ms; }
.toast.is-leaving { opacity: 0; }

/* Rows with actions: the title link stretches over the row (.tile-link),
   the action buttons sit above it. Unread rows get a subtle fill. */
.song-row { position: relative; }
.song-row > .song-row-actions { position: relative; z-index: 2; }
.song-row.is-unread { background: var(--primary-subtle); }
.song-row-note { font: 500 12px/1.3 var(--font-body); color: var(--foreground-muted); }

/* LIST LABEL - a small heading that groups rows inside a list (Today,
   Yesterday, Songs, Artists). */
.list-label { padding: 12px 14px 4px; font: 700 11px/1 var(--font-body); color: var(--foreground-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.list-label:first-child { padding-top: 0; }

/* A section-header holding tabs keeps them beside the title. */
.section-header > .tabs { flex-shrink: 0; }

/* Playlist mosaic used as a cover (no image): fills the cover frame. */
.playlist-cover.playlist-mosaic { display: grid; aspect-ratio: 8 / 9; }   /* same frame as an image cover */
.card-playlist, .card-artist { position: relative; }
.playlist-cover > .chip { position: absolute; top: 12px; left: 12px; z-index: 2; }

/* DETAIL HEADER  .detail-header - the top of a single-item page (collection,
   playlist, artist, member, song): cover on the left, title, chips, meta
   and actions on the right. Stacks on phones. ds_detail_header() renders it.
   .detail-media-round makes the cover a circle (people, artists). */
.detail-header { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 28px; align-items: center; }
.detail-media  { aspect-ratio: 1 / 1; border-radius: var(--radius-lg); overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--on-media); font: 900 56px/1 var(--font-display); }
.detail-media > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-media-round { border-radius: var(--radius-circle); }
.detail-body    { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.detail-chips   { display: flex; flex-wrap: wrap; gap: 6px; }
.detail-meta    { display: flex; flex-wrap: wrap; gap: 6px 18px; font: 500 13px/1.4 var(--font-body); color: var(--foreground-muted); }
.detail-meta > span { display: inline-flex; align-items: center; gap: 6px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
@media (max-width: 720px) { .detail-header { grid-template-columns: 1fr; } .detail-media { max-width: 200px; } }

/* MENU LIST - a stack of .menu-item rows inside an overlay or panel (the
   song "More" sheet). Same items as a dropdown .menu, without the popover. */
.menu-list { display: flex; flex-direction: column; gap: 2px; }

/* -----------------------------------------------------------------------------
   RICH TEXT EDITOR  .post-editor - built by assets/js/post-editor.js around
   any <textarea data-post-editor="restricted|full">. Visual / HTML tabs, a
   toolbar, the editing surface and a theme-colour menu. (Ported from the
   legacy skin onto DS tokens.)
   -------------------------------------------------------------------------- */
.post-editor { border: var(--field-border-width) solid var(--field-border-color); border-radius: min(var(--field-radius), var(--radius-lg)); background: var(--field-bg); overflow: hidden; display: flex; flex-direction: column; }
.post-editor-tabs { display: flex; gap: 2px; padding: 8px 8px 0; border-bottom: 1px solid var(--border); }
.post-editor-tab { padding: 8px 16px; border: 0; background: transparent; color: var(--foreground-muted); font: 600 14px/1 var(--font-body); cursor: pointer; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.post-editor-tab:hover { color: var(--foreground); }
.post-editor-tab.active { color: var(--foreground); background: var(--surface-subtle); }
.post-editor-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; padding: 8px; background: var(--surface-subtle); border-bottom: 1px solid var(--border); }
.post-editor-toolbar button { width: 34px; height: 34px; border: 0; background: transparent; color: var(--foreground-muted); border-radius: var(--radius-sm); font-size: 14px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.post-editor-toolbar button:hover { background: var(--surface); color: var(--foreground); }
.post-editor-html { min-height: var(--pe-height, 280px); }
.post-editor-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.post-editor-surface,
.post-editor-preview { flex: 1; min-height: var(--pe-height, 280px); padding: 20px 24px; font: 450 16px/1.65 var(--font-body); color: var(--foreground); overflow-y: auto; outline: none; }
.post-editor-surface h2, .post-editor-preview h2 { font: 800 1.4rem/1.25 var(--font-display); margin: 1em 0 0.4em; }
.post-editor-surface h3, .post-editor-preview h3 { font: 700 1.15rem/1.3 var(--font-display); margin: 1em 0 0.4em; }
.post-editor-surface blockquote, .post-editor-preview blockquote { margin: 12px 0; padding: 8px 14px; background: var(--surface-subtle); border-radius: var(--radius-sm); font-style: italic; color: var(--foreground-muted); }
.post-editor-surface pre, .post-editor-preview pre { background: var(--surface-subtle); padding: 12px 14px; border-radius: var(--radius-sm); overflow-x: auto; font: 500 14px/1.5 var(--font-mono); }
.post-editor-surface a, .post-editor-preview a { color: var(--primary); text-decoration: underline; }
.post-editor-source { display: none; }
.post-editor.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }
.post-editor-html { flex: 1; min-height: 280px; padding: 16px 20px; font: 500 13px/1.55 var(--font-mono); color: var(--foreground); background: var(--field-bg); border: 0; outline: none; resize: vertical; white-space: pre; tab-size: 2; }
.post-editor-color-wrap { position: relative; display: inline-block; }
.post-editor-color-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: var(--z-sticky); min-width: 200px; max-height: 320px; overflow-y: auto; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--menu-radius); box-shadow: var(--shadow-md); }
.post-editor-color-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; background: transparent; color: var(--foreground); font: 500 13px/1.2 var(--font-body); text-align: left; cursor: pointer; border-radius: var(--radius-sm); }
.post-editor-color-item:hover { background: var(--surface-subtle); }
.pe-swatch { width: 18px; height: 18px; border-radius: var(--radius-xs); display: inline-block; flex-shrink: 0; border: 1px solid var(--border); }

/* ARTICLE  - a single long-form post: cover image, title, meta, body. */
.article-cover { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius-lg); display: block; }
.article-meta  { display: flex; flex-wrap: wrap; gap: 6px 16px; font: 500 13px/1.4 var(--font-body); color: var(--foreground-muted); }

/* LAYOUT WITH ASIDE  .layout-aside - main column plus a side column (article
   + recent posts, detail + related). The aside drops below on narrow screens. */
.layout-aside { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--section-gap); align-items: stretch; }
/* Both columns run the full height of the row; the last section in each
   takes the slack so their bottoms line up. */
.layout-aside > * > .section:last-child { flex: 1 1 auto; }
/* A sticky aside keeps its own height so it can stick. */
.layout-aside > .aside-sticky { align-self: start; }
.layout-aside > .aside-sticky > .section:last-child { flex: 0 0 auto; }
.layout-aside > * { min-width: 0; display: flex; flex-direction: column; gap: var(--section-gap); }
.layout-aside-start { grid-template-columns: 260px minmax(0, 1fr); }
@media (max-width: 960px) { .layout-aside, .layout-aside-start { grid-template-columns: 1fr; } }

/* STEPS  .steps - vertical progress list for a multi-step flow. Each .step
   holds a .step-link button (marker + title + sub); .is-active marks the
   current step, .is-done the completed ones, disabled links are not reached yet. */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.step  { position: relative; padding-bottom: 16px; }
.step:last-child { padding-bottom: 0; }
.step::before { content: ""; position: absolute; left: 13px; top: 32px; bottom: 4px; width: 2px; border-radius: 2px; background: var(--border); }
.step:last-child::before { display: none; }
.step.is-done::before { background: var(--success); }
.step-link { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.step-link:disabled { cursor: default; }
.step-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; border-radius: var(--radius-sm); }
.step-marker { width: 28px; height: 28px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-circle); background: var(--surface); color: var(--foreground-muted); font: 700 12px/1 var(--font-body); box-shadow: inset 0 0 0 2px var(--border); }
.step-check { display: none; font-size: 12px; }
.step-body  { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding-top: 4px; }
.step-title { font: 600 14px/1.3 var(--font-body); color: var(--foreground-muted); }
.step-sub   { font: 500 12px/1.35 var(--font-body); color: var(--foreground-muted); opacity: 0.8; }
.step.is-active .step-marker { background: var(--primary); color: var(--primary-reverse); box-shadow: none; }
.step.is-active .step-title,
.step.is-done .step-title   { color: var(--foreground); }
.step.is-done .step-marker  { background: var(--success-subtle); color: var(--success); box-shadow: none; }
.step.is-done .step-number  { display: none; }
.step.is-done .step-check   { display: inline; }
.step.is-done .step-link:hover .step-title { color: var(--primary); }

/* WIZARD  .wizard - multi-step form inside an .overlay-modal: the active
   .wizard-step on the left, a .wizard-rail with progress, summary and tips on
   the right. The modal's .overlay-foot holds Back / step count / Next. */
.overlay-modal.overlay-modal-xl { max-width: 1040px; }
.wizard { display: grid; grid-template-columns: minmax(0, 1fr) 300px; flex: 1 1 auto; min-height: 0; margin-top: 20px; border-top: 1px solid var(--border); }
.wizard-main { padding: 24px 24px 32px; overflow-y: auto; min-height: 0; }
.wizard-step { display: flex; flex-direction: column; gap: 18px; }
.wizard-step-head  { display: flex; flex-direction: column; gap: 4px; }
.wizard-step-title { font: 700 20px/1.25 var(--font-display); margin: 0 0 4px; }
.wizard-step-title > .info-tip { vertical-align: middle; margin-left: 2px; }
.wizard-rail { padding: 24px; background: var(--surface-subtle); border-left: 1px solid var(--border); overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 24px; }
.wizard-rail-block { display: flex; flex-direction: column; gap: 10px; }
.wizard-rail-title { font: 700 12px/1.3 var(--font-body); letter-spacing: 0.06em; text-transform: uppercase; color: var(--foreground-muted); margin: 0; }
.wizard-rail .kv-row > dd { font-size: 13px; }
.wizard-count { margin-left: auto; }
@media (max-width: 860px) {
    .wizard { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); overflow-y: auto; }
    .wizard-rail { order: -1; border-left: 0; border-bottom: 1px solid var(--border); padding: 16px 24px; overflow: visible; }
    .wizard-rail .steps, .wizard-rail-block { display: none; }
    .wizard-main { overflow: visible; }
}

/* Small, common utilities the pages need. Spacing is NOT a utility in the DS:
   stacks, sections and rows space their children with gap. */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-prewrap { white-space: pre-wrap; }
.tile-sub     { font: 500 12px/1.3 var(--font-body); opacity: 0.75; }
.overlay-modal.overlay-modal-sm { max-width: 400px; }
.overlay-modal.overlay-modal-md { max-width: 560px; }
/* Clickable tile: a whole .tile as an <a> or <button> (stat tiles that open
   a tab or page). Same tile, plus pointer, focus ring and the hover lift. */
.tile-action { font: inherit; color: inherit; text-decoration: none; cursor: pointer; transition: transform 160ms, box-shadow 160ms; }
.tile-action:hover { transform: translateY(-2px); box-shadow: 0 8px 24px color-mix(in srgb, var(--foreground) 10%, transparent); text-decoration: none; }
.tile-action:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.tile-value-row { display: inline-flex; align-items: center; gap: 8px; }
.tile-value-row > i { font-size: 0.6em; color: var(--warning); }
.text-mono { font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: 13px; }
/* Optional / secondary note inside a .form-label ("(optional)"). */
.form-label-hint { font-weight: 500; color: var(--foreground-muted); }
/* Inset panel: a quiet surface inside a section (previews, summaries). */
.inset { background: var(--surface-subtle); border-radius: var(--radius-md); padding: 16px; }
/* PICKER - type to search, pick one from a dropdown, show it as a chip.
   <div class="picker menu-anchor"> field/input
     <div class="menu menu-fill" hidden> .menu-item results </div>
   </div>  then the chosen value as .chip.chip-lg with a .chip-remove button. */
.menu-anchor > .menu.menu-fill { left: 0; right: 0; max-height: 280px; overflow-y: auto; }
.menu-item-sub { display: block; font: 500 12px/1.3 var(--font-body); color: var(--foreground-muted); }
.chip > .chip-remove { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0 0 0 4px; font-size: 1.1em; line-height: 1; opacity: 0.7; }
.chip > .chip-remove:hover { opacity: 1; }
.picker { position: relative; }
.picker > .search-field { width: 100%; }
.picker-value { align-self: flex-start; }
.item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.song-action.song-action-danger:hover { color: var(--danger); }
.card-file .song-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* File cards are compact: a 4:3 preview, a big brand-coloured icon when the
   file has no image, tight text and tools. */
.card-file .song-media { aspect-ratio: 4 / 3; }
.card-file .song-media-empty { background: var(--primary-subtle); color: var(--primary); }
.card-file .song-media-empty > :is(i, svg) { font-size: 48px; width: 48px; height: 48px; }
.card-file .song-body { padding: 8px 10px 10px; }
.card-file .song-title { font-size: 13px; }
.card-file .song-actions { margin-top: 6px; padding-top: 6px; }
/* A submit button sitting in a field grid lines up with the inputs. */
.form-grid-action { align-self: end; }
.song-row[role="button"] { cursor: pointer; }
.text-strike { text-decoration: line-through; }
.text-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* End-aligned row: on its own or as a modifier of .inline. */
.inline-end { display: flex; flex-wrap: wrap; align-items: center; gap: var(--item-gap); justify-content: flex-end; }
/* Table actions: the last column of admin and list tables. Always right
   aligned, as narrow as its buttons, buttons never wrap under each other. */
.table .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.table .col-actions > .inline,
.table .col-actions > .inline-end { flex-wrap: nowrap; justify-content: flex-end; gap: 4px; }
/* Equal columns that wrap: side-by-side panels inside a section. */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--item-gap); }
/* Roomier columns for fields that carry a control row (pickers, selects). */
.cols-lg { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
/* Aside column that stays in view while the main column scrolls. */
.aside-sticky { position: sticky; top: calc(var(--header-space, 80px) + 16px); }
@media (max-width: 960px) { .aside-sticky { position: static; } }
.comp-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; position: relative; z-index: 3; }
.text-nowrap { white-space: nowrap; }
.table tr.is-active { background: var(--primary-subtle); }
/* Invalid inputs (set aria-invalid="true" from validation). */
.form-input[aria-invalid="true"], .form-textarea[aria-invalid="true"], .form-select[aria-invalid="true"] { border-color: var(--danger); }
/* Choice list: an .item holding a radio/check is a selectable option card. */
label.item { cursor: pointer; }
.item-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.item-text > small { font: 500 12px/1.4 var(--font-body); color: var(--foreground-muted); }
/* Drag handle for sortable rows (SortableJS handle). */
.drag-handle { cursor: grab; color: var(--foreground-muted); }
.drag-handle:active { cursor: grabbing; }
.song-row.is-active { background: var(--primary-subtle); }
/* CONTROL ROW  .control-row - label | control | value, one per line
   (theme editor sliders, colour tokens, shape pickers). */
.control-row { display: grid; grid-template-columns: minmax(100px, 160px) minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 6px 0; }
.control-row > .control-label { font: 500 13px/1.3 var(--font-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.control-row > .control-value { font: 500 12px/1 var(--font-mono, ui-monospace, monospace); color: var(--foreground-muted); min-width: 48px; text-align: right; }
.control-row-swatch { grid-template-columns: auto minmax(0, 1fr) auto; }
/* A segmented control in a control row sizes to its options. */
.control-row > .tabs { justify-self: start; }
/* CONTROL PANEL  .control-panel - the admin settings layout: one row per
   setting, the name (with an info tip holding the help text) on the left and
   the control on the right, rows divided by a rule. Built with
   ds_control_row() / ds_control_switch(). Save buttons go in the section's
   own .section-actions after the body, so the space above them is the same
   on every page.
     .control-panel
       └─ .control-panel-row
            ├─ .control-name  (label + .info-tip[data-popover])
            └─ .control-field (input, select, switch, or several of them) */
.control-panel { display: flex; flex-direction: column; container-type: inline-size; }
/* One label column width everywhere (--control-label-width), so labels line
   up from page to page and dialog to dialog. */
.control-panel-row { display: grid; grid-template-columns: var(--control-label-width) minmax(0, 1fr); align-items: center; gap: 8px 24px; padding: 14px 0; border-top: 1px solid var(--border); }
.control-panel-row:first-child { border-top: 0; padding-top: 0; }
.control-panel-row:last-child { padding-bottom: 0; }
.control-panel-row-top { align-items: start; }
.control-name { display: flex; align-items: center; gap: 6px; min-width: 0; font: 600 14px/1.35 var(--font-body); color: var(--foreground); }
.control-name > label { cursor: pointer; }
.control-field { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; font: 500 14px/1.45 var(--font-body); color: var(--foreground); overflow-wrap: anywhere; }
.control-field > .form-input, .control-field > .form-select, .control-field > .form-textarea,
.control-field > .input-prefix, .control-field > .input-suffix, .control-field > .search-field,
.control-field > .menu-anchor, .control-field > .post-editor { flex: 1 1 220px; min-width: 0; }
.control-field > .form-textarea { width: 100%; }
.control-field > .menu-anchor > .search-field { width: 100%; }
.control-field-full { flex: 1 1 100%; min-width: 0; }
.control-field > .range { flex: 1 1 200px; min-width: 120px; }
/* File inputs: the browser's chooser button styled like a secondary button. */
.form-input[type="file"] { height: auto; padding: 6px; cursor: pointer; }
.form-input[type="file"]::file-selector-button { margin-right: 12px; padding: 8px 16px; border: 0; border-radius: var(--btn-radius); background: var(--surface-subtle); color: var(--foreground); font: 600 13px/1 var(--font-body); cursor: pointer; }
.control-field > .color-field { flex: 1 1 220px; }
.control-value { font: 500 13px/1.3 var(--font-body); color: var(--foreground-muted); }
/* In a narrow column the name sits above its control. */
@container (max-width: 440px) { .control-panel-row { grid-template-columns: 1fr; } }
/* TYPE PREVIEW  .type-preview - a sample of one typography setting, under
   its control on the Theme page. Reads the live tokens. */
.type-preview { display: flex; flex-direction: column; gap: 8px; padding: 20px; border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--border); }
.type-preview > p { margin: 0; }
.type-preview-display { font: 800 calc(40px * var(--font-scale))/1.1 var(--font-display); letter-spacing: -0.02em; }
.type-preview-heading { font: 700 calc(22px * var(--font-scale))/1.2 var(--font-display); }
.type-preview-card { font: 700 calc(15px * var(--font-scale))/1.3 var(--font-display); }
.type-preview-subtitle { font: 500 calc(14px * var(--font-scale))/1.45 var(--font-body); opacity: 0.7; }
.type-preview-body { font: 500 calc(15px * var(--font-scale))/1.6 var(--font-body); max-width: 70ch; }
.type-preview-meta { font: 500 calc(12px * var(--font-scale))/1.4 var(--font-body); color: var(--foreground-muted); }
/* LAYOUT DEMO  .layout-demo[data-focus] - a small drawing of a page that
   uses the live layout tokens (scaled to 40%); the measure the setting
   changes is drawn in the brand colour. */
.layout-demo { display: flex; justify-content: center; padding: 16px; border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--border); overflow: hidden; }
.layout-demo-page { --demo: 0.4; width: min(100%, calc(var(--page-width) * var(--demo))); padding: 0 calc(var(--page-padding) * var(--demo)); display: flex; flex-direction: column; background: var(--background); border-radius: var(--radius-sm); outline: 1px dashed var(--border); }
.layout-demo-nav { height: 16px; margin-top: 6px; border-radius: var(--navbar-radius, 999px); background: var(--surface); }
.layout-demo-top { height: calc(var(--page-top-gap) * var(--demo)); }
.layout-demo-gap { height: calc(var(--section-gap) * var(--demo)); }
.layout-demo-section { padding: calc(var(--section-padding) * var(--demo)); border-radius: calc(var(--section-radius) * var(--demo)); background: var(--surface); }
.layout-demo-section:last-child { margin-bottom: 10px; }
.layout-demo-body { display: flex; flex-direction: column; gap: calc(var(--item-gap) * var(--demo)); }
.layout-demo-body > span { height: 8px; border-radius: 4px; background: var(--border); }
.layout-demo[data-focus="page-width"] .layout-demo-page { outline: 2px solid var(--primary); }
.layout-demo[data-focus="page-padding"] .layout-demo-page { box-shadow: inset calc(var(--page-padding) * var(--demo)) 0 0 var(--primary-muted), inset calc(var(--page-padding) * var(--demo) * -1) 0 0 var(--primary-muted); }
.layout-demo[data-focus="page-top-gap"] .layout-demo-top,
.layout-demo[data-focus="section-gap"] .layout-demo-gap { background: var(--primary-muted); }
.layout-demo[data-focus="section-padding"] .layout-demo-section { background: var(--primary-muted); }
.layout-demo[data-focus="section-padding"] .layout-demo-body { background: var(--surface); }
.layout-demo[data-focus="item-gap"] .layout-demo-body { background: var(--primary-muted); }
.layout-demo[data-focus="item-gap"] .layout-demo-body > span { background: var(--surface); outline: 1px solid var(--border); }
/* ELEMENT SAMPLE  .element-sample - live examples of one element above its
   settings on the Theme page's Elements tab. */
.element-sample { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 20px; border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--border); }
.element-sample > .form-input, .element-sample > .form-select { flex: 1 1 200px; width: auto; }
.element-sample-wide { flex: 1 1 100%; }
.element-sample-card { flex: 0 1 280px; }
.element-sample-tile { flex: 0 1 180px; }
.element-sample-menu { position: static; flex: 0 1 220px; animation: none; }
.element-sample-cover { display: block; width: 96px; aspect-ratio: 1; border-radius: var(--cover-radius); background: linear-gradient(135deg, var(--feature-2), var(--feature-3)); }
/* SHAPE PICKER  .shape-picker of .shape-option - one choice per corner
   shape; each option shows its shape (--sample-radius) beside its name. */
.shape-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.shape-option { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); color: var(--foreground); font: 600 13px/1.2 var(--font-body); cursor: pointer; transition: background 120ms, border-color 120ms; }
.shape-option:hover { background: var(--surface-subtle); }
.shape-option[aria-checked="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-reverse); }
.shape-sample { width: 40px; height: 26px; border-radius: var(--sample-radius, 0); background: var(--primary-subtle); border: 2px solid var(--primary); flex-shrink: 0; }
.shape-sample-circle { width: 26px; }
.shape-option[aria-checked="true"] .shape-sample { background: color-mix(in srgb, var(--primary-reverse) 25%, transparent); border-color: var(--primary-reverse); }
/* IMAGE FIELD  .image-field[data-image-field] - an image setting: a
   contain-fit preview, Upload and Remove. ds.js uploads the file and keeps
   the hidden input holding the file name. Built with ds_image_field(). */
.image-field { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; flex: 1 1 100%; min-width: 0; }
.image-field > .logo-preview { width: 100%; }

/* AVATAR EDIT  .avatar-edit - an avatar that is its own change button: on
   hover or focus the photo dims and a camera icon shows over it. */
.avatar-edit { position: relative; display: inline-flex; padding: 0; border: 0; background: none; border-radius: var(--radius-circle); cursor: pointer; flex-shrink: 0; }
.avatar-edit-icon { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; border-radius: inherit; background: color-mix(in srgb, black 50%, transparent); color: #ffffff; font-size: 20px; opacity: 0; transition: opacity 150ms; }
.avatar-edit:hover .avatar-edit-icon, .avatar-edit:focus-visible .avatar-edit-icon { opacity: 1; }
.avatar-edit:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }

/* PROFILE CARD  .profile-card - the top of the profile page: the photo,
   the name with the email tight under it, and the role chip top right. */
.profile-card { display: flex; align-items: center; gap: 20px; min-width: 0; }
.profile-card-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.profile-card-name { margin: 0; font: 800 calc(24px * var(--font-scale))/1.2 var(--font-display); }
.profile-card-email { margin: 0; font: 500 14px/1.4 var(--font-body); color: var(--foreground-muted); overflow-wrap: anywhere; }
.profile-card-link { margin-top: 6px; font: 600 13px/1.3 var(--font-body); display: inline-flex; align-items: center; gap: 6px; }
.profile-card-role { align-self: flex-start; }

/* BACKGROUND IMAGES - a page (body.has-bg-image, --page-bg-image) or a
   section (.section-bg-image, --section-bg-image). A section's image sits
   under a wash of its own colour so the text stays readable. */
/* v326: an overlay colour sits over each image (--page-bg-overlay,
   --section-bg-overlay; ds_overlay_css). A section defaults to an 84% wash of
   its own colour so text stays readable; a page defaults to no overlay. */
body.has-bg-image { background: linear-gradient(var(--page-bg-overlay, transparent), var(--page-bg-overlay, transparent)) fixed, var(--page-bg-image) center / cover no-repeat fixed, var(--page-background, var(--background)); }
/* Dark mode (v328): the image stays, faint, under a wash of the dark
   background (--page-bg-dark-wash, Theme > Colours, 85% unless set). The
   light-mode overlay does not apply. */
[data-theme="dark"] body.has-bg-image { background: linear-gradient(color-mix(in srgb, var(--background) var(--page-bg-dark-wash, 85%), transparent), color-mix(in srgb, var(--background) var(--page-bg-dark-wash, 85%), transparent)) fixed, var(--page-bg-image) center / cover no-repeat fixed, var(--background); }
.section.section-bg-image { background: linear-gradient(var(--section-bg-overlay, color-mix(in srgb, var(--section-bg) 84%, transparent)), var(--section-bg-overlay, color-mix(in srgb, var(--section-bg) 84%, transparent))), var(--section-bg-image) center / cover no-repeat; }

/* INFO TIP  .info-tip - a small round (i) after a setting's name; its
   data-popover holds the help text, shown on hover, focus or click. */
.info-tip { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--foreground-muted); font-size: 13px; cursor: help; flex-shrink: 0; }
.section-title > .info-tip { vertical-align: middle; margin-left: 2px; }
.info-tip:hover, .info-tip:focus { color: var(--primary); outline: none; }
.info-tip:focus-visible { box-shadow: 0 0 0 2px var(--primary-subtle); }
/* The tip's popover is only laid out while shown, so a hidden one near the
   window edge never widens the page. */
.info-tip[data-popover]::after, .info-tip[data-popover]::before { display: none; }
.info-tip[data-popover]::after { text-align: left; }
.info-tip[data-popover]:is(:hover, :focus)::after, .info-tip[data-popover]:is(:hover, :focus)::before { display: block; }
.info-tip[data-popover]:focus::after, .info-tip[data-popover]:focus::before { opacity: 1; }
.info-tip[data-popover]:focus::after { transform: translateX(-50%) translateY(0); }
.info-tip[data-popover-side="right"]:focus::after { transform: translateY(-50%) translateX(0); }
/* SWATCH  .swatch - a colour chip; colour comes from --swatch. Wrapped
   around an <input type="color"> it becomes the picker (.swatch-input). */
.swatch { display: inline-block; width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--swatch, var(--surface-subtle)); border: 1px solid var(--border); flex-shrink: 0; }
.swatch-sm { width: 20px; height: 20px; }
.swatch-input { position: relative; cursor: pointer; overflow: hidden; }
.swatch-input > input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.swatch-strip { display: flex; gap: 4px; }
/* Embedded player frame (YouTube preview etc): 16:9, iframe fills it. */
.embed-frame { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius-md); overflow: hidden; background: var(--surface-subtle); }
.embed-frame > iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* Summary bar: label + note on the left, a figure on the right (costs, totals). */
.summary-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.summary-value { font: 800 22px/1.1 var(--font-display); }
/* Small image thumbnail beside an upload field (preview). */
.media-thumb { height: 48px; width: auto; max-width: 160px; border-radius: var(--radius-sm); object-fit: cover; display: block; }
.media-thumb-lg { height: 80px; }
/* Logos: show the whole image, never crop. */
.media-thumb-contain { object-fit: contain; background: var(--surface-subtle); padding: 4px; }
/* Native colour input sized to the field height. */
input[type="color"].form-color { width: 48px; height: var(--field-height, 44px); padding: 3px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; flex-shrink: 0; }
/* In a footer row, push this item (a destructive action) to the start. */
.push-start { margin-right: auto; }
/* Push this item (an action at the end of a bar) to the far end. */
.push-end { margin-left: auto; }
.text-strong { font-weight: 600; }
/* Avatar tinted with a data colour (badge icons): --avatar-color. */
.avatar-color { background: var(--avatar-color, var(--primary)); color: #fff; }
.chip[role="button"] { cursor: pointer; }
/* Font picker option previewed in its own face (--preview-font). */
.font-preview { font-family: var(--preview-font, inherit); }
.text-num { font-variant-numeric: tabular-nums; font-weight: 700; }
/* Image preview in a form (upload fields): a contained 16:9 frame. */
.media-preview { width: 100%; max-width: 360px; aspect-ratio: 16 / 9; border-radius: var(--radius-md); overflow: hidden; background: var(--surface-subtle); }
.media-preview > img { width: 100%; height: 100%; object-fit: cover; display: block; }


/* The hidden attribute always hides, even on primitives that set their own
   display (.section is flex). Kept LAST in the file so it wins every
   single-class rule without !important. */

/* GLOBAL RHYTHM - nothing in the DS may sit flush against its neighbour.
   1. Forms are a column with the item gap, like every other container, so a
      field never touches the next label. Buttons keep their natural width.
   2. Two sections that end up as siblings outside a gap container (a tab
      panel wrapper, a JS-built list) still get the section gap. Inside the
      DS gap containers the gap does the work, so the margin is cleared. */
form { display: flex; flex-direction: column; gap: var(--item-gap); }
form > .btn { align-self: flex-start; }
/* Any section after a VISIBLE earlier sibling section. Hidden tab panels
   (sections with [hidden]) do not count, so the first visible panel after a
   tab bar sits at the normal gap instead of picking up a phantom margin. */
.section:not([hidden]) ~ .section { margin-top: var(--section-gap); }
:is(.page-container, .page-stack, .section-row, .layout-aside > *, .stack, .vibe-stack, [data-tab-panel], form) > .section:not([hidden]) ~ .section { margin-top: 0; }

/* Filters in a section header: one compact toolbar beside the title. */
.section-header > .section-toolbar { flex: 0 1 auto; margin-left: auto; max-width: 100%; }
.section-toolbar > .search-field { flex: 1 1 220px; min-width: 140px; }
.toolbar > .check { padding: 0 10px; white-space: nowrap; }
@media (max-width: 720px) { .section-header > .section-toolbar { flex: 1 1 100%; flex-wrap: wrap; } }

/* Vibe page: card + stats as one centred column at the card's large size. */
.vibe-page { width: 100%; max-width: 560px; margin: 0 auto; }
.vibe-content-actions { display: flex; justify-content: center; gap: 4px; margin-top: 12px; flex-wrap: wrap; }
.vibe-content-actions .following { color: var(--primary); }
.vibe-action:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* CAPPED LIST  [data-capped] - long lists show their first five rows; the
   .list-more button underneath reveals the rest (DS.capLists / DS.tile.list). */
[data-capped]:not(.is-expanded) > :nth-child(n+6) { display: none; }
.list-more { align-self: flex-start; margin-top: 8px; }

/* TOOLBAR ICON  .toolbar-icon - round icon control for a compact toolbar
   (search, filter, view). Same 42px family height as every toolbar control.
   aria-expanded (its menu or search is open) shows the primary tint;
   data-active (a choice other than the default is on) goes solid primary. */
.toolbar-icon {
    width: var(--toolbar-icon-size); height: var(--toolbar-icon-size); flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: var(--radius-circle);
    background: var(--toolbar-icon-bg); color: var(--foreground);
    font-size: 15px; cursor: pointer;
    transition: background 120ms, color 120ms;
}
.toolbar-icon:hover { background: color-mix(in srgb, var(--foreground) 10%, var(--surface)); }
.toolbar-icon[aria-expanded="true"] { background: var(--primary-subtle); color: var(--primary); }
/* A filter is on: solid primary (pseudo-elements belong to the tooltip). */
.toolbar-icon[data-active] { background: var(--primary); color: var(--primary-reverse); }

/* TOOLBAR SEARCH  .toolbar-search - search that collapses to its icon. Open
   (.is-open) the field grows out of the icon; the clear button sits at its
   end. Text matches menu items (14px, 500). */
.toolbar-search { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.toolbar-search-input {
    width: 0; min-width: 0; height: 42px; padding: 0;
    border: 0; background: transparent; outline: none; opacity: 0;
    color: var(--foreground); font: 500 14px/1 var(--font-body);
    transition: width 240ms cubic-bezier(0.2, 0.7, 0.2, 1), padding 240ms, opacity 180ms;
}
.toolbar-search-input::placeholder { color: var(--foreground-muted); }
.toolbar-search-input::-webkit-search-decoration,
.toolbar-search-input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.toolbar-search-clear {
    display: none; width: 30px; height: 30px; flex-shrink: 0;
    align-items: center; justify-content: center;
    border: 0; border-radius: var(--radius-circle); background: transparent;
    color: var(--foreground-muted); cursor: pointer; font-size: 14px;
}
.toolbar-search-clear:hover { background: var(--surface-subtle); color: var(--foreground); }
.toolbar-search.is-open { flex: 1 1 auto; }
.toolbar-search.is-open .toolbar-search-input { width: clamp(160px, 26vw, 320px); padding: 0 6px 0 10px; opacity: 1; flex: 1 1 auto; }
.toolbar-search.is-open .toolbar-search-clear { display: inline-flex; }

/* INPUT PREFIX / SUFFIX  .input-prefix, .input-suffix - a fixed lead-in or
   unit joined to a text input (a page address "/" + slug; a size + "px"). */
.input-prefix { display: flex; align-items: stretch; min-width: 0; }
.input-prefix-text { display: inline-flex; align-items: center; padding: 0 12px; background: var(--surface-subtle); color: var(--foreground-muted); font: 500 14px/1 var(--font-mono, ui-monospace, monospace); border: var(--field-border-width) solid var(--field-border-color); border-right: 0; border-radius: var(--field-radius) 0 0 var(--field-radius); }
.input-prefix > .form-input { flex: 1; min-width: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }

.input-suffix { display: flex; align-items: stretch; min-width: 0; }
.input-suffix > .form-input { flex: 1; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-suffix-text { display: inline-flex; align-items: center; padding: 0 12px; background: var(--surface-subtle); color: var(--foreground-muted); font: 500 14px/1 var(--font-mono, ui-monospace, monospace); border: var(--field-border-width) solid var(--field-border-color); border-left: 0; border-radius: 0 var(--field-radius) var(--field-radius) 0; }

/* BADGE CARD  .badge-card - a badge in the admin badge grid: icon, name,
   description, actions; .is-muted when disabled. */
.badge-card { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.badge-card > .inline { margin-top: auto; }
.card.is-muted { opacity: 0.6; }

/* CURRENT ITEM  .menu-item[aria-current="page"] - the page you are on, in a
   side navigation built from menu items (the admin sidebar). */
.menu-item[aria-current="page"] { background: var(--primary-subtle); color: var(--primary); font-weight: 600; }

/* ADMIN LAYOUT  .admin-layout - every admin page: the grouped admin sidebar
   (.admin-nav, menu labels + menu items) beside the page's own content. The
   sidebar scrolls within the viewport; on narrow screens it gives way to the
   navbar toolbox menu, which holds the same links. */
.admin-layout { grid-template-columns: 240px minmax(0, 1fr); }
.admin-nav { gap: 4px; padding: 12px; max-height: calc(100vh - var(--header-space, 80px) - 32px); overflow-y: auto; }
.admin-nav-group { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.admin-nav-group[hidden] { display: none; }
.admin-nav-filter { margin-bottom: 8px; }
/* Matches on the current page (section titles and settings), under the filter. */
.admin-nav-results { display: flex; flex-direction: column; gap: 4px; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.admin-nav-results .menu-item { white-space: normal; text-align: left; }
.admin-nav-group > summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; padding: 8px 10px 4px; border-radius: var(--radius-sm); }
.admin-nav-group > summary::-webkit-details-marker { display: none; }
.admin-nav-group > summary::after { content: ""; width: 6px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); margin: 0 4px 3px 0; transition: transform 160ms; }
.admin-nav-group:not([open]) > summary::after { transform: rotate(-45deg); margin-bottom: 0; }
.admin-nav-group > summary:hover { color: var(--foreground); }
@media (max-width: 960px) { .admin-layout > aside { display: none; } }

/* Long menus (e.g. a type list from the API) scroll inside a capped height. */
.menu-scroll { max-height: min(360px, 60vh); overflow-y: auto; }

/* Navbar menus (admin, account) can be long: they scroll within the viewport below the header. */
.nav-menu.menu-scroll { max-height: calc(100vh - var(--header-space, 80px) - 24px); }

/* CHOICE MENU  items with role menuitemradio / menuitemcheckbox (DS choice
   menu in ds.js) show a tick at the end when aria-checked is true. */
.menu-item[aria-checked]::after {
    content: ""; flex-shrink: 0; margin-left: auto;
    width: 5px; height: 10px; margin-right: 4px;
    border: solid currentColor; border-width: 0 2px 2px 0;
    transform: translateY(-2px) rotate(45deg);
    opacity: 0;
}
.menu-item[aria-checked="true"] { color: var(--primary); }
.menu-item[aria-checked="true"]::after { opacity: 1; }

/* SLIDE PANES  .slide-panes - a list and its detail in one place (v324).
   The list pane shows; .is-detail slides the list off to the right and the
   detail pane in from the left. The pane not showing leaves the flow, so the
   container is always the height of what is on screen. */
.slide-panes { position: relative; overflow-x: clip; }
.slide-pane { transition: transform 320ms ease, opacity 320ms ease, visibility 320ms; }
.slide-pane-detail,
.slide-panes.is-detail > .slide-pane-list { position: absolute; top: 0; left: 0; right: 0; opacity: 0; visibility: hidden; pointer-events: none; }
.slide-pane-detail { transform: translateX(-100%); }
.slide-panes.is-detail > .slide-pane-list { transform: translateX(100%); }
.slide-panes.is-detail > .slide-pane-detail { position: static; transform: none; opacity: 1; visibility: visible; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) { .slide-pane { transition: none; } }

[hidden] { display: none; }
