/* Mah Select v1 — reusable single/multi/tree selector */
:root {
    --mah-select-primary: #4c78dd;
    --mah-select-primary-soft: color-mix(in srgb, var(--mah-select-primary) 12%, transparent);
    --mah-select-surface: #fff;
    --mah-select-text: #2f3441;
    --mah-select-muted: #7a8191;
    --mah-select-border: #dce1e8;
    --mah-select-danger: #dc3545;
    --mah-select-radius: 10px;
    --mah-select-shadow: 0 14px 38px rgba(30, 38, 55, .16);
}

.mah-select,
.mah-select__panel,
.mah-select__backdrop {
    box-sizing: border-box;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

.mah-select *,
.mah-select__panel *,
.mah-select__backdrop * {
    box-sizing: border-box;
    font-family: inherit;
}

/* Dashmix ships Font Awesome 6 and uses the `fa fa-*` convention. The broad
   typography inheritance above must not replace the icon font. */
.mah-select .fa,
.mah-select__panel .fa,
.mah-select__backdrop .fa {
    font-family: var(--fa-style-family, "Font Awesome 6 Free");
    font-style: normal;
    font-weight: var(--fa-style, 900);
}

.mah-select {
    position: relative;
    width: 100%;
    color: var(--mah-select-text);
}

.mah-select__native-source {
    position: absolute !important;
    inset: auto auto 0 0 !important;
    width: 1px !important;
    height: 1px !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    clip: rect(0 0 0 0) !important;
    clip-path: inset(50%) !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.mah-select.is-invalid .mah-select__trigger {
    border-color: var(--mah-select-danger);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mah-select-danger) 14%, transparent);
}

.mah-select__trigger {
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .65rem;
    padding: .45rem .7rem;
    color: var(--mah-select-text);
    background: var(--mah-select-surface);
    border: 1px solid var(--mah-select-border);
    border-radius: var(--mah-select-radius);
    text-align: start;
    cursor: pointer;
    transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.mah-select__trigger:hover:not(:disabled) {
    border-color: color-mix(in srgb, var(--mah-select-primary) 55%, var(--mah-select-border));
}

.mah-select__trigger:focus-visible,
.mah-select.is-open .mah-select__trigger {
    outline: 0;
    border-color: var(--mah-select-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mah-select-primary) 18%, transparent);
}

.mah-select__trigger:disabled {
    opacity: .58;
    cursor: not-allowed;
    background: color-mix(in srgb, var(--mah-select-muted) 8%, var(--mah-select-surface));
}

.mah-select.is-loading .mah-select__chevron i {
    animation: mah-select-spin .75s linear infinite;
}

.mah-select.is-loading .mah-select__chevron i::before {
    content: "\f110";
}

.mah-select.has-limit-error .mah-select__trigger {
    animation: mah-select-shake 220ms ease-in-out 2;
    border-color: var(--mah-select-danger);
}

.mah-select__trigger-value,
.mah-select__selected-summary,
.mah-select__multi-summary {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: .55rem;
}

.mah-select__placeholder {
    color: var(--mah-select-muted);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.mah-select__selected-title,
.mah-select__multi-summary > span:last-child {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.mah-select__trigger-tools {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}

.mah-select__count {
    min-width: 1.35rem;
    height: 1.35rem;
    display: inline-grid;
    place-items: center;
    padding-inline: .3rem;
    border-radius: 999px;
    color: #fff;
    background: var(--mah-select-primary);
    font-size: .72em;
    font-weight: 700;
}

.mah-select__chevron {
    color: var(--mah-select-muted);
    font-size: .72em;
    transition: transform 150ms ease;
}

.mah-select.is-open .mah-select__chevron {
    transform: rotate(180deg);
}

.mah-select__panel {
    position: fixed;
    z-index: 1095;
    display: none;
    flex-direction: column;
    min-width: min(280px, calc(100vw - 16px));
    overflow: hidden;
    color: var(--mah-select-text);
    background: var(--mah-select-surface);
    border: 1px solid var(--mah-select-border);
    border-radius: calc(var(--mah-select-radius) + 2px);
    box-shadow: var(--mah-select-shadow);
    opacity: 0;
    transform: translateY(-4px) scale(.99);
    transform-origin: top center;
}

.mah-select__panel.is-open {
    display: flex;
    animation: mah-select-enter 150ms cubic-bezier(.2, .75, .25, 1) forwards;
}

.mah-select__panel.is-top {
    transform-origin: bottom center;
}

.mah-select__panel-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .85rem 1rem .55rem;
    border-bottom: 1px solid var(--mah-select-border);
}

.mah-select__panel-title {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.mah-select__close {
    width: 2rem;
    height: 2rem;
    display: inline-grid;
    place-items: center;
    color: var(--mah-select-muted);
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.mah-select__close:hover {
    color: var(--mah-select-text);
    background: color-mix(in srgb, var(--mah-select-muted) 10%, transparent);
}

.mah-select__mobile-handle {
    display: none;
}

.mah-select__search {
    position: relative;
    display: flex;
    align-items: center;
    margin: .7rem .7rem .35rem;
}

.mah-select__search > i {
    position: absolute;
    inset-inline-start: .75rem;
    z-index: 1;
    color: var(--mah-select-muted);
    pointer-events: none;
}

.mah-select__search input {
    width: 100%;
    min-height: 38px;
    padding: .45rem 2.25rem .45rem .7rem;
    color: var(--mah-select-text);
    background: color-mix(in srgb, var(--mah-select-muted) 5%, var(--mah-select-surface));
    border: 1px solid var(--mah-select-border);
    border-radius: 8px;
    outline: 0;
}

[dir="ltr"] .mah-select__search input {
    padding: .45rem .7rem .45rem 2.25rem;
}

.mah-select__search input:focus {
    border-color: var(--mah-select-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--mah-select-primary) 12%, transparent);
}

.mah-select__spinner {
    position: absolute;
    inset-inline-end: .75rem;
    color: var(--mah-select-primary);
}

.mah-select__toolbar {
    min-height: 34px;
    display: flex;
    align-items: center;
    gap: .25rem;
    padding: .15rem .7rem .45rem;
    border-bottom: 1px solid var(--mah-select-border);
}

.mah-select__action,
.mah-select__load-more,
.mah-select__preview-clear {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .25rem .45rem;
    color: var(--mah-select-primary);
    background: transparent;
    border: 0;
    border-radius: 6px;
    font-size: .78em;
    cursor: pointer;
}

.mah-select__action:hover,
.mah-select__load-more:hover,
.mah-select__preview-clear:hover {
    background: var(--mah-select-primary-soft);
}

.mah-select__clear,
.mah-select__preview-clear {
    color: var(--mah-select-danger);
}

.mah-select__selection-status {
    margin-inline-start: auto;
    color: var(--mah-select-muted);
    font-size: .75em;
}

.mah-select__notice {
    margin: .45rem .7rem 0;
    padding: .5rem .65rem;
    border-radius: 7px;
    color: var(--mah-select-text);
    background: color-mix(in srgb, var(--mah-select-primary) 10%, var(--mah-select-surface));
    border-inline-start: 3px solid var(--mah-select-primary);
    font-size: .82em;
}

.mah-select__notice.is-danger {
    color: color-mix(in srgb, var(--mah-select-danger) 82%, #000);
    background: color-mix(in srgb, var(--mah-select-danger) 10%, var(--mah-select-surface));
    border-color: var(--mah-select-danger);
}

.mah-select__notice.is-warning {
    background: #fff7df;
    border-color: #e8a600;
}

.mah-select__pinned-selection {
    display: flex;
    gap: .35rem;
    overflow-x: auto;
    padding: .5rem .7rem;
    border-bottom: 1px solid var(--mah-select-border);
    scrollbar-width: thin;
}

.mah-select__pinned-card {
    flex: 0 0 auto;
    max-width: 180px;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem .45rem;
    color: var(--mah-select-text);
    background: var(--mah-select-primary-soft);
    border: 1px solid color-mix(in srgb, var(--mah-select-primary) 25%, transparent);
    border-radius: 999px;
    font-size: .78em;
    cursor: pointer;
}

.mah-select__pinned-card > span:not(.mah-select__media) {
    max-width: 100px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.mah-select__pinned-card > i {
    color: var(--mah-select-danger);
    font-size: .8em;
}

.mah-select__options {
    flex: 1 1 auto;
    max-height: var(--mah-select-list-max-height, 360px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--mah-select-muted) 45%, transparent) transparent;
}

.mah-select__option {
    --mah-select-depth: 0;
    position: relative;
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .42rem .65rem;
    padding-inline-start: calc(.65rem + var(--mah-select-depth) * 1.1rem);
    border-bottom: 1px solid color-mix(in srgb, var(--mah-select-border) 60%, transparent);
    cursor: pointer;
    transition: background-color 110ms ease, color 110ms ease;
}

.mah-select__option[hidden] {
    display: none !important;
}

.mah-select__option:hover,
.mah-select__option:focus-visible {
    outline: 0;
    background: color-mix(in srgb, var(--mah-select-primary) 7%, var(--mah-select-surface));
}

.mah-select__option.is-selected {
    background: var(--mah-select-primary-soft);
}

.mah-select__option.is-disabled {
    opacity: .5;
    background: color-mix(in srgb, var(--mah-select-muted) 5%, var(--mah-select-surface));
    cursor: not-allowed;
}

.mah-select__option--pinned {
    position: sticky;
    top: 0;
    z-index: 2;
    background: color-mix(in srgb, var(--mah-select-primary) 6%, var(--mah-select-surface));
    box-shadow: 0 1px 0 var(--mah-select-border);
}

.mah-select__tree-toggle,
.mah-select__tree-spacer {
    width: 1.5rem;
    height: 1.5rem;
    flex: 0 0 1.5rem;
}

.mah-select__tree-toggle {
    display: grid;
    place-items: center;
    padding: 0;
    color: var(--mah-select-muted);
    background: transparent;
    border: 0;
    border-radius: 5px;
    cursor: pointer;
    transition: transform 120ms ease, background-color 120ms ease;
}

.mah-select__tree-toggle:hover {
    background: color-mix(in srgb, var(--mah-select-muted) 10%, transparent);
}

[dir="ltr"] .mah-select__tree-toggle {
    transform: rotate(180deg);
}

.mah-select__option.is-collapsed .mah-select__tree-toggle {
    transform: rotate(-90deg);
}

[dir="ltr"] .mah-select__option.is-collapsed .mah-select__tree-toggle {
    transform: rotate(90deg);
}

.mah-select__media {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: inline-grid;
    place-items: center;
    overflow: hidden;
    color: #fff;
    background: var(--mah-select-media-color, var(--mah-select-primary));
    border-radius: 50%;
    font-size: .78em;
    font-weight: 700;
}

.mah-select__media--image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mah-select__trigger .mah-select__media,
.mah-select__pinned-card .mah-select__media,
.mah-select__media-stack .mah-select__media {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
}

.mah-select__media-stack {
    display: inline-flex;
    direction: ltr;
    padding-inline-start: .3rem;
}

.mah-select__media-stack .mah-select__media {
    margin-inline-start: -.3rem;
    border: 2px solid var(--mah-select-surface);
}

.mah-select__details {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: .12rem;
}

.mah-select__title {
    overflow: hidden;
    color: var(--mah-select-text);
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.mah-select__subtitle {
    display: flex;
    flex-wrap: wrap;
    gap: .15rem .65rem;
    color: var(--mah-select-muted);
    font-size: .76em;
}

.mah-select__subtitle > span {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}

.mah-select__accessory {
    flex: 0 0 auto;
    max-width: 35%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.mah-select__accessory--badge {
    padding: .18rem .48rem;
    color: var(--mah-select-primary);
    background: var(--mah-select-primary-soft);
    border-radius: 999px;
    font-size: .72em;
    font-weight: 700;
}

.mah-select__accessory--text {
    color: var(--mah-select-muted);
    font-size: .76em;
}

.mah-select__accessory--empty {
    width: 0;
}

.mah-select__check {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    display: grid;
    place-items: center;
    color: transparent;
    border: 1.5px solid var(--mah-select-border);
    border-radius: 6px;
    font-size: .7em;
    transition: color 110ms ease, border-color 110ms ease, background-color 110ms ease;
}

.mah-select__panel--single .mah-select__check {
    border-radius: 50%;
}

.mah-select__option.is-selected .mah-select__check {
    color: #fff;
    background: var(--mah-select-primary);
    border-color: var(--mah-select-primary);
}

.mah-select__option.is-partial .mah-select__check {
    border-color: var(--mah-select-primary);
    box-shadow: inset 0 0 0 4px var(--mah-select-surface), inset 0 0 0 12px var(--mah-select-primary);
}

.mah-select__empty {
    padding: 1.7rem 1rem;
    color: var(--mah-select-muted);
    text-align: center;
}

.mah-select__pagination {
    padding: .45rem .7rem;
    text-align: center;
    border-top: 1px solid var(--mah-select-border);
}

.mah-select__load-more {
    justify-content: center;
    width: 100%;
}

.mah-select__preview {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    margin-top: .45rem;
}

.mah-select__chips {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
}

.mah-select__chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    max-width: 100%;
    padding: .24rem .5rem;
    color: var(--mah-select-text);
    background: var(--mah-select-primary-soft);
    border-radius: 999px;
    font-size: .76em;
}

.mah-select__chip > span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.mah-select__chip-remove {
    display: inline-grid;
    place-items: center;
    padding: 0;
    color: var(--mah-select-muted);
    background: transparent;
    border: 0;
    cursor: pointer;
}

.mah-select__chip-remove:hover {
    color: var(--mah-select-danger);
}

.mah-select__backdrop {
    position: fixed;
    inset: 0;
    z-index: 1090;
    display: none;
    padding: 0;
    background: rgba(19, 24, 34, .42);
    border: 0;
    opacity: 0;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

body.mah-select-page-locked {
    position: fixed;
    inset-inline: 0;
    width: 100%;
    overflow: hidden;
}

.mah-select__panel.is-mobile {
    inset: var(--mah-select-mobile-top-gap, 30vh) 0 0;
    width: 100%;
    max-width: none;
    max-height: none !important;
    border-width: 1px 0 0;
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
    transform-origin: bottom center;
    animation-name: mah-select-sheet-enter;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.mah-select__panel.is-mobile .mah-select__panel-header,
.mah-select__panel.is-mobile .mah-select__mobile-handle {
    display: flex;
}

.mah-select__panel.is-mobile .mah-select__options {
    max-height: none;
}

.mah-select__backdrop.is-open {
    display: block;
    animation: mah-select-fade 140ms ease forwards;
}

@media (max-width: 768px) {
    .mah-select__mobile-handle {
        width: 42px;
        height: 4px;
        align-self: center;
        margin-top: .5rem;
        background: color-mix(in srgb, var(--mah-select-muted) 35%, transparent);
        border-radius: 999px;
    }

    .mah-select__option {
        min-height: 56px;
        padding-block: .5rem;
    }

    .mah-select__toolbar {
        padding-block: .3rem .55rem;
    }
}

@keyframes mah-select-enter {
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes mah-select-sheet-enter {
    to { opacity: 1; transform: translateY(0); }
}

@keyframes mah-select-fade {
    to { opacity: 1; }
}

@keyframes mah-select-shake {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(3px); }
}

@keyframes mah-select-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .mah-select *,
    .mah-select__panel,
    .mah-select__backdrop {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}

