<div class="awemmy-chat">

  {{!-- Header: portrait + actor name + attribute --}}
  <div class="chat-roll-header">
    {{#if actorImage}}
    <img class="chat-actor-img" src="{{actorImage}}" alt="{{actorName}}" />
    {{/if}}
    <div class="chat-roll-info">
      {{#if actorName}}<div class="chat-actor-name">{{actorName}}</div>{{/if}}
      <div class="chat-roll-label">{{flavor}}</div>
    </div>
  </div>

  {{!-- Field source (only when rolling from a Field item) --}}
  {{#if sourceItemName}}
  <div class="chat-source-item">
    {{#if sourceItemImg}}<img class="chat-source-img" src="{{sourceItemImg}}" alt="{{sourceItemName}}" />{{/if}}
    <span class="chat-source-name">{{sourceItemName}}</span>
  </div>
  {{/if}}

  {{#unless isPrivate}}

  {{!-- Dice breakdown --}}
  <div class="roll-breakdown">
    {{#each dice}}
    {{#each results}}
    <span class="die-result {{#if (eq result ../faces)}}max{{else if (eq result 1)}}min{{/if}}">
      <i class="fa-solid fa-dice-d{{../faces}}"></i> {{result}}
    </span>
    {{/each}}
    {{/each}}
    {{#if modifier}}
    <span class="roll-mod">
      {{#if (gt modifier 0)}}+ {{modifier}}{{else if (lt modifier 0)}}− {{abs modifier}}{{/if}}
    </span>
    {{/if}}
    {{#if bonus}}
    <span class="roll-mod situational">
      {{#if (gt bonus 0)}}+ {{bonus}}{{else if (lt bonus 0)}}− {{abs bonus}}{{/if}}
    </span>
    {{/if}}
    {{#if knowledgeBonus}}
    <span class="roll-mod knowledge">
      {{#if (gt knowledgeBonus 0)}}+ {{knowledgeBonus}}{{else if (lt knowledgeBonus 0)}}− {{abs knowledgeBonus}}{{/if}}
    </span>
    {{/if}}
    <span class="roll-equals">=</span>
    <span class="roll-total">{{total}}</span>
    {{#if dc}}<span class="roll-dc">/ DC {{dc}}</span>{{/if}}
  </div>

  {{!-- Outcome badge --}}
  {{#if outcome}}
  <div class="outcome-badge {{outcome}}">
    {{#if (eq outcome "criticalSuccess")}}
      <i class="fa-solid fa-star"></i> {{localize "AWEMMY.Roll.CriticalSuccess"}}
    {{else if (eq outcome "success")}}
      <i class="fa-solid fa-circle-check"></i> {{localize "AWEMMY.Roll.Success"}}
    {{else if (eq outcome "failure")}}
      <i class="fa-solid fa-circle-xmark"></i> {{localize "AWEMMY.Roll.Failure"}}
    {{else if (eq outcome "criticalFailure")}}
      <i class="fa-solid fa-skull"></i> {{localize "AWEMMY.Roll.CriticalFailure"}}
    {{/if}}
  </div>
  {{/if}}

  {{else}}
  <div class="private-result">
    <i class="fa-solid fa-eye-slash"></i> {{localize "AWEMMY.Roll.Private"}}
  </div>
  {{/unless}}

</div>
