.qelk-mf-search-shell {
    --qelk-mf-search-admin-offset: 0px;

    position: fixed;
    inset: var(--qelk-mf-search-admin-offset) 0 auto 0;
    z-index: 900000;
    display: none;
    width: 100%;
    height: calc(100dvh - var(--qelk-mf-search-admin-offset));
    overflow: hidden;
    isolation: isolate;
    color: var(--mfp-text);
    pointer-events: none;
    overscroll-behavior: contain;
}

.qelk-mf-search-shell.is-open {
    display: block;
    pointer-events: auto;
}

body.admin-bar .qelk-mf-search-shell {
    --qelk-mf-search-admin-offset: 32px;
}

body.qelk-mf-search-open {
    overflow: hidden;
    overscroll-behavior: none;
}

.qelk-mf-search-backdrop {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: rgba(16,20,24,0.54);
    backdrop-filter: blur(8px);
    cursor: pointer;
    pointer-events: auto;
    touch-action: none;
}

.qelk-mf-search-panel {
    position: relative;
    z-index: 1;
    width: min(760px, calc(100% - 32px));
    max-height: min(760px, calc(100dvh - var(--qelk-mf-search-admin-offset) - 56px));
    margin: 28px auto 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid var(--mfp-border);
    border-radius: 28px;
    background: var(--mfp-card-strong);
    box-shadow: var(--mfp-shadow);
    pointer-events: auto;
    touch-action: pan-y;
    overscroll-behavior: contain;
}

.qelk-mf-search-bar {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 8px;
    align-items: center;
    padding: 14px;
    border-bottom: 1px solid var(--mfp-border);
}

.qelk-mf-search-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--mfp-border);
    border-radius: 999px;
    background: var(--mfp-bg-soft);
    color: var(--mfp-text);
    cursor: pointer;
}

.qelk-mf-search-icon-button:hover,
.qelk-mf-search-icon-button:focus {
    border-color: var(--mfp-accent);
    background: var(--mfp-accent-soft);
    outline: none;
}

.qelk-mf-search-button-icon,
.qelk-mf-search-button-icon svg {
    width: 18px;
    height: 18px;
}

.qelk-mf-search-form label {
    display: block;
}

.qelk-mf-search-form input {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--mfp-border);
    border-radius: 999px;
    padding: 0 20px;
    background: var(--mfp-bg-soft);
    color: var(--mfp-text);
    font: inherit;
    font-size: 16px;
    font-weight: 760;
    outline: none;
}

.qelk-mf-search-form input:focus {
    border-color: var(--mfp-accent);
    box-shadow: 0 0 0 3px var(--mfp-accent-soft);
}

.qelk-mf-search-form input[type="search"]::-webkit-search-cancel-button,
.qelk-mf-search-form input[type="search"]::-webkit-search-decoration {
    appearance: none;
    -webkit-appearance: none;
}

.qelk-mf-search-body {
    min-height: 0;
    overflow: auto;
    padding: 16px;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

.qelk-mf-search-content {
    display: grid;
    gap: 16px;
}

.qelk-mf-search-section {
    display: grid;
    gap: 8px;
}

.qelk-mf-search-section + .qelk-mf-search-section {
    padding-top: 4px;
}

.qelk-mf-search-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 28px;
}

.qelk-mf-search-section-head h2 {
    margin: 0;
    color: var(--mfp-text-muted);
    font-size: 12px;
    font-weight: 850;
    letter-spacing: 0;
    line-height: 1.2;
    text-transform: uppercase;
}

.qelk-mf-search-section-head button {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--mfp-accent-strong);
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.qelk-mf-search-list {
    display: grid;
    gap: 6px;
}

.qelk-mf-search-result {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    min-height: 52px;
    padding: 8px 10px 8px 12px;
    border-radius: 16px;
    color: var(--mfp-text);
    text-decoration: none;
}

.qelk-mf-search-result:hover,
.qelk-mf-search-result:focus {
    background: var(--mfp-accent-soft);
    outline: none;
}

.qelk-mf-search-result::after {
    content: ">";
    justify-self: end;
    grid-column: 1;
    grid-row: 1;
    color: var(--mfp-text-muted);
    font-size: 16px;
    font-weight: 700;
}

.qelk-mf-search-result img {
    grid-column: 1;
    grid-row: 1;
    width: 48px;
    height: 64px;
    border-radius: 12px;
    object-fit: cover;
    background: var(--mfp-bg-soft);
}

.qelk-mf-search-result > span {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    padding-right: 28px;
}

.qelk-mf-search-result--has-image {
    grid-template-columns: 48px minmax(0, 1fr);
    min-height: 78px;
    padding: 7px;
}

.qelk-mf-search-result--has-image::after {
    grid-column: 2;
}

.qelk-mf-search-result--has-image > span {
    grid-column: 2;
}

.qelk-mf-search-result strong,
.qelk-mf-search-result small {
    display: block;
    min-width: 0;
}

.qelk-mf-search-result strong {
    overflow: hidden;
    color: var(--mfp-text);
    font-size: 14px;
    font-weight: 850;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qelk-mf-search-result small {
    margin-top: 4px;
    overflow: hidden;
    color: var(--mfp-text-muted);
    font-size: 12px;
    font-weight: 720;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qelk-mf-search-section--products .qelk-mf-search-result {
    grid-template-columns: 56px minmax(0, 1fr);
    min-height: 76px;
    padding: 7px;
}

.qelk-mf-search-section--products .qelk-mf-search-result::after {
    grid-column: 2;
}

.qelk-mf-search-section--products .qelk-mf-search-result img {
    width: 56px;
    height: 70px;
    border-radius: 12px;
}

.qelk-mf-search-section--products .qelk-mf-search-result > span {
    grid-column: 2;
}

.qelk-mf-search-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.qelk-mf-search-chip-wrap {
    display: inline-grid;
    grid-template-columns: minmax(0, auto) 28px;
    align-items: center;
    min-height: 36px;
    overflow: hidden;
    border: 1px solid var(--mfp-border);
    border-radius: 999px;
    background: var(--mfp-bg-soft);
}

.qelk-mf-search-chip,
.qelk-mf-search-chip-remove {
    min-height: 34px;
    border: 0;
    background: transparent;
    color: var(--mfp-text);
    font: inherit;
    cursor: pointer;
}

.qelk-mf-search-chip {
    min-width: 0;
    max-width: 210px;
    padding: 0 10px 0 14px;
    overflow: hidden;
    font-size: 13px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qelk-mf-search-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    padding: 0;
    color: var(--mfp-text-muted);
    font-size: 18px;
}

.qelk-mf-search-chip:hover,
.qelk-mf-search-chip:focus,
.qelk-mf-search-chip-remove:hover,
.qelk-mf-search-chip-remove:focus {
    color: var(--mfp-accent-strong);
    outline: none;
}

.qelk-mf-search-state {
    margin: 0;
    padding: 14px 0;
    color: var(--mfp-text-muted);
    font-size: 14px;
    font-weight: 750;
    line-height: 1.4;
}

.mfp-search-toggle-mobile {
    display: none;
}

@media (min-width: 981px) {
    .qelk-mf-search-panel {
        max-height: min(680px, calc(100dvh - var(--qelk-mf-search-admin-offset) - 112px));
        margin-top: 76px;
    }

    .qelk-mf-search-body {
        padding: 18px;
    }

    .qelk-mf-search-content {
        grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
        align-items: start;
    }

    .qelk-mf-search-section--products {
        grid-column: 1 / -1;
    }
}

@media (max-width: 980px) {
    .mfp-search-toggle-mobile {
        display: inline-flex;
    }

    .qelk-mf-search-backdrop {
        display: none;
    }

    .qelk-mf-search-panel {
        width: 100%;
        max-height: none;
        height: 100%;
        margin: 0;
        border: 0;
        border-radius: 0;
        background: var(--mfp-bg);
        box-shadow: none;
    }

    .qelk-mf-search-bar {
        padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left));
        background: var(--mfp-card-strong);
    }

    .qelk-mf-search-body {
        padding: 14px max(14px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    }

    .qelk-mf-search-content {
        gap: 18px;
    }

    .qelk-mf-search-result {
        min-height: 60px;
        border-radius: 14px;
    }

    .qelk-mf-search-section--products .qelk-mf-search-result {
        min-height: 82px;
    }

    .qelk-mf-search-result strong {
        white-space: normal;
    }
}

@media screen and (max-width: 782px) {
    body.admin-bar .qelk-mf-search-shell {
        --qelk-mf-search-admin-offset: 46px;
    }
}
