<div class="l5r5e chat-roll chiaroscuro-chat-roll">
    {{!-- Ring accent bar --}}
    <div class="chi-ring-bar {{ring.id}}"></div>

    {{!-- Header: portrait + ring badge --}}
    <div class="chi-chat-header">
        <img class="profile-img" src="{{profileImg}}" alt="{{actor.name}}" />
        <div class="chi-chat-badges">
            <span class="chi-ring-badge {{ring.id}}" title="{{ring.label}}">
                <i class="i_{{ring.id}}"></i>
                <span class="chi-ring-name">{{ring.label}}</span>
                <span class="chi-ring-val">{{ring.value}}</span>
            </span>
            {{#if useAspectPoint}}<span class="chi-aspect-badge {{aspectType}}">
                {{#ifCond aspectType '==' 'solar'}}☀{{else}}☽{{/ifCond}}
                <span class="chi-badge-label">{{localize (concat 'chiaroscuro.aspects.' aspectType)}}</span>
            </span>{{/if}}
            {{#if useAssistance}}<span class="chi-assistance-badge">
                ⚑ <span class="chi-badge-label">{{localize 'chiaroscuro.dice.assistance'}}</span>
            </span>{{/if}}
        </div>
    </div>

    {{!-- Context: skill (rank) → difficulty --}}
    <div class="chi-chat-context">
        {{#if skill.name}}
            <span class="chi-ctx-skill">{{skill.name}}</span>
            {{#if skill.rank}}<span class="chi-ctx-rank chi-rank-{{skill.rank}}">{{localize (concat 'chiaroscuro.skill_ranks.' skill.rank)}}</span>{{/if}}
            <span class="chi-ctx-arrow">→</span>
        {{/if}}
        <span class="chi-ctx-diff-name">{{localize (concat 'chiaroscuro.difficulties.' difficulty.id)}}</span>
    </div>

    {{!-- Formula: ring val [× multiplier] = nbDice d6 --}}
    <div class="chi-chat-formula">
        <span class="chi-fml-base {{ring.id}}">{{ring.value}}d6</span>
        {{#if useAspectPoint}}
            <span class="chi-fml-mult {{aspectType}}">
                {{#if useAssistance}}× 3{{else}}× 2{{/if}}
                <em>{{#ifCond aspectType '==' 'solar'}}☀{{else}}☽{{/ifCond}}{{#if useAssistance}} ⚑{{/if}}</em>
            </span>
        {{else}}{{#if useAssistance}}
            <span class="chi-fml-mult">× 2 <em>⚑</em></span>
        {{/if}}{{/if}}
        {{#if skill.bonus}}<span class="chi-fml-bonus">+{{skill.bonus}}</span>{{/if}}
        {{#if modifier}}<span class="chi-fml-mod {{#ifCond modifier '>' 0}}chi-fml-pos{{else}}chi-fml-neg{{/ifCond}}">{{#ifCond modifier '>' 0}}+{{/ifCond}}{{modifier}}</span>{{/if}}
        <span class="chi-fml-eq">= {{nbDice}}d6</span>
    </div>

    {{!-- Dice pool (raw, only shown if parangon adjusted) --}}
    {{#if wasAdjusted}}
    <div class="chi-dice-section-label">{{localize 'chiaroscuro.dice.raw_dice'}}</div>
    <div class="chi-chat-dice-pool chi-dice-raw">
        {{#each rawResults}}
        <span class="chi-die chi-die-sm {{#ifCond this '<' 3}}die-low{{else}}{{#ifCond this '>' 4}}die-high{{/ifCond}}{{/ifCond}}">{{this}}</span>
        {{/each}}
    </div>
    <div class="chi-dice-section-label">{{localize 'chiaroscuro.dice.adjusted_dice'}}</div>
    {{/if}}

    {{!-- Dice pool (adjusted / main) --}}
    <div class="chi-chat-dice-pool">
        {{#each adjustedResults}}
        <span class="chi-die {{#ifCond this '<' 3}}die-low{{else}}{{#ifCond this '>' 4}}die-high{{/ifCond}}{{/ifCond}}">
            {{this}}
            {{#if (lookup ../diceAdjustedFlags @index)}}<i class="fas fa-caret-up die-adj-icon" title="{{localize 'chiaroscuro.dice.adjusted'}}"></i>{{/if}}
        </span>
        {{/each}}
    </div>

    {{!-- Breakdown: sum [+bonus] [±mod] = total / diff --}}
    <div class="chi-chat-breakdown">
        <span class="chi-bd-part chi-bd-sum" title="{{localize 'chiaroscuro.dice.dice_result'}}">{{rawSum}}</span>
        {{#if skill.bonus}}
            <span class="chi-bd-part chi-bd-pos">+{{skill.bonus}}</span>
        {{/if}}
        {{#if modifier}}
            <span class="chi-bd-part {{#ifCond modifier '>' 0}}chi-bd-pos{{else}}chi-bd-neg{{/ifCond}}">{{#ifCond modifier '>' 0}}+{{/ifCond}}{{modifier}}</span>
        {{/if}}
        <span class="chi-bd-eq">=</span>
        <span class="chi-bd-total">{{total}}</span>
        <span class="chi-bd-vs">/</span>
        <span class="chi-bd-diff">{{difficulty.value}}</span>
    </div>

    {{!-- Result banner --}}
    <div class="chi-chat-result {{#if success}}chi-success{{else}}chi-failure{{/if}}">
        <div class="chi-result-icon">
            {{#if success}}<i class="fas fa-check-circle"></i>{{else}}<i class="fas fa-times-circle"></i>{{/if}}
        </div>
        <div class="chi-result-body">
            <span class="chi-result-text">{{#if success}}{{localize 'chiaroscuro.dice.success'}}{{else}}{{localize 'chiaroscuro.dice.failure'}}{{/if}}</span>
            {{#if success}}{{#if bonus}}
                <span class="chi-result-delta chi-result-bonus">+{{bonus}} {{localize 'chiaroscuro.dice.bonus_successes'}}</span>
            {{/if}}{{else}}{{#if missBy}}
                <span class="chi-result-delta chi-result-miss">−{{missBy}} {{localize 'chiaroscuro.dice.miss_by'}}</span>
            {{/if}}{{/if}}
        </div>
    </div>

    {{!-- Item link (arcane, weapon, etc.) --}}
    {{#if l5r5e.item.uuid}}
    <div class="l5r5e item-infos">
        <div class="profile"><img class="profile-img" src="{{l5r5e.item.img}}" alt="{{l5r5e.item.name}}" /></div>
        <div class="name">@UUID[{{l5r5e.item.uuid}}]</div>
    </div>
    {{/if}}
</div>
