.message-actions { display:flex; align-items:center; gap:var(--space-1); position:relative; }
.message-actions > button {
    display:grid; place-items:center; width:var(--compact-action-height); height:var(--compact-action-height);
    border:0; border-radius:var(--ui-radius); padding:0; background:transparent; color:var(--text-secondary);
    cursor:pointer; transition:color var(--motion),background-color var(--motion);
}
.message-actions svg { width:var(--font-label); height:var(--font-label); }
.message-actions > button:is(:hover,:focus-visible,[aria-pressed="true"]) { background:var(--bg-card); color:var(--primary); }
.message-actions > button.is-copied { color:var(--success); }
@media(prefers-reduced-motion:reduce) { .message-actions > button { transition:none; } }

#chat-section .message.assistant:has(> .message-actions) { flex-direction:column; align-items:flex-start; gap:var(--space-3); }
/* Только проба вложений; положение и геометрия composer остаются рабочими. */
#chat-section .attachment-card {
    display:flex; align-items:center; gap:var(--space-2); box-sizing:border-box;
    min-height:var(--control-height); padding:var(--space-2); min-width:0;
    border:0; border-radius:var(--ui-radius); background:var(--bg-sidebar);
    color:var(--text); animation:attachment-card-in var(--motion) ease-out;
}
#chat-section .attached-files-container > .attachment-card { flex:0 1 var(--chat-file-width); max-width:100%; }
#chat-section .attachment-card .file-card-name { font-size:var(--font-label); font-weight:500; line-height:1.3; }
#chat-section .attachment-card .file-card-size { font-size:var(--font-caption); line-height:1.3; }
/* Вложение из истории открывается по нажатию — тот же отклик, что у кнопки «убрать». */
#chat-section .attachment-card.is-openable { cursor:pointer; transition:background-color var(--motion); }
#chat-section .attachment-card.is-openable:is(:hover,:focus-visible) { background:var(--bg-card); }
.attachment-card-remove {
    display:grid; place-items:center; width:var(--compact-action-height); height:var(--compact-action-height);
    flex-shrink:0; padding:0; border:0; border-radius:var(--ui-radius); background:transparent;
    color:var(--text-secondary); cursor:pointer; transition:background-color var(--motion),color var(--motion);
}
.attachment-card-remove svg { width:var(--space-4); height:var(--space-4); }
.attachment-card-remove:is(:hover,:focus-visible) { background:var(--bg-card); color:var(--primary); }
.sent-attachments { display:grid; gap:var(--space-2); margin-top:var(--space-3); width:var(--chat-file-width); max-width:100%; }
@keyframes attachment-card-in { from{opacity:0;transform:translateY(var(--space-1))} to{opacity:1;transform:translateY(0)} }
@media(prefers-reduced-motion:reduce) { #chat-section .attachment-card { animation:none; } .attachment-card-remove { transition:none; } }

/* Полученный файл: согласованная карточка и голубое появление после ответа. */
.assistant-file .file-card {
    padding:var(--space-3); gap:var(--space-2);
    background:var(--bg-sidebar); border:0; border-radius:var(--ui-radius);
}
.assistant-file .file-card-name { font-size:var(--font-label); font-weight:500; }
.assistant-file .file-card-size { font-size:var(--font-caption); color:var(--text-secondary); }
.assistant-file :is(.file-card-download-btn,.file-card-save-btn) {
    width:var(--co-button-height); height:var(--co-button-height);
    border-radius:var(--ui-radius); background:transparent; color:var(--text-secondary);
    transition:background-color var(--motion),color var(--motion);
}
.assistant-file :is(.file-card-download-btn,.file-card-save-btn)::before {
    width:var(--icon-size); height:var(--icon-size);
}
.assistant-file :is(.file-card-download-btn,.file-card-save-btn):not(:disabled):is(:hover,:focus-visible,:active) {
    background:var(--bg-card); color:var(--primary);
}
.assistant-file .file-card-save-btn.is-saved { background:transparent; color:var(--success); }
.assistant-file .file-card-save-btn.is-saved::before {
    width:var(--icon-size); height:var(--icon-size); border:0; transform:none;
    background:currentColor;
    mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 12l5 5L20 6' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;
}
@media(prefers-reduced-motion:reduce) {
    .assistant-file :is(.file-card-download-btn,.file-card-save-btn) { transition:none; }
}

/* Сначала ответ заканчивает печать, затем приходит файл тем же голубым следом. */
.file-arriving .file-card {
    animation:chat-file-reveal var(--motion) ease-out both,chat-file-surface var(--chat-file-color-duration) ease-out both;
}
.file-arriving .file-card-name { animation:chat-file-ink var(--chat-file-color-duration) ease-out both; }
.file-arriving .file-card-size { animation:chat-file-muted var(--chat-file-color-duration) ease-out both; }
@keyframes chat-file-reveal { from{opacity:0;transform:translateY(var(--space-1))} to{opacity:1;transform:translateY(0)} }
@keyframes chat-file-surface { from{background:color-mix(in srgb,var(--primary) 18%,var(--bg-sidebar))} to{background:var(--bg-sidebar)} }
@keyframes chat-file-ink { from{color:var(--primary)} to{color:var(--text)} }
@keyframes chat-file-muted { from{color:var(--primary)} to{color:var(--text-secondary)} }
@media(prefers-reduced-motion:reduce) {
    .file-arriving :is(.file-card,.file-card-name,.file-card-size) { animation:none; }
}

/* Файл относится к тому же ответу: общий поток без межсообщенческого зазора. */
#chat-section .message.assistant:has(> .assistant-file) {
    flex-direction:column; align-items:flex-start; gap:var(--space-3);
}
#chat-section .message.assistant > .assistant-file { margin:0; width:100%; }
#chat-section .message.assistant:has(> .assistant-file) > .msg-report { flex-basis:auto; margin-top:0; }

/* Предложение документа приходит тем же голубым следом, что и файл ассистента. */
#chat-section .document-arriving > .action-card {
    animation:chat-file-reveal var(--motion) ease-out both,chat-file-surface var(--chat-file-color-duration) ease-out both;
}
#chat-section .document-arriving > .action-card dd {
    animation:chat-file-ink var(--chat-file-color-duration) ease-out both;
}
#chat-section .document-arriving > .action-card :is(dt,.document-action-summary,.review-document-note) {
    animation:chat-file-muted var(--chat-file-color-duration) ease-out both;
}
@media(prefers-reduced-motion:reduce) {
    #chat-section .document-arriving > .action-card,
    #chat-section .document-arriving > .action-card :is(dt,dd,.document-action-summary,.review-document-note) { animation:none; }
}
