body > header .global-search {
    position: absolute;
    top: 50%;
    right: 135px;
    transform: translateY(-50%);
    width: min(220px, 28vw);
    max-width: 22rem;
    min-width: 10rem;
    direction: rtl;
    z-index: 2;
}

body > header .global-search__toggle,
body > header .global-search__close,
body > header .global-search__backdrop {
    display: none;
}

body > header .global-search__drawer {
    display: block;
    position: static;
}

body > header .global-search__label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body > header .global-search__field {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background-color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

body > header .global-search__field:focus-within {
    border-color: var(--primary, #8a0707);
    box-shadow: 0 2px 12px rgba(138, 7, 7, 0.2);
}

body > header .global-search__icon {
    color: var(--primary, #8a0707);
    font-size: 1rem;
    flex-shrink: 0;
}

body > header .global-search__input {
    flex: 1;
    min-width: 0;
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text, #2b2b2b);
    font-family: "Zain", sans-serif;
    font-size: 16px;
    direction: rtl;
    padding: 4px 2px;
    -webkit-appearance: none;
    appearance: none;
}

body > header .global-search__input::placeholder {
    color: rgba(0, 0, 0, 0.45);
}

body > header .global-search__results {
    position: absolute;
    top: calc(100% + 0.4rem);
    inset-inline: 0;
    margin: 0;
    padding: 0.35rem;
    list-style: none;
    max-height: min(60vh, 20rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
    border: 1px solid #ddd;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 1001;
}

body > header .global-search__results[hidden] {
    display: none !important;
}

body > header .global-search__result {
    display: block;
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text, #2b2b2b);
    transition: background 0.15s ease;
}

body > header .global-search__result:hover,
body > header .global-search__result.is-active {
    background: rgba(138, 7, 7, 0.08);
}

body > header .global-search__result-title {
    display: block;
    font-weight: 700;
    font-size: 0.95rem;
}

body > header .global-search__result-meta {
    display: block;
    font-size: 0.78rem;
    color: rgba(0, 0, 0, 0.5);
    margin-top: 0.1rem;
}

body > header .global-search__empty {
    padding: 0.75rem;
    text-align: center;
    color: rgba(0, 0, 0, 0.55);
    font-size: 0.9rem;
}

body.darkmode > header .global-search__field {
    background-color: #e0e0e0;
    border-color: #bbb;
}

body.darkmode > header .global-search__input {
    color: #000;
}

body.darkmode > header .global-search__input::placeholder {
    color: rgba(0, 0, 0, 0.5);
}

body.darkmode > header .global-search__icon {
    color: var(--primary, #ff4040);
}

body.darkmode > header .global-search__results {
    background: #e8e8e8;
    border-color: #bbb;
}

body.darkmode > header .global-search__result {
    color: #1a1a1a;
}

body.darkmode > header .global-search__result-meta {
    color: rgba(0, 0, 0, 0.55);
}

@media (max-width: 900px) {
    body > header .global-search {
        grid-area: search;
        position: static;
        transform: none;
        width: auto;
        max-width: none;
        min-width: 0;
        margin: 0;
        justify-self: center;
        z-index: 6;
    }

    body > header .global-search__toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 2.5rem;
        height: 2.5rem;
        padding: 0;
        border: none;
        border-radius: 50%;
        background: transparent;
        color: var(--text, #2b2b2b);
        font-size: 1.35rem;
        cursor: pointer;
        transition:
            color 0.2s ease,
            background 0.2s ease,
            transform 0.15s ease;
    }

    body > header .global-search__toggle:hover,
    body > header .global-search__toggle:focus-visible {
        color: var(--primary, #8a0707);
        background: rgba(138, 7, 7, 0.1);
        outline: none;
        transform: scale(1.05);
    }

    body > header .global-search.is-expanded .global-search__toggle {
        color: var(--primary, #8a0707);
        background: rgba(138, 7, 7, 0.12);
    }

    body > header .global-search__drawer {
        display: none;
        position: fixed;
        left: 0;
        right: 0;
        top: var(--global-search-top, 4.25rem);
        padding: 0.55rem max(0.65rem, env(safe-area-inset-right, 0px))
            0.75rem max(0.65rem, env(safe-area-inset-left, 0px));
        background: #c7c7c7;
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
        z-index: 1100;
        direction: rtl;
    }

    body > header .global-search.is-expanded .global-search__drawer {
        display: block;
    }

    body > header .global-search__backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: 1095;
        border: none;
        padding: 0;
        margin: 0;
        cursor: pointer;
    }

    body > header .global-search.is-expanded .global-search__backdrop {
        display: block;
    }

    body > header .global-search__field {
        width: 100%;
        padding: 0.55rem 0.5rem 0.55rem 0.65rem;
        box-sizing: border-box;
    }

    body > header .global-search__close {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        width: 2rem;
        height: 2rem;
        padding: 0;
        border: none;
        border-radius: 50%;
        background: rgba(0, 0, 0, 0.06);
        color: var(--text, #2b2b2b);
        font-size: 1rem;
        cursor: pointer;
    }

    body > header .global-search__close:hover {
        background: rgba(138, 7, 7, 0.12);
        color: var(--primary, #8a0707);
    }

    body > header .global-search__input {
        font-size: 1rem;
    }

    body > header .global-search__results {
        position: static;
        margin-top: 0.5rem;
        max-height: min(45vh, 14rem);
        width: 100%;
        box-sizing: border-box;
    }

    body.darkmode > header .global-search__drawer {
        background: #444;
    }

    body.darkmode > header .global-search__toggle {
        color: #f1f1f1;
    }

    body.darkmode > header .global-search__close {
        background: rgba(255, 255, 255, 0.1);
        color: #f1f1f1;
    }
}

body.global-search-open {
    overflow: hidden;
}

body.global-search-open > header {
    z-index: 1200;
}

@media (max-width: 480px) {
    body > header .global-search__input::placeholder {
        font-size: 0.88rem;
    }
}