.kl-modules-mega {
    position: relative;
    font-family: var(--font-body, "DM Sans", sans-serif);
}

.kl-modules-mega__trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0;
    color: var(--color-muted-foreground);
    background: transparent;
    cursor: pointer;
    transition: color 160ms ease;
}

.kl-modules-mega__trigger:hover,
.kl-modules-mega__trigger:focus-visible,
.kl-modules-mega.is-open .kl-modules-mega__trigger {
    color: var(--color-primary);
}

.kl-modules-mega__trigger:focus-visible,
.kl-modules-mega__cat:focus-visible,
.kl-modules-mega__module:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 3px;
}

.kl-modules-mega__chevron {
    width: 0.875rem;
    height: 0.875rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 180ms ease;
}

.kl-modules-mega.is-open .kl-modules-mega__chevron {
    transform: rotate(180deg);
}

.kl-modules-mega__panel {
    position: absolute;
    top: calc(100% + 1rem);
    left: 50%;
    z-index: 60;
    display: grid;
    grid-template-columns: 12rem minmax(0, 1fr);
    width: min(47rem, calc(100vw - 2rem));
    min-height: 17rem;
    overflow: hidden;
    color: var(--color-foreground);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.875rem;
    box-shadow: 0 18px 45px rgba(15, 15, 15, 0.13);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate(-50%, -0.5rem);
    transition:
        opacity 160ms ease,
        visibility 160ms ease,
        transform 180ms ease;
}

.kl-modules-mega__panel::before {
    position: absolute;
    top: -1rem;
    right: 0;
    left: 0;
    height: 1rem;
    content: "";
}

.kl-modules-mega.is-open .kl-modules-mega__panel {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(-50%, 0);
}

.kl-modules-mega__cats {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    padding: 1rem;
    background: color-mix(in srgb, var(--color-accent-soft) 48%, var(--color-surface));
    border-right: 1px solid var(--color-border);
}

.kl-modules-mega__cat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem;
    color: var(--color-muted-foreground);
    font: 600 0.8125rem/1.35 var(--font-body, "DM Sans", sans-serif);
    text-align: left;
    background: transparent;
    border-radius: 0.5rem;
    cursor: pointer;
    transition:
        color 160ms ease,
        background-color 160ms ease;
}

.kl-modules-mega__cat:hover,
.kl-modules-mega__cat.is-active,
.kl-modules-mega__cat[aria-selected="true"] {
    color: var(--color-primary);
    background: var(--color-surface);
}

.kl-modules-mega__cat svg {
    width: 0.875rem;
    height: 0.875rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.kl-modules-mega__mods {
    min-width: 0;
    padding: 1rem;
}

.kl-modules-mega__module-panel {
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.kl-modules-mega__module-panel.is-active {
    display: grid;
}

.kl-modules-mega__module {
    display: flex;
    gap: 0.875rem;
    min-width: 0;
    padding: 1rem;
    border-radius: 0.75rem;
    transition:
        color 160ms ease,
        background-color 160ms ease;
}

.kl-modules-mega__module:hover {
    color: var(--color-primary);
    background: var(--color-accent-soft);
}

.kl-modules-mega__module-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 2.5rem;
    width: 2.5rem;
    height: 2.5rem;
    color: var(--color-primary);
    font-size: 1.125rem;
    background: var(--color-accent-soft);
    border-radius: 0.625rem;
}

.kl-modules-mega__module-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.kl-modules-mega__module-copy strong {
    color: var(--color-foreground);
    font-size: 0.9375rem;
    font-weight: 650;
    line-height: 1.35;
}

.kl-modules-mega__module-copy > span:not(.kl-modules-mega__module-link) {
    margin-top: 0.3rem;
    color: var(--color-muted-foreground);
    font-size: 0.8125rem;
    line-height: 1.5;
}

.kl-modules-mega__module-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.75rem;
    color: var(--color-primary);
    font-size: 0.75rem;
    font-weight: 650;
}

.kl-modules-mega__module-link svg {
    width: 0.75rem;
    height: 0.75rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (max-width: 1024px) {
    .kl-nav-menu .kl-modules-mega {
        width: 100%;
        border-bottom: 1px solid var(--color-border);
    }

    .kl-nav-menu .kl-modules-mega__trigger {
        justify-content: space-between;
        width: 100%;
        padding: 0.75rem 0.5rem;
    }

    .kl-nav-menu .kl-modules-mega__panel {
        position: static;
        display: none;
        grid-template-columns: 1fr;
        width: 100%;
        min-height: 0;
        margin: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: none;
        transition: none;
    }

    .kl-nav-menu .kl-modules-mega.is-open .kl-modules-mega__panel {
        display: grid;
        transform: none;
    }

    .kl-nav-menu .kl-modules-mega__cats {
        gap: 0.25rem;
        padding: 0.5rem;
        border-right: 0;
        border-bottom: 1px solid var(--color-border);
    }

    .kl-nav-menu .kl-modules-mega__cat {
        padding: 0.625rem 0.75rem;
    }

    .kl-nav-menu .kl-modules-mega__mods {
        padding: 0.5rem;
    }

    .kl-nav-menu .kl-modules-mega__module-panel.is-active {
        grid-template-columns: 1fr;
    }

    .kl-nav-menu .kl-modules-mega__module {
        padding: 0.75rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .kl-modules-mega__trigger,
    .kl-modules-mega__chevron,
    .kl-modules-mega__panel,
    .kl-modules-mega__cat,
    .kl-modules-mega__module {
        transition: none;
    }
}
