
.tts-active {
    background-color: rgba(var(--bs-primary-rgb), 0.2); /* Чуть прозрачнее, чем слово */
    border-radius: 0.25rem;
    box-shadow: 0 0 0 1px rgba(var(--bs-secondary-rgb), 0.2);
    transition: background-color 260ms ease-in-out;
    scroll-margin-top: 20vh;
    /* Чтобы подсветка красиво переносилась на новые строки */
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}


@media (max-width: 768px) {
  .tts-active {
    scroll-margin-top: 15vh; 
  }
}


.tts-mini-button {
  width: 17px; 
  height: 17px; 
  vertical-align: middle;
}

/* Универсальный класс для кнопок-иконок в меню Voice */
.tts-icon-btn {
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    line-height: 0 !important;
    outline: none;
    border: none;
    padding: 2px;
    transition: opacity 0.2s;
}

.tts-icon-btn:hover {
    opacity: 0.7;
    text-decoration: none !important;
}

.tts-icon-btn img {
    display: block;
    margin: 0;
}

/* Убираем стандартные подчеркивания ссылок внутри плеера */
.voice-player a {
    text-decoration: none !important;
}


/* Подсветка последнего нажатого слова (Bootstrap primary) */
.active-word {
  background-color: rgba(var(--bs-primary-rgb), 0.35);
  border-radius: 0.25rem;
    box-shadow: 0 0 0 1px rgba(var(--bs-secondary-rgb), 0.15);
}

.dark .active-word {
  background-color: rgba(var(--bs-primary-rgb), 0.25);
    box-shadow: 0 0 0 1px rgba(var(--bs-secondary-rgb), 0.15);
}

  .pli-lang, .rus-lang, .eng-lang {
transition: background-color 260ms ease-in-out;
}

/* Объединенный стиль для селекторов режима и скорости */
.tts-mode-select, 
.tts-rate-select {
    background: transparent;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
    padding: 2px;
    color: #666;
    cursor: pointer;
    margin-bottom: 5px; /* Чтобы не прилипали друг к другу при переносе */
}

/* Стилизация темной темы для обоих селекторов */
.dark .tts-mode-select,
.dark .tts-rate-select {
    border-color: #555;
    color: #ccc;
    background-color: #333;
}

/* Контейнер для подписи "Speed" */
.tts-speed-label {
    font-size: 12px;
    color: #888;
    margin-right: 3px;
}



.tts-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.tts-icon-btn.large .tts-main-img {
    width: 32px;
    height: 32px;
}

.tts-footer {
    margin-top: 8px;
    font-size: 0.9em;
}

/* Убираем подчеркивание в любой ситуации */
.tts-icon-btn, .tts-icon-btn img {
    text-decoration: none !important;
    border: none !important;
}

.voice-dropdown {
    position: relative;
    display: inline-block;
}

.next-main-button {
  position: relative; 
  top: -2px;
  right: 6px;
}

.voice-link {
    position: relative; 
    display: inline-block;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.voice-player {
    display: block; 
    visibility: hidden;
    opacity: 0;
    position: fixed;

    bottom: 50px; 
    left: 50%;
    
    /* Состояние "Скрыто": смещаем вниз на 120% высоты элемента */
    transform: translate(-50%, 120%);
    
    /* Сохраняем ваш дизайн */
    background: white;
    padding: 10px;
    border: 1px solid #ddd;
    z-index: 999;
    min-width: 130px;
    max-width: 90vw;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 24px;

    /* Плавная анимация выезда */
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease, visibility 0s 0.4s;
}

.voice-dropdown.active .voice-player {
    /* Состояние "Показано" */
    visibility: visible;
    opacity: 1;
    
    /* Поднимаем чуть выше края экрана (на 30px), чтобы висела красиво, как раньше */
    transform: translate(-50%, -30px);
    
    /* Убираем задержку видимости при появлении */
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease, visibility 0s;
}

/* Темная тема (остается без изменений, просто для сохранения контекста) */
.dark .voice-player {
    background: #333;
    border-color: #555;
    color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.player-links {
    margin-top: 15px;
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .voice-player {
    width: 95%;  /* Чуть шире на мобильных */
        max-width: 210px;
        max-height: 80vh;
        overflow-y: auto;
    }
    
.tts-link {
  font-size: 0.7em;
  position: relative;
  top: -2px;
}
    /* При активном состоянии на мобильных можно поднимать чуть меньше, если нужно */
    .voice-dropdown.active .voice-player {
         transform: translate(-50%, -20px);
    }
}
/*
.close-tts-btn {
  position: relative; 
  top: -3px;    
  cursor: pointer;
  color: #999;
  text-decoration: none !important;
  z-index: 10;
}
*/

.close-tts-btn:hover {
  opacity: 0.7;
  color: #333;        /* Затемнение при наведении */
}

/* Для темной темы (чтобы крестик был виден) */
.dark .close-tts-btn {
  color: #bbb;
}
.dark .close-tts-btn:hover {
  color: #fff;
}


.tts-icon {
  display: inline-block;
}

.tts-icon.backward, .tts-icon.forward {
  width: 20px;
}

.tts-icon.play {
  width: 45px;
}

.tts-icon.forward {
  position: relative;
  right:5px;
}


.tts-mode-select,
.tts-rate-select {
  font-size: 14px;
}

/* Анимация появления: увеличение с небольшим отскоком */
@keyframes btnPopIn {
  0% {
    opacity: 0;
    transform: scale(0.5); /* Начинаем с маленького размера */
  }
  60% {
    transform: scale(1.1); /* Чуть увеличиваем больше нормы (пружина) */
  }
  100% {
    opacity: 0.8;
    transform: scale(1);   /* Возвращаем в норму */
  }
}

.dynamic-tts-btn {
  position: fixed;
  right: 90px; 
  bottom: 30px; 
  z-index: 99;
  width: 30px;  
  height: 30px;
  
  /* Идеальная центровка */
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  
  box-sizing: border-box;
  border-radius: 50%; /* Круглая форма */
  border: 2px solid #5a5a5a; 
  background-color: rgb(221, 221, 221);
  cursor: pointer;
  
  /* --- ИЗМЕНЕНИЯ ЗДЕСЬ --- */
  opacity: 0; /* Исходно невидима, анимация сделает 0.8 */
  transform: scale(0.5); /* Исходно маленькая */
  animation: btnPopIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  /* ----------------------- */

  transition: all 0.3s ease; /* Это оставим для hover эффектов */
  padding: 0;
  margin: 0;
}

.dynamic-tts-btn.shifted {
  right: 132px; /* Сдвигаем левее, чтобы освободить место кнопке "Вверх" */
}

/* Добавим эффект при наведении для живости */
.dynamic-tts-btn:hover {
  opacity: 1 !important;
  transform: scale(1.1) !important; /* Кнопка чуть увеличится при наведении */
}


.dynamic-tts-btn img {
  width: 14px;
  height: 14px;
  /* Убираем любые дефолтные смещения браузера */
  display: block;
  margin: 0 auto; 
}

/* Темная тема для соответствия uiextra.css */
.dark .dynamic-tts-btn {
  border-color: #5a5a5a;
  background-color: #42426a;
}

.dark .dynamic-tts-btn img {
  filter: invert(1);
}

/* 1. Контейнер лейбла */
.tts-checkbox-custom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  font-size: 14px;
  padding: 2px 6px;
  color: #666;
  cursor: pointer;
  margin-top: 5px;
  width: auto;
}

/* 2. Сам чекбокс (базовые настройки для светлой темы) */
.tts-checkbox-custom input {
  appearance: checkbox !important;
  -webkit-appearance: checkbox !important;
  display: inline-block !important;
  width: 13px !important;
  height: 13px !important;
  margin: 0 6px 0 0 !important;
  cursor: pointer;
  vertical-align: middle;
  border-radius: 4px;
  /* Принудительно задаем светлую схему для белого фона */
  color-scheme: light; 
}

/* 3. Поддержка темной темы */
.dark .tts-checkbox-custom {
  border-color: #555;
  color: #ccc;
  background-color: #333;
}

.dark .tts-checkbox-custom input {
    /* Принудительно задаем темную схему для темного фона */
    color-scheme: dark;
}

/* Убираем или меняем accent-color, если он перекрывает стандартный вид */
.tts-checkbox-custom input[type="checkbox"] {
  accent-color: #5a5a5a; 
}

/* --- ГРУППОВАЯ ПОДСВЕТКА БЛОКА (Исправленная) --- */

/* 1. Сам блок-контейнер */
#sutta span[id]:has(.tts-active) {
    display: block; 
        scroll-margin-top: 15vh;

    /* Зеленоватый цвет (тот же тон, что и active-word), прозрачность 0.15 */
    background-color: rgba(var(--bs-primary-rgb), 0.25);
    border-radius: 6px;
 /*   padding: 2px 2px; 
    margin: 2px -2px; */
    transition: background-color 0.2s ease;
    /* Убирает разрывы заливки, если блок переносится */
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

/* 2. Поддержка темной темы */
.dark #sutta span[id]:has(.tts-active),
body[data-theme="dark"] #sutta span[id]:has(.tts-active) {
    /* В темной теме чуть плотнее, чтобы было видно */
    background-color: rgba(var(--bs-primary-rgb), 0.30); 
}

/* 3. УБИРАЕМ АРТЕФАКТЫ ВНУТРИ (Самое важное) */
/* Мы говорим: если блок подсвечен целиком, то внутренние элементы (.active-word и .tts-active)
   должны стать полностью прозрачными и без рамок */
#sutta span[id]:has(.tts-active) .tts-active,
#sutta span[id]:has(.tts-active) .active-word {
    background-color: transparent !important;
    box-shadow: none !important; /* Убирает "тень" или обводку вокруг слов */
    border: none !important;
    border-radius: 0;
    padding: 0; /* Убираем отступы, чтобы текст не прыгал */
}

/* 4. Исправление для режима колонок */
.column-view #sutta span[id]:has(.tts-active) {
    display: flow-root;
}

/* Выравнивание плеера и боковых кнопок в одну горизонтальную линию на широких экранах */
@media (min-width: 475px) {
    .voice-dropdown.active .voice-player {
        transform: translate(-50%, 25px);
    }
}
