{# Single reply card — expects: reply (ReplySummary), reply_num (int) #}
{% set error_class = ' reply-error' if reply.is_error else '' %}
<div class="card{{ error_class }}">
    <h2>Reply #{{ reply_num }} <span class="reply-meta">{{ reply.timestamp }}</span></h2>
    <div class="reply-stats">
        <div class="reply-stat">
            <span class="reply-stat-label">Cost</span>
            <span class="reply-stat-value">${{ '%.4f'|format(reply.total_cost_usd) }}</span>
        </div>
        <div class="reply-stat">
            <span class="reply-stat-label">Duration</span>
            <span class="reply-stat-value">{{ format_duration(reply.duration_ms / 1000) }}</span>
        </div>
        <div class="reply-stat">
            <span class="reply-stat-label">Turns</span>
            <span class="reply-stat-value">{{ reply.num_turns }}</span>
        </div>
        <div class="reply-stat">
            <span class="reply-stat-label">Session</span>
            <span class="reply-stat-value">{{ reply.session_id }}</span>
        </div>
    </div>
    {% set usage = reply.usage %}
    {% set usage_items = [] %}
    {% if usage.input_tokens %}{% set _ = usage_items.append(('Input', '{:,}'.format(usage.input_tokens))) %}{% endif %}
    {% if usage.output_tokens %}{% set _ = usage_items.append(('Output', '{:,}'.format(usage.output_tokens))) %}{% endif %}
    {% if usage.cache_read_input_tokens %}{% set _ = usage_items.append(('Cache Read', '{:,}'.format(usage.cache_read_input_tokens))) %}{% endif %}
    {% if usage.cache_creation_input_tokens %}{% set _ = usage_items.append(('Cache Write', '{:,}'.format(usage.cache_creation_input_tokens))) %}{% endif %}
    {% if usage_items %}
    <div class="usage-grid">
        {% for label, value in usage_items %}
        <div class="usage-item">
            <div class="usage-label">{{ label }}</div>
            <div class="usage-value">{{ value }}</div>
        </div>
        {% endfor %}
    </div>
    {% endif %}
    {% if reply.request_text %}
    <hr class="reply-divider">
    <div class="text-label">Request</div>
    <div class="text-content request">{{ reply.request_text }}</div>
    {% endif %}
    {% if reply.response_text %}
    <hr class="reply-divider">
    <div class="text-label">Response</div>
    <div class="text-content response">{{ reply.response_text }}</div>
    {% endif %}
</div>
