.ds-mega-wrapper {
    --ds-accent: #43685a;
    --ds-accent-dark: #345247;
    --ds-bg: #f9f5f0;
    --ds-card: #ffffff;
    --ds-text: #1f2a26;
    --ds-muted: #5f6b66;
    --ds-line: #e6dfd5;
}

/* Overlay */
.ds-mega-menu {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--ds-bg);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;

    visibility: hidden;
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity .25s ease, transform .25s ease, visibility 0s linear .25s;
}

.ds-mega-menu.active {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition: opacity .25s ease, transform .25s ease, visibility 0s;
}

/* Sticky header: logo, search, close */
.ds-mega-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 14px 40px;
    background: var(--ds-bg);
    border-bottom: 1px solid var(--ds-line);
}

.ds-mega-search {
    flex: 1;
    max-width: 520px;
    margin: 0 auto;
}

.ds-mega-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 18px;
    font: inherit;
    font-size: 1rem; /* 16px+ prevents iOS zoom on focus */
    color: var(--ds-text);
    background: #fff;
    border: 1px solid var(--ds-line);
    border-radius: 999px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

.ds-mega-search-input:focus {
    border-color: var(--ds-accent);
    box-shadow: 0 0 0 3px rgba(67, 104, 90, .18);
}

.ds-mega-close {
    flex: none;
    width: 44px;
    height: 44px;
    margin-left: auto;
    padding: 0;
    font-size: 1.3rem;
    line-height: 1;
    color: #fff;
    background: var(--ds-accent);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background .2s, transform .2s;
}

.ds-mega-close:hover,
.ds-mega-close:focus-visible {
    background: var(--ds-accent-dark);
    transform: rotate(90deg);
}

/* Content + grid */
.ds-mega-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 40px 60px;
}

.ds-mega-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    gap: 24px;
    align-items: start;
}

/* Cards */
.ds-mega-column {
    background: var(--ds-card);
    border-radius: 16px;
    padding: 20px 22px 22px;
    box-shadow: 0 2px 8px rgba(31, 42, 38, .06);
    transition: box-shadow .2s ease, transform .2s ease;
    animation: ds-mega-card-in .35s ease both;
}

.ds-mega-column:hover {
    box-shadow: 0 10px 28px rgba(31, 42, 38, .12);
    transform: translateY(-2px);
}

@keyframes ds-mega-card-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

.ds-mega-card-head {
    display: flex;
    align-items: center;
    gap: 14px;
}

.ds-mega-thumb {
    flex: none;
    display: block;
    width: 52px;
    height: 52px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--ds-bg);
}

.ds-mega-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ds-mega-column h3 {
    flex: 1;
    margin: 0;
    line-height: 1.25;
}

.ds-mega-column h3 a {
    font-size: 1.15rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--ds-text);
}

.ds-mega-column h3 a:hover {
    color: var(--ds-accent);
}

/* Accent bar under card head */
.ds-mega-card-head::after {
    content: "";
    order: 99;
    flex-basis: 100%;
    height: 3px;
    width: 34px;
    margin-top: 2px;
    background: var(--ds-accent);
    border-radius: 2px;
}

.ds-mega-card-head {
    flex-wrap: wrap;
}

.ds-mega-card-head h3 {
    min-width: 0;
}

/* Toggle (mobile only) */
.ds-mega-toggle {
    display: none;
    flex: none;
    position: relative;
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--ds-bg);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.ds-mega-toggle::before,
.ds-mega-toggle::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 2px;
    margin: -1px 0 0 -7px;
    background: var(--ds-accent);
    border-radius: 1px;
    transition: transform .25s ease;
}

.ds-mega-toggle::after {
    transform: rotate(90deg);
}

.ds-mega-toggle[aria-expanded="true"]::after {
    transform: rotate(0deg);
}

/* Sub menus */
.ds-mega-column ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ds-mega-column li {
    margin: 0;
}

.ds-mega-column a {
    text-decoration: none;
    color: var(--ds-muted);
}

.ds-sub-menu {
    margin-top: 12px !important;
}

.ds-sub-menu > li > a {
    display: inline-block;
    padding: 5px 0;
    transition: color .15s ease, transform .15s ease;
}

.ds-sub-menu > li:hover > a {
    transform: translateX(4px);
}

.ds-sub-menu a:hover {
    color: var(--ds-accent);
}

/* Level 2+ */
.ds-sub-menu .ds-sub-menu {
    margin-top: 2px !important;
    padding-left: 14px;
    border-left: 2px solid var(--ds-line);
}

.ds-sub-menu .ds-sub-menu a {
    font-size: .95rem;
    padding: 4px 0;
    display: inline-block;
}

.ds-sub-menu .ds-sub-menu .ds-sub-menu a {
    font-size: .9rem;
}

/* Empty search result */
.ds-mega-empty {
    text-align: center;
    color: var(--ds-muted);
    padding: 40px 0;
}

.ds-mega-column[hidden],
.ds-mega-empty[hidden] {
    display: none;
}

/* Open button */
.ds-mega-open {
    background: none;
    border: none;
    padding: 10px 0;
    font: inherit;
    font-weight: 600;
    color: black;
    cursor: pointer;
    text-decoration: none;
}

.ds-mega-open:hover {
    font-weight: bold;
}

/* Prevent background scroll */
body.ds-mega-opened {
    overflow: hidden;
}

/* Mobile: accordion */
@media (max-width: 768px) {
    .ds-mega-header {
        flex-wrap: wrap;
        gap: 10px 12px;
        padding: 10px 16px;
    }

    .ds-mega-search {
        order: 3;
        flex: 1 1 100%;
        max-width: none;
        margin: 0;
    }

    .ds-mega-content {
        padding: 16px 16px 40px;
    }

    .ds-mega-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .ds-mega-column {
        padding: 6px 16px;
        border-radius: 14px;
        animation: none;
    }

    .ds-mega-column:hover {
        transform: none;
        box-shadow: 0 2px 8px rgba(31, 42, 38, .06);
    }

    .ds-mega-card-head {
        flex-wrap: nowrap;
        min-height: 56px;
    }

    .ds-mega-card-head::after {
        display: none;
    }

    .ds-mega-column h3 a {
        display: block;
        padding: 12px 0;
        font-size: 1.05rem;
    }

    .ds-mega-column.has-children .ds-mega-toggle {
        display: block;
    }

    .ds-mega-column.has-children > .ds-sub-menu {
        display: none;
        margin: 0 0 12px !important;
    }

    .ds-mega-column.has-children.is-open > .ds-sub-menu {
        display: block;
    }

    .ds-sub-menu > li > a {
        padding: 9px 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ds-mega-menu,
    .ds-mega-column,
    .ds-sub-menu > li > a {
        transition: none;
        animation: none;
    }
}
