
  .searchbar {
    z-index:1;
  }
  ::-webkit-scrollbar {
  width: 16px;
  height: 16px; }

  ::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.2);
  -webkit-box-shadow: inset 1px 1px 0 rgba(0,0,0,0.10),inset 0 -1px 0 rgba(0,0,0,0.07); }

  .ui-autocomplete { 
  max-height: 220px; 
  min-height: 38px;
  overflow-y: auto; 
  overflow-x: hidden;
  scrollbar-color: #c1c1c1ff #424242; 
  border-radius: 1rem;
  max-width: 274px;
  align-items: center;
  }
  #arrowImg {
      height: 13px;
      margin-left: -6px;
      margin-top: -15px;
  }

  #arrowImg.dark {
     color: #000;
  }

  article {
      margin-left: 5px;
  }

  #sutta p, 
  #sutta ol, 
  #sutta ul, 
  #sutta li { 
    margin-bottom: 1.5rem; 
    font-size: 1.1rem; 
  }

  #sutta h1 {
    text-align: center;
  }

  #sutta hr { 
  display: none;
  }

#scrollToTopBtn {
  border-width: 2px;
  border-radius: 32px;
  bottom: 30px;
  right: 90px;
  /* background-color: #424269; border-color: #5A5A5A; */ /* Ваши старые комменты */
  height: 30px;
  width: 30px;
  
  /* --- ИЗМЕНЕНИЯ ЗДЕСЬ --- */
  
  /* 1. Начальное состояние перед анимацией */
  opacity: 0; 
  transform: scale(0.5); 

  /* 2. Применяем ту же анимацию "пружины" */
  animation: btnPopIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  
  /* 3. Плавность для эффектов при наведении */
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Добавим эффект наведения для комплекта, как у TTS кнопки */
#scrollToTopBtn:hover {
  transform: scale(1.15) !important; /* Чуть увеличиваем при наведении */
  opacity: 1 !important; /* Делаем полностью непрозрачной */
}


  html.dark #scrollToTopBtn #arrowImg,
  body.dark #scrollToTopBtn #arrowImg,
  body[data-theme="dark"] #scrollToTopBtn #arrowImg {
    filter: invert(1);
  }

  .go-button {
    margin-left: 5px;
    height: 35px;
    width: 35px;
    border-radius: 32px;
    -webkit-border-radius: 32px;
    border: 1px solid #5a5a5a; /* --dark-gray */
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 0;
   /* background-color: transparent;*/
    background-color: rgb(221, 221, 221);
    color: #5a5a5a;
  }

  .byline p {
    overflow: hidden;  
    text-overflow: ellipsis; /* "..." если текст не помещается */
    margin: 0;          /* Убираем отступы */
  }

    /* 
  .rus-lang {
    font-family: "Robto Serif", serif;
  }
  */

  .hint {
    font-family: sans-serif;
    z-index:100;
  }

  .byline .pli-lang,
  .byline .rus-lang, .byline .eng-lang {
    display: inline;    /* Отменяем inline-block для byline */
    width: auto;        /* Сбрасываем ширину */
  }

  /* Резервируем место, даже если текст пуст или скрыт */
  .byline::after {
    content: "";
    display: inline-block;
    height: 1.2rem;  /* Такая же высота, как у текста */
    visibility: hidden;  /* Невидим, но сохраняет место */
  }

  .dark .go-button {
    border-color: #dddddd; /* --off-white */
    background-color: #42426a; /* --dark-blue */
    color: #dddddd; /* --off-white */
  }

  .dark .go-button:hover {
    background-color: #8f8f8f; /* --light-gray */
  }

  .roundedborder{
    position: absolute; 
    right :35px; 
    z-index:999999;
  }

  input,
  button,
  select,
  optgroup,
  textarea {
   /* font-family: "Robto Serif";*/
    font-size: 0.8rem;
    line-height: 1rem;
  }
  .svgarrow {
    color: #000;
  }

  .dark .svgarrow {
    color: #D5D5D5;
  }

  #match-button-next {
    border-radius: 32px;
    position: fixed; 
    bottom: 30px; 
    right: 100px; 
    z-index: 99; 
    padding: 5px; 
  }

  #match-button-clear {
    display: none;
    border-radius: 32px;
    position: fixed; 
    bottom: 30px; 
    right: 100px; 
    z-index: 99; 
    padding: 5px; 
  }

  .warning {
    color: #902A07;
    text-align: center;
  }

  .dark p.warning {
    color: rgb(170,69,16);
  }

  .close-warning {
    cursor: pointer; 
    margin-left: 0px; 
    font-weight: bold;
  }

  /* На маленьких мобильных: показываем только номер */
  #navigation {
    display: flex;
    gap: 8px; 
    overflow: hidden;
  }

  #previous2,
  #next2 {
      max-width: 49%;
    word-break: break-word;
  }

  #previous,
  #previous2 {
    margin-right: auto;
    text-align: left;
  }

  #next,
  #next2 {
    margin-left: auto;
    text-align: right;
  }

  #previous,
  #next {
    max-width: 49%;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
    line-height: 1.2em; /* или 1.4em, в зависимости от шрифта */
    height: 2.4em;       /* 1.2em * 2 строки */
  }

  #previous a,
  #next a {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2em;
    height: 2.4em;
  }

  /* Стиль для названия сутты (одна строка + обрезка) */
  .sutta-name {
    white-space: nowrap; /* Запрещаем перенос */
    overflow: hidden;
    text-overflow: ellipsis; /* Добавляем "..." */
    max-width: 48%; /* Ограничиваем ширину (можно адаптивно) */
  }

  .afternav {
      display: none;
    }

    @media (max-width: 356px) {
   .sutta-name {
      display: none;
    }

  .afternav {
        display: block;
      }
    }

  .finder {
    color: #902A07;
      font-weight: bold;
  }

  .dark .finder  {
    color: #DA420E;
        font-weight: bold;
  }  

  .common-size-icon4 {
    margin-top: -3px; 
  margin-left: 6px;	
    height: 25px; 
    width: 22px;
  }


/* === Базовые стили для всех режимов === */

.pli-lang, .eng-lang, .rus-lang {
  display: block;       /* Forces the element to take full width */
  margin-bottom: 4px;   /* Adds a little breathing room between languages */
}


  .column-view .pli-lang,
  .column-view .eng-lang,
  .column-view .rus-lang {
    display: inline-block;
    vertical-align: top;
    text-align: left;
    box-sizing: border-box;
    word-wrap: break-word;
  }

  .column-view .pli-lang:not(:empty) + .rus-lang:not(:empty),
  .column-view .pli-lang:not(:empty) + .eng-lang:not(:empty),
  .column-view .eng-lang:not(:empty) + .rus-lang:not(:empty) {
    width: 48%;  
  }

  header .column-view .pli-lang:not(:empty) {
      width: 100%;  

  }


  .column-view .pli-lang:not(:empty) {
    width: 48%;
    padding-right: 10px;
    max-width: 48%;
  }

  /* === Новый стиль: с .right-column === */

  /* Если внутри .column-view есть .right-column */
  .column-view .right-column {
    display: inline-block;
    width: 48%;
    padding-left: 10px;
    vertical-align: top;
    box-sizing: border-box;

    /* Убираем возможные пробельные отступы между дочерними элементами 
    font-size: 0;*/ /* Отключаем влияние размера шрифта на inline-block элементы */
  }

  /* Внутри right-column — восстанавливаем нормальный размер текста 
  .column-view .right-column * {
    font-size: medium;  
  }*/

  /* Pali — слева */
  .column-view .pli-lang:not(:empty) {
    width: 48%;
    padding-right: 10px;
    max-width: 48%;
  }

  /* Переводы внутри right-column — блочные элементы */
  .column-view .right-column .rus-lang,
  .column-view .right-column .eng-lang {
    display: block;
    width: 100%;
    margin: 0; /* Убираем все внешние отступы */
    padding: 0;
  }

  /* Убедимся, что <br> не добавляет лишний отступ */
  .column-view .right-column br {
    display: none; /* Либо удалите <br> из HTML, если он не нужен */
  }

  /* Скрытие пустых */
  .column-view .pli-lang:empty,
  .column-view .eng-lang:empty,
  .column-view .rus-lang:empty {
    display: none;
  }

  /* Ширина контейнера */
  #sutta.column-view {
    max-width: 105rem;
  }

  /* Перенос слов для читаемости    white-space: pre-wrap; */
  #sutta * {
    word-break: break-word;
    overflow-wrap: break-word;
  }


  .greyedout {
    color: #5a5a5a !important;
  }

  .dark .greyedout {
    color: #8f8f8f !important;
  }


  .variant {
    display: inline; /* или inline-block */
    vertical-align: baseline;
    line-height: 1.4; /* совпадает с основным текстом */
    margin: 0;
    padding: 0;
    color: #95796b !important;
  }

  .dark .variant {
    color: #83676a !important;
  }

  .dark .btn-close {
    color: #989898 !important;
    filter: invert(1) grayscale(100%) brightness(200%);
  }


  .hidden-variant {
    display: none !important;
  }


  .sutta-title .variant {
    display: block;
    font-size: 18px;
    font-weight: normal;
    line-height: 1.4;
  }

#language-button {
  border-radius: 32px;
  position: fixed; 
  bottom: 30px; 
  right: 20px; 
  z-index: 100; 
  padding: 5px; 
  /* Добавляем прозрачность и анимацию как у соседних кнопок */
  opacity: 0.8; 
  animation: btnPopIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Эффект при наведении, чтобы она становилась полностью непрозрачной */
#language-button:hover {
  opacity: 1 !important;
  transform: scale(1.1);
}



  #language-button-dummy {
    border-radius: 32px !important;
    /*position: absolute;
    right: 10px;
    top: 20px;*/
    padding: 5px; 
  }

  .copyLink {
      position: relative;
      display: inline-block;
      vertical-align: middle;
      -webkit-tap-highlight-color: transparent;
    /*   touch-action: manipulation;
      user-select: none;
      -webkit-user-select: none;
      -webkit-touch-callout: none; */
  }

  .copyLink::after {
      content: "";
      position: absolute;
      left: 0;
      right: 0;
      top: -2px;
      bottom: -2px;
      background-color: transparent;
      transition: 
          background-color 0.5s ease-out,
          box-shadow 0.5s ease-out,
          opacity 0.5s ease-out,
          top 0.3s ease-out,
          bottom 0.3s ease-out,
          left 0.3s ease-out,
          right 0.3s ease-out;
      border-radius: 3px;
      opacity: 0;
      pointer-events: none;
  }

  /* Для десктопов - hover */
  @media (hover: hover) {
      .copyLink:hover::after {
          background-color: rgba(19, 104, 87, 0.8); /* Полупрозрачный вариант */
          top: -3px;
          bottom: -3px;
          left: -3px;
          right: -3px;
          box-shadow: 0 0 4px rgba(19, 104, 87, 0.5);
          opacity: 1;
      }
  }

  /* Яркое подтверждение при касании */
  .copyLink:active::after {
      background-color: #136857; /* Полностью непрозрачный */
      box-shadow: 0 0 8px rgba(19, 104, 87, 0.8); /* Ярче свечение */
      top: -4px;
      bottom: -4px;
      left: -4px;
      right: -4px;
      opacity: 1;
      transition: 
          background-color 0.1s ease-out,
          box-shadow 0.1s ease-out,
          top 0.1s ease-out,
          bottom 0.1s ease-out,
          left 0.1s ease-out,
          right 0.1s ease-out; /* Очень быстрое появление */
  }

  /* Для тач-устройств - фокус после касания */
  .copyLink:focus::after {
      background-color: rgba(19, 104, 87, 0.6);
      top: -3px;
      bottom: -3px;
      left: -3px;
      right: -3px;
      box-shadow: 0 0 4px rgba(19, 104, 87, 0.5);
      opacity: 1;
      outline: none;
      transition-duration: 0.5s; /* Медленное затухание */
  }

  /* Убираем фокус для мыши */
  @media (hover: hover) {
      .copyLink:focus::after {
          background-color: transparent;
          box-shadow: none;
          opacity: 0;
      }
  }

  /* Делаем родительские элементы контекстом для позиционирования */
  .pli-lang, .rus-lang, .eng-lang, .variant {
    position: relative;
  }


  p .copyLink,
  p .copyLink-start {
      font-size: 1.2em; /* или другой желаемый размер */
  }

  a.copyLink::before,
  a.copyLink-start::before {
    content: '✦';
  }

  .copyLink {
        opacity: 0;
  }

  .copyLink-start {
      position: absolute;
      top: -0.2em;
      left: -1.0em;

      color: inherit;
      opacity: 0;
      text-decoration: none;
      cursor: pointer;
      transition: opacity 0.3s ease;
  }
  .copyLink:hover,
  .copyLink:focus,
  .copyLink-start:hover,
  .copyLink-start:focus {
      opacity: 0.9;
  }

  h1.sutta-title > span,
  header ul li > span {
    position: relative;
  /*  display: inline-block; */
    vertical-align: top; 
  }

.plain-label {
  all: unset;             
  cursor: pointer;       
  display: inline;
}


#settings, #paliLookupInfo{
    z-index: 1000 !important;
}


.modal-backdrop {
    z-index: 999 !important;
}

   /*   background-color: rgba(52, 52, 190, 0.2);
     background-color: rgba(66, 66, 106, 0.6);
  */
/* Класс для подсветки текущего предложения при чтении */

/* 1. Общее правило для обычного текста (оставляем как есть) */
#sutta.hide-pali .rus-lang,
#sutta.hide-pali .eng-lang {
    display: block;
    margin-bottom: 8px; /* Отступ для абзацев */
}

/* 2. СПЕЦИАЛЬНОЕ правило для стихов: убираем отступ */
#sutta.hide-pali .verse-line .rus-lang,
#sutta.hide-pali .verse-line .eng-lang {
    margin-bottom: 0; /* Строки стиха будут прижаты друг к другу */
}

/* 3. Дополнительно: добавить небольшой отступ всему блоку стиха, если нужно */
#sutta.hide-pali .verse-line {
    margin-bottom: 2px; /* Небольшой зазор между строками самого HTML контейнера */
}



/* Контейнер для умной кнопки */
#smart-gear-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    
    /* ВАЖНО: Контейнер прозрачен для кликов, чтобы не перекрывать сайт */
    pointer-events: none;
}

/* Кнопка-триггер (шестеренка) */
#smart-gear-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    
    background-color: rgb(221, 221, 221); 
    border: 2px solid #5a5a5a;
    
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none;
    padding: 0;
    
    opacity: 0;
    transform: translateY(-20px) scale(0.5);
    visibility: hidden;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s;

    /* ВАЖНО: Кнопка ловит клики, но только когда станет visible */
    pointer-events: auto; 
}

/* Размер иконки */
#smart-gear-btn img {
    width: 16px;
    height: 16px;
    display: block;
}

/* Когда добавляем класс visible через JS */
#smart-gear-btn.visible {
    opacity: 0.8;
    transform: translateY(0) scale(1);
    visibility: visible;
    /* pointer-events: auto уже наследуется, а visibility: visible включает его */
}

/* Эффект при наведении */
#smart-gear-btn:hover {
    opacity: 1 !important;
    transform: scale(1.15) !important;
    background-color: rgb(221, 221, 221);
}

/* Темная тема */
.dark #smart-gear-btn {
    background-color: #42426a;
    border-color: #5a5a5a;
}


.dark #smart-gear-btn img {
    filter: brightness(0) invert(0.7) !important;
}

#smart-panel {
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    border: 1px solid #ccc;
    
    /* --- ДОБАВЬ ЭТИ ТРИ СТРОКИ --- */
    max-height: calc(100vh - 80px); /* 80px — запас, чтобы панель не упиралась в края экрана */
    overflow-y: auto;               /* Включаем скролл, если контент не влезает */
    -webkit-overflow-scrolling: touch; /* Плавный скролл для мобильных устройств */
    /* ----------------------------- */

    opacity: 0;
    visibility: hidden;
    transform: scale(0.9);
    transform-origin: top right;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    
    /* ВАЖНО: Скрытая панель не должна ловить клики */
    pointer-events: none;
}

#smart-panel.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    
    /* ВАЖНО: Активная панель начинает ловить клики */
    pointer-events: auto;
}

.smart-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 8px;
    transition: background 0.2s;
}

.smart-btn:hover {
    background-color: rgba(0,0,0,0.1);
}

.smart-btn img {
    width: 24px;
    height: 24px;
}

.dark #smart-panel {
    background-color: #333;
    border-color: #555;
}
.dark .smart-btn img {
    filter: invert(1);
}
.dark .smart-btn:hover {
    background-color: rgba(255,255,255,0.1);
}

#dict-select {
  width: 140px;
  max-width: 180px;
}
.btn-language {
    text-decoration: none;
    color: white !important; 
}


@media (max-height: 520px) {
  #smart-gear-container {
    top: 8px;
    right: max(20px, env(safe-area-inset-right, 0px));
    align-items: flex-end;
    pointer-events: none;
    z-index: 1002;
  }


  #smart-panel {
    position: fixed;
    top: 52px;
    right: max(20px, env(safe-area-inset-right, 0px));
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform-origin: top right;
    box-sizing: border-box;
    pointer-events: auto;
  }

  #smart-panel .smart-btn {
    white-space: normal;
    word-break: break-word;
  }
}


/* Стилизация по ID для очистки HTML */
#chapter-button img {
    position: relative;
    top: -2px;
}

#fontDec, #fontInc {
    width: 32px;
    height: 32px;
    font-weight: bold;
}

#fontVal {
    min-width: 45px;
}

/* Общие стили для иконок компаса в модальных окнах */
.compass-icon {
    cursor: pointer;
    height: 25px;
    width: 25px; /* фиксируем ширину */
    color: grey;
    margin-left: 0.5em; /* небольшой отступ от заголовка */
    display: inline-flex; /* flex лучше центрирует картинку */
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}
.compass-icon img {
    height: 100%;
    width: auto;
}


/* Разделитель в смарт-панели */
#smart-panel hr {
    margin: 4px 0;
    border-color: #ccc;
}


/* Специальный зеленый варнинг для Devanagari и Memorize */
.warning-green {
    color: green !important;
}

/* Стили из начала memorize.js перенесены сюда для скорости */
.mem-pli-size {
    font-size: 1.4em !important;
}

.mem-copy-size {
    font-size: 0.8em !important;
}

.mem-copy-pos {
    bottom: 0em !important;
    right: -0.6em !important;
}

  /* === ОБЩИЕ СТИЛИ === */
    .mem-trigger {
        cursor: pointer;
        position: relative;
        transition: color 0.2s, text-shadow 0.2s, border-bottom-color 0.2s;
        border-bottom: 1px solid transparent;
    }
    
    .mem-trigger:hover,
    .mem-trigger.mem-active { 
        color: var(--bs-primary, #0d6efd); 
        border-bottom-color: var(--bs-primary, #0d6efd);
    }

    .mem-bubble {
        position: absolute;
        background-color: #ffffff;
        color: #333333;
        border: 1px solid #ccc;
        box-shadow: 0 4px 10px rgba(0,0,0,0.2);
        padding: 6px 12px; /* Чуть больше паддинг для многострочного текста */
        border-radius: 6px;
        font-size: 18px; 
        font-family: sans-serif;
        z-index: 10000;
        
        /* === ИЗМЕНЕНИЯ ДЛЯ ПЕРЕНОСА СЛОВ === */
        white-space: normal;       /* Разрешаем перенос */
        overflow-wrap: break-word; /* Ломаем длинные слова */
        word-break: break-word;    /* Совместимость */
        text-align: center;        /* Центрируем текст */
        line-height: 1.3;          /* Межстрочный интервал */
        
        /* Ограничиваем ширину */
        width: max-content;        /* Стремимся к ширине контента */
        max-width: 300px;          /* Но не шире 300px на десктопе */
        
        /* На мобильных не шире экрана */
        @media (max-width: 400px) {
            max-width: 85vw;
        }

        pointer-events: auto; 
        cursor: pointer; 
        
        transform: translateY(-100%); 
        margin-top: -8px;
        opacity: 0; 
        transition: opacity 0.2s ease-out; 
    }
    
    .mem-bubble.visible {
        opacity: 1;
    }

    /* Стрелочка вниз */
    .mem-bubble::after {
        content: "";
        position: absolute;
        top: 100%;
        left: var(--arrow-x, 50%); 
        margin-left: -6px;
        border-width: 6px;
        border-style: solid;
        border-color: #ffffff transparent transparent transparent; 
    }
    /* Обводка стрелочки */
    .mem-bubble::before {
        content: "";
        position: absolute;
        top: 100%;
        left: var(--arrow-x, 50%);
        margin-left: -7px;
        border-width: 7px;
        border-style: solid;
        border-color: #ccc transparent transparent transparent; 
    }

    /* === ТЕМНАЯ ТЕМА === */
    body.dark .mem-trigger:hover,
    body.dark .mem-trigger.mem-active {
        color: var(--bs-primary, #0d6efd); 
        text-shadow: 0 0 8px rgba(13, 110, 253, 0.6); 
    }
    body.dark .mem-bubble {
        background-color: #2b2b2b;
        color: #e0e0e0;
        border: 1px solid #555;
        box-shadow: 0 4px 10px rgba(0,0,0,0.6);
    }
    body.dark .mem-bubble::after {
        border-color: #2b2b2b transparent transparent transparent;
    }
    body.dark .mem-bubble::before {
        border-color: #555 transparent transparent transparent;
    }
    
    
/* Подсветка последнего нажатого слова (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-mini-button {
  width: 17px !important; 
  height: 17px !important; 
  vertical-align: middle;
}

@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; 
  transform: scale(0.5); 
  animation: btnPopIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;

  transition: all 0.3s ease; 
  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; 
  transform: none !important; 
}

.dark .dynamic-tts-btn {
  border-color: #5a5a5a;
  background-color: #42426a;
}

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


#form.ui-widget #paliauto,
#paliauto.ui-autocomplete-input,
#paliauto {
    font-size: 1.0rem !important; 
    line-height: 1rem !important; 
    font-family: var(--bs-font-sans-serif, sans-serif) !important; 
    padding-left: 10px !important;
    padding-right: 10px !important;
    height: 35px !important;
    box-sizing: border-box !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}


/*
smart TOC 
*/

/* Контейнер для кнопки и панели оглавления */
#smart-toc-container {
    position: fixed;
    top: 20px;
    right: 60px; /* Сдвинуто левее шестеренки (30px + отступ) */
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none;
}

/* Кнопка-пилюля */
#smart-toc-btn {
    height: 30px;
    border-radius: 15px;
    background-color: rgb(221, 221, 221);
    border: 2px solid #5a5a5a;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    cursor: pointer;
    padding: 0 10px;
    gap: 8px;
    max-width: 250px;
    box-shadow: none;
    
    opacity: 0;
    transform: translateY(-20px) scale(0.9);
    visibility: hidden;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s;
    pointer-events: auto;
}

#smart-toc-btn.visible {
    opacity: 0.8;
    transform: translateY(0) scale(1);
    visibility: visible;
}

#smart-toc-btn:hover {
    opacity: 1 !important;
    transform: scale(1.05) !important;
    background-color: rgb(221, 221, 221);
}

#smart-toc-btn img {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}


/* Состояние только с иконкой (в самом верху страницы) */
#smart-toc-btn.icon-only {
    max-width: 30px; 
    padding: 5px;
    justify-content: center;
}

#smart-toc-btn.icon-only span {
    display: none;
}

#smart-toc-current {
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #333;
    font-family: sans-serif;
}

/* Выпадающая панель оглавления */
#smart-toc-panel {
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    border: 1px solid #ccc;
    
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;

    opacity: 0;
    visibility: hidden;
    transform: scale(0.9);
    transform-origin: top right;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    
    width: max-content;
    max-width: 320px;
}

#smart-toc-panel.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    pointer-events: auto;
}

/* Элементы списка оглавления */
.toc-item {
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    color: #333;
    transition: background 0.2s;
    word-break: break-word;
    line-height: 1.2;
    font-family: sans-serif;
}

.toc-item:hover {
    background-color: rgba(0,0,0,0.05);
}

.toc-item.active {
    background-color: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.1);
    color: var(--bs-primary, #0d6efd);
    font-weight: bold;
}

/* Иерархия отступов */
.toc-h1 { margin-left: 0; font-size: 16px; font-weight: bold; }
.toc-h2 { margin-left: 12px; font-size: 14px; font-weight: bold; }
.toc-h3 { margin-left: 24px; font-size: 14px; }
.toc-h4, .toc-h5, .toc-h6 { margin-left: 36px; font-size: 13px; color: #555; }

/* Темная тема */
.dark #smart-toc-btn {
    background-color: #42426a;
    border-color: #5a5a5a;
}
.dark #smart-toc-btn img {
    filter: brightness(0) invert(0.7);
}
.dark #smart-toc-current {
    color: #ddd;
}
.dark #smart-toc-panel {
    background-color: #333;
    border-color: #555;
}
.dark .toc-item {
    color: #e0e0e0;
}
.dark .toc-item:hover {
    background-color: rgba(255,255,255,0.1);
}
.dark .toc-item.active {
    background-color: rgba(13, 110, 253, 0.2);
    color: #6ea8fe;
}
.dark .toc-h4, .dark .toc-h5, .dark .toc-h6 { color: #aaa; }

/* Адаптация для мобильных как у шестеренки */
@media (max-height: 520px) {
    #smart-toc-container {
        top: 8px;
        right: max(60px, calc(env(safe-area-inset-right, 0px) + 40px));
    }
    #smart-toc-panel {
        position: fixed;
        top: 52px;
        right: max(20px, env(safe-area-inset-right, 0px));
        max-height: calc(100vh - 64px);
    }
}

/* === Стили языков внутри оглавления === */
.toc-item .pli-lang {
    color: #222; /* Темный (основной) для Пали в светлой теме */
    font-weight: 500;
    line-height: 1.2;
    margin-bottom: 2px;
    display: block; /* Каждый язык с новой строки */
}

.toc-item .rus-lang, 
.toc-item .eng-lang, 
.toc-item .tha-lang {
    color: #777; /* Серый (вторичный) для перевода в светлой теме */
    line-height: 1.2;
    display: block;
}

/* Темная тема для оглавления */
.dark .toc-item .pli-lang {
    color: #e0e0e0; /* Яркий белый для Пали в темной теме */
}

.dark .toc-item .rus-lang, 
.dark .toc-item .eng-lang, 
.dark .toc-item .tha-lang {
    color: #999; /* Светло-серый для перевода в темной теме */
}

/* === Синхронизация видимости языков в TOC === */
#smart-toc-panel.hide-pali .pli-lang,
#smart-toc-panel.hide-russian .rus-lang,
#smart-toc-panel.hide-english .eng-lang {
    display: none !important;
}
