  /* ─── Reset ─── */
  .menucss ::before, .menucss ::after { box-sizing: border-box; margin: 0; padding: 0; }
 
  /* ─── Variabili ─── */
  .menucss {
    --bg: white;
    --bg-sub: white;
    --text: #e0e0f0;
    --accent: white; /*#7c6af7;*/
    --border: rgba(255,255,255,0.08);
    --hover: black; /*rgba(124,106,247,0.18);*/
    --radius: 6px;
    --item-h: 44px;
    --sub-w: 220px;
  }
 
 
  /* ─── Struttura base ─── */
nav ul {
    list-style: none;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
  }
 
  /* menu orizzontale primo livello */
  nav > ul {
    display: flex;
    flex-wrap: wrap;
  }
 
  nav li {
    position: relative;
  }
 
  nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 16px;
    height: var(--item-h);
    /* color: var(--text); */
    text-decoration: none;
    white-space: nowrap;
    border-radius: var(--radius);
    transition: background 0.15s;
  }
 
  nav a:hover,
  nav a:focus {
    background: var(--hover);
    color: var(--bg);
    outline: none;
  }
 
  /* ─── Freccia indicatore sottomenu ─── */
  nav li:has(> ul) > a::after {
    content: "›";
    font-size: 20px;
    line-height: 50px;
    color: var(--accent);
    transform: rotate(90deg);
    display: inline-block;
  }
 
  /* dal 2° livello: freccia orizzontale */
  nav ul ul li:has(> ul) > a::after {
    transform: rotate(0deg);
  }
 
  /* ─── Sottomenu — nascosto di default ─── */
  nav ul ul {
    display: none;
    position: absolute;
    top: 0;
    left: 100%;
    min-width: var(--sub-w);
    background: var(--bg-sub);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    z-index: 100;
    flex-direction: column;
  }
 
  /* primo livello: il dropdown scende */
  nav > ul > li > ul {
    top: 100%;
    left: 0;
  }
 
  /* ─── Apertura: hover (desktop) + focus-within (mobile tap) ─── */
  nav li:hover > ul,
  nav li:focus-within > ul {
    display: flex;
  }
 

@media (min-width: 641px) {
/* inizio alineamento a dx */
nav.right > ul {
    justify-content: flex-end;
  }

  nav.right > ul > li > ul {
    left: 0;
    right: auto;
  }

  nav.right ul ul ul {
    top: 0;
    left: 100%;
    right: auto;
  }
  /* Fine alineamento a dx */

  /*Nasconde dal 3 livelloi in giu */
    nav.right ul ul ul {
        display: none !important;
    }  
    /* ... e le freccine che indicano il 3 livello */
    nav.right ul ul li:has(> ul) > a::after {
    display: none;
    }    
}





  /* ─── Mobile: tutto verticale sotto 640px ─── */
  @media (max-width: 640px) {

    nav {
        overflow-y: auto;
        max-height: 100vh;
    }
        
    nav > ul {
      flex-direction: column;
    }
 
    nav ul ul {
      display: flex;
      position: static;
      left: auto;
      top: auto;
      border: none;
      border-left: 2px solid var(--accent);
      border-radius: 0;
      background: transparent;
      margin-left: 16px;
      min-width: unset;
      width: auto;
    }
 
    nav li:has(> ul) > a::after {
      display: none;
    }
  }