document.querySelectorAll('.stream-table tr.training-row').forEach(row => {
  const td = row.querySelector('td');
  const title = td?.querySelector('.stream-title');
  const link = td?.querySelector('a');

  if (td && title && link && !td.querySelector('.gc-go-btn')) {
    // Создаем универсальный wrapper
    const wrapper = document.createElement('div');

    // Определяем, мобильное устройство или нет
    const isMobile = window.innerWidth <= 768;

    // Стили wrapper в зависимости от устройства
    wrapper.style.display = 'flex';
    wrapper.style.flexDirection = isMobile ? 'column' : 'row';
    wrapper.style.justifyContent = 'space-between';
    wrapper.style.alignItems = isMobile ? 'flex-start' : 'center';
    wrapper.style.width = '100%';
    wrapper.style.gap = isMobile ? '12px' : '24px';

    // Создаем кнопку
    const btn = document.createElement('a');
    btn.href = link.href;
    btn.textContent = 'Перейти';
    btn.className = 'gc-go-btn';
    btn.target = '_blank';

    // Удаляем оригинальную ссылку, если она дублирует кнопку
    link.removeAttribute('href');
    link.style.pointerEvents = 'none';

    // Перемещаем заголовок и кнопку внутрь wrapper
    wrapper.appendChild(title);  // Название тренинга
    wrapper.appendChild(btn);    // Кнопка

    // Очищаем td и вставляем wrapper
    td.innerHTML = '';
    td.appendChild(wrapper);
  }
});
