Editable styles for nested for loop

How can I style nested for loop which must editable. I have added this code but it is not taking the parent repeater class. Is this the right way?

Code -

<div class=“whole”>

<div class=“card”>
<h1>{{ module.card.title }} </h1>
{% for item in module.card.heading_column %}
<div class=“heading-wrap heading-wrap-{{ loop.index }}”>
<h3>
{{ item.heading }}
</h3>
{% for item2 in item.sub_heading_repeater %}
<div class=“sub-heading sub-heading-{{ loop.index }}”>
<h5>
{{ item2.sub_heading }}
</h5>

</div>
{% endfor %}
</div>
{% endfor %}
</div>
</div>

{% require_css %}
<style>
{% scope_css %}
{% for item in module.card.heading_column %}
.heading-wrap-{{ loop.index }}
{% for item2 in item.sub_heading_repeater %}
.sub-heading-{{ loop.index }} h5{
color: {{ item2.sub_heading_color.color }};
}
{% endfor %}
}
{% endfor %}

{% end_scope_css %}
</style>
{% end_require_css %}