/* Desktop keeps the compact text navigation. Icons are for the mobile panel. */
.menu-panel-head,
.menu-section-label,
.nav-link-icon {
  display: none;
}

.nav-link-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.menu-backdrop[hidden] {
  display: none;
}

@media (max-width: 1040px) {
  body.mobile-menu-open {
    overflow: hidden;
  }

  .menu-backdrop:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 19;
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: rgba(5, 15, 28, .48);
    backdrop-filter: blur(3px);
    cursor: default;
  }

  .header .menu-toggle {
    min-height: 42px;
    padding: 7px 13px;
    border: 1px solid rgba(255, 255, 255, .32);
    border-radius: 12px;
    background: rgba(255, 255, 255, .06);
    font-size: 14px;
    font-weight: 500;
  }

  .header .menu-toggle[aria-expanded="true"] {
    border-color: rgba(119, 220, 181, .8);
    background: rgba(96, 189, 151, .12);
  }

  .header .nav.open,
  .header.search-mode .nav.open {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 0;
    box-sizing: border-box;
    width: min(336px, calc(100vw - 50px));
    max-width: calc(100vw - 50px);
    max-height: calc(100dvh - 94px - env(safe-area-inset-bottom, 0px));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, .7);
    border-radius: 22px;
    background: #fcfaf6;
    color: #1b2c35;
    box-shadow: 0 20px 55px rgba(4, 17, 28, .23), 0 3px 12px rgba(4, 17, 28, .09);
  }

  .header .menu-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 1px 1px 14px 5px;
    color: #162a32;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -.015em;
    line-height: 1.35;
  }

  .header .menu-panel-head button {
    display: grid;
    place-items: center;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid #e8ebe7;
    border-radius: 10px;
    background: #f4f5f1;
    color: #415458;
    font-size: 22px;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
  }

  .header .menu-panel-head button:hover {
    background: #e8f2ec;
  }

  .header .nav.open .nav-primary,
  .header .nav.open .nav-secondary {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-column: auto;
    grid-row: auto;
    align-items: stretch;
    justify-content: stretch;
    align-self: stretch;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    padding: 0;
  }

  .header .nav.open .nav-primary {
    gap: 6px;
  }

  .header .nav.open .menu-section-label {
    grid-column: 1;
    display: block;
    margin: 0 0 3px 5px;
    color: #77847d;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .03em;
    line-height: 1.4;
  }

  .header .nav.open .nav-primary > [data-nav-key],
  .header .nav.open .nav-primary > [data-nav-key]:first-child {
    position: relative;
    grid-column: 1;
    grid-row: auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 11px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    min-height: 51px;
    margin: 0;
    padding: 7px 35px 7px 9px;
    border: 1px solid #e5eae4;
    border-color: color-mix(in srgb, var(--menu-bg, #17bd81) 20%, #eaece8);
    border-radius: 13px;
    background: #fff;
    background: color-mix(in srgb, var(--menu-bg, #17bd81) 9%, #fffefa);
    color: #1b2c35;
    font-size: 14px;
    font-weight: 550;
    line-height: 1.3;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
    box-shadow: none;
  }

  .header .nav.open .nav-primary > [data-nav-key]:hover,
  .header .nav.open .nav-primary > [data-nav-key][aria-current="page"] {
    background: color-mix(in srgb, var(--menu-bg, #17bd81) 16%, #fffefa);
    border-color: color-mix(in srgb, var(--menu-bg, #17bd81) 38%, #eaece8);
  }

  .header .nav.open .nav-primary > [data-nav-key]::after,
  .header .nav.open .nav-secondary > [data-nav-key]::after {
    content: "";
    position: absolute;
    right: 15px;
    width: 6px;
    height: 6px;
    border-top: 1.5px solid currentColor;
    border-right: 1.5px solid currentColor;
    transform: rotate(45deg);
    opacity: .43;
  }

  .header .nav.open .nav-link-icon {
    display: grid;
    place-items: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .header .nav.open .nav-link-icon svg {
    display: block;
    width: 18px;
    height: 18px;
  }

  .header .nav.open .nav-primary .nav-link-icon {
    background: var(--menu-bg, #17bd81);
    color: var(--menu-ink, #0b1023);
  }

  .header .nav.open .nav-link-copy {
    display: inline-flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    align-items: center;
    min-width: 0;
    gap: 3px 7px;
  }

  .header .nav.open .nav-primary > [data-nav-key][hidden],
  .header .nav.open .nav-secondary > [data-nav-key][hidden] {
    display: none;
  }

  .header .nav.open .nav-primary .nav-new-feature,
  .header .nav.open .nav-secondary .nav-new-feature {
    padding: 2px 6px;
    border-radius: 5px;
    background: #e0f3e9;
    color: #146d4a;
    font-size: 10px;
    font-weight: 500;
    line-height: 1.3;
  }

  .header .nav.open .nav-secondary {
    gap: 0;
    margin-top: 13px;
    padding-top: 12px;
    border-top: 1px solid #e9ece7;
  }

  .header .nav.open .nav-secondary > [data-nav-key] {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 11px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    min-height: 43px;
    padding: 5px 35px 5px 9px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #344448;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.35;
    text-align: left;
    white-space: normal;
    box-shadow: none;
  }

  .header .nav.open .nav-secondary .nav-link-icon {
    background: #f1f3ee;
    color: #477363;
  }

  .header .nav.open .nav-secondary > [data-nav-key]:hover,
  .header .nav.open .nav-secondary > [data-nav-key][aria-current="page"] {
    background: #edf5ed;
    color: #1d6849;
    box-shadow: none;
  }

  .header .nav.open :is(a, button):focus-visible,
  .header .menu-toggle:focus-visible {
    outline: 3px solid #54d7a5;
    outline-offset: 2px;
  }
}

@media (max-width: 360px) {
  .header .nav.open,
  .header.search-mode .nav.open {
    padding: 12px;
  }
}

@media (prefers-reduced-motion: no-preference) and (max-width: 1040px) {
  .header .nav.open {
    animation: menu-appear .18s ease-out;
  }

  @keyframes menu-appear {
    from { opacity: 0; transform: translateY(-5px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }
}
