/* место под панель инструментов снизу справа */
.msg{
  position: relative;
  padding-bottom: 46px; /* чтобы ряд иконок не перекрывал текст */
}

/* Единая панель инструментов (🤖, ✎, 🗑) в один ряд */
.msg-tools{
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity .15s ease;
  z-index: 2;
}
.msg:hover .msg-tools{ opacity: 1; }

/* на тач-экранах показываем всегда */
@media (hover:none){
  .msg-tools{ opacity: 1; }
}

/* кнопки/иконки внутри панели */
.msg-tools .tool-btn,
.msg-tools .robot-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: #6B7280;
  cursor: pointer;
  user-select: none;
}
.msg-tools .tool-btn:hover,
.msg-tools .robot-btn:hover{
  color:#111; border-color:var(--primary); background:#F3F4FF;
}

/* Снимаем старые позиционирования (если где-то остались) */
.msg .robot-btn{ position: static; opacity: 1; }
.msg .msg-actions{ position: static; opacity: 1; display: contents; } /* чтобы их кнопки встали в общий flex */

/* стили результата работы агента (как было) */
.agent-result{ margin-top:6px; padding:8px; border-radius:8px; white-space:pre-wrap; border:1px solid var(--border); }
.agent-result.pending{ background:#fff8e1; border-color:#ffe082; }
.agent-result.done{ background:#e8f5e9; border-color:#a5d6a7; }
.agent-result.error{ background:#ffebee; border-color:#ef9a9a; }

/* ===== AGENT PATCH @ '"$ts"' ===== */
.msg{
  /* немного места под панель иконок */
  padding-bottom: 42px !important;
  position: relative;
}

/* Единая панель действий внизу справа */
.msg-actions{
  position: absolute !important;
  right: 8px !important;
  bottom: 8px !important;
  display: flex !important;
  gap: 8px !important;
  opacity: 1 !important;               /* всегда видна */
  pointer-events: auto;
  z-index: 2;
}

.msg-actions button{
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
body.dark .msg-actions button{ background: var(--panel); }
.msg-actions button:hover{
  border-color: var(--primary);
  background: #F3F4FF;
}

/* Старую одиночную кнопку робота выравниваем и скрываем по умолчанию —
   теперь она дублируется в панели .msg-actions */
.msg .robot-btn{
  display: none !important;
  position: absolute; right: 10px; bottom: 8px;
  width: 32px; height: 32px;
  align-items: center; justify-content: center;
  font-size: 18px;
}
/* ===== /AGENT PATCH ===== */
/* === UI HOTFIX (toolbar bottom-right) === */
.msg{ position:relative; padding-bottom:44px !important; }
.msg-actions{
  position:absolute; right:8px; bottom:8px;
  display:flex; gap:8px; z-index:2; opacity:1; pointer-events:auto;
}
.msg-actions button{
  background:transparent; border:1px solid var(--border);
  border-radius:10px; width:32px; height:32px;
  display:flex; align-items:center; justify-content:center; cursor:pointer;
}
body.dark .msg-actions button{ background:var(--panel); }
.msg-actions button:hover{ border-color:var(--primary); background:#F3F4FF; }
/* робот-иконка отдельная (если встречается) — вернуть и выровнять */
.msg .robot-btn{
  display:inline-flex !important; align-items:center; justify-content:center;
  position:absolute; right:8px; bottom:8px; width:32px; height:32px;
  border:1px solid var(--border); border-radius:10px; font-size:18px;
}
/* === /UI HOTFIX === */

/* --- фикс отступа между аватаром и текстом --- */
.msg, .message, .chat-message {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.msg .avatar, .message .avatar, .chat-message .avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
}

/* смягчаем «прыжки» списка сессий при обновлениях */
.sessions, .session-item {
  transition: none !important;
}

/* --- перенос текста ниже аватара и имени --- */
.msg .from-avatar{
  display:inline-block;
  width:34px; height:34px; border-radius:50%;
  vertical-align:middle;
  margin-right:8px;               /* отступ между аватаром и именем */
}

.msg .from-name{
  display:inline-block;            /* имя в той же строке с аватаром */
  font-weight:700;
  line-height:1.2;
}

/* принудительно переносим текст сообщения на следующую строку */
.msg .from-name::after{
  content:"";
  display:block;                   /* разрыв строки после имени */
  height:0;
  margin-bottom:6px;               /* зазор между шапкой и текстом */
}