I'd like to create a view of nodes and links where rows are static and columns are dynamic:

How can i make the columns of the grid dynamic depends if there is a link or a node? Ultimately i'll have multiple links below other links but number of columns on each row is dynamic and changes between rows. Is this doable with flexbox instead?
.wrapper {
display: grid;
grid-auto-columns: min-content;
grid-template-rows:
[ETH1] 1fr
[SR] 1fr
[IGP] 1fr
[ETH2] 1fr
[OCH] 1fr
[OMS] 1fr
[OTS] 1fr
[LAST] 1fr;
}
.layer {
display: flex;
align-items: center;
position: relative;
//margin-bottom: 5px;
> .title {
border: 1px solid #ccc;
border-radius: 5px;
padding: 5px 10px;
min-width: 40px;
// position: relative;
&:after {
content: "";
position: absolute;
bottom: 50%;
left: 60px;
width: 500px;
height: 2px;
background: #ccc;
z-index: 0;
}
}
}
.node {
padding: 0.5em;
border: 2px solid #6381b0;
background: #a8bfe1;
border-radius: 5px;
display: flex;
align-items: center;
z-index: 1;
}
.port {
color: white;
background: aliceblue;
border-radius: 50%;
border: 2px solid dodgerblue;
height: 10px;
width: 10px;
z-index: 2;
align-self: center;
&.left {
margin-left: -8px;
}
&.right {
margin-right: -8px;
}
}
.link {
min-width: 100px;
display: flex;
height: 4px;
align-self: center;
z-index: 2;
&.up {
background-color: green;
}
&.down {
background-color: red;
}
}
<div class='wrapper'>
<div class="layer" style="grid-row: ETH1;">
<div class='title'>L1</div>
</div>
<div class="layer" style="grid-row: SR;">
<div class='title'>L2</div>
</div>
<div class="layer" style="grid-row: IGP;">
<div class='title'>L3</div>
</div>
<div class="layer" style="grid-row: ETH2;">
<div class='title'>L4</div>
</div>
<div class="layer" style="grid-row: OCH;">
<div class='title'>L5</div>
</div>
<div class="layer" style="grid-row: OMS;">
<div class='title'>L6</div>
</div>
<div class="layer" style="grid-row: OTS;">
<div class='title'>L7</div>
</div>
<div class="node" style="grid-row: ETH1 / OCH;">E1</div>
<div class="node" style="grid-row: SR / LAST;">C1</div>
<div class='port left' style="grid-row: SR;"></div>
<div class='link up' style="grid-row: SR;">
<a href='#' class='link-visual'></a>
</div>
<div class='port right' style="grid-row: SR;"></div>
<div class='port left' style="grid-row: ETH2;"></div>
<div class='link up' style="grid-row: ETH2;">
<a href='#' class='link-visual'></a>
</div>
<div class='port right' style="grid-row: ETH2;"></div>
<div class="node" style="grid-row: SR / OMS;">C2</div>
<div class="node" style="grid-row: ETH / OMS;">E2</div>
</div>