
  .searchbar {
    z-index:1;
  }
  /* Scrollbar styling moved to public/overrides/css/extrastyles.css — one rule for the whole
     site instead of this file's own (16px, no radius) winning here just because it loaded last
     (owner: the reader's burger menu looked like unstyled default html next to the home page). */

  .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;
  }
  /* Was hand-tuned negative margins (margin-left:-6px, margin-top:-15px) — assumed a button box
     model that no longer matches (body #scrollToTopBtn in search/index.html sets a fixed 30x30,
     padding:0, border:2px); measured live: icon center sat ~5px above true center. Tried
     display:flex on #scrollToTopBtn first — didn't stick: smoothScroll.js toggles this button's
     visibility with an INLINE style.display ('block'/'none') on every scroll event, and inline
     style always beats a stylesheet rule, so any `display` set here gets silently overwritten the
     next time the user scrolls. Absolute-positioning the icon sidesteps that entirely — doesn't
     care what `display` the button itself ends up with, as long as the button stays the
     positioned ancestor (it does — position:fixed already). Explicit width, not auto: at
     height:13px without a width the box rendered 15px wide instead of the ~9.8px the SVG's own
     113x150 intrinsic ratio implies — pinned instead of chasing why. */
  #arrowImg {
      height: 17px;
      width: 12.8px;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      margin: 0;
      /* Owner: the icon read noticeably heavier/more solid than the language pill next to it,
         even though both buttons share the same 0.8 container opacity (#scrollToTopBtn,
         .dynamic-tts-btn below) — a solid glyph shape just reads as more opaque than antialiased
         text at the same numeric value. Fade the glyph itself too, same value as the TTS icon. */
      opacity: 0.8;
  }
  #scrollToTopBtn:hover #arrowImg {
      opacity: 1;
  }

  #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; */ /* Ваши старые комменты */
  /* Matches #language-button's rendered height (38px) — see same note in search/index.html. */
  height: 38px;
  width: 38px;
  /* НЕ ставить здесь display:flex — smoothScroll.js переключает видимость этой кнопки инлайновым
     style.display ('block'/'none') на каждый скролл, инлайн всегда бьёт правило из таблицы
     стилей, flex тут же слетал бы обратно в block. Центровка иконки — через position:absolute
     на #arrowImg (см. выше), ей не важно, какой display у кнопки. */

  /* --- ИЗМЕНЕНИЯ ЗДЕСЬ --- */
  
  /* 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 [class*="-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;
  flex-direction: row;
  justify-content: space-between;
  gap: 8px; 
  overflow: hidden;
  max-width: 45rem;
  margin: 0 auto;
}

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

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

  /* Owner: long sutta titles wrapped to a second line and threw off the row's layout — was a
     2-line -webkit-line-clamp on the container/link while .sutta-name (below) separately forced
     single-line nowrap, two conflicting truncation rules fighting each other. One line only,
     split down the middle (max-width:49% each side, unchanged), ellipsis for whatever doesn't
     fit — matching what was asked ("не было бы переноса на след. строку"). #previous2/#next2
     (bottom copy, after #sutta) get the exact same treatment — same bug, just wasn't visible
     until that copy actually had markup to render into (see search/index.html). */
  #previous,
  #next,
  #previous2,
  #next2 {
    max-width: 49%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  #previous a,
  #next a,
  #previous2 a,
  #next2 a {
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 100%;
    vertical-align: middle;
  }

  /* Стиль для названия сутты (одна строка + обрезка) */
  .sutta-name {
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }


  .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-icon3 {
    margin-top: -3px; 
  margin-left: 0px;	
    height: 25px; 
    width: 22px;
  }


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



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

[class*="-lang"] {
  display: block;       /* Forces the element to take full width */
  margin-bottom: 4px;   /* Adds a little breathing room between languages */
}


  .column-view [class*="-lang"] {
    display: inline-block;
    vertical-align: top;
    text-align: left;
    box-sizing: border-box;
    word-wrap: break-word;
  }

  /* Старая раскладка (перевод прямым соседом .pli-lang, без .right-column) — сейчас
     megareader.js всегда оборачивает переводы в .right-column (см. ниже), это правило на
     случай прямого соседства без обёртки. */
  .column-view .pli-lang:not(:empty) + [class*="-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 [class*="-lang"] {
    display: block;
    width: 100%;
    margin: 0; /* Убираем все внешние отступы */
    padding: 0;
  }

  /* Owner: with 2+ translators/languages stacked in right-column, margin:0 above left them
     touching with zero gap — "merge into one pile". Gap only BETWEEN blocks, not before the
     first (right after the Pali line). */
  .column-view .right-column [class*="-lang"] + [class*="-lang"] {
    margin-top: 0.5em;
  }

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

  /* Скрытие пустых */
  .column-view [class*="-lang"]:empty {
    display: none;
  }

  /* Columns need two texts: with the translation switched off (the Pāḷi/Рус pill, Pāḷi only), the
     Pāḷi takes the whole width instead of the left half with an empty right one (owner 2026-11-13, sn12.63 in the app:
     «режим для двух колонок не работает для одного текста»). Whatever path left .column-view on. Not the editions grid,
     whose columns are the editions themselves. The reader and the search results' quotes alike (the pill hides there too). */
  /* (no :has() test for a line without a translation: checked for every Pāḷi line of a 15k-element page on each style
     recalc, 2026-11-14) */
  .column-view.hide-russian.hide-english:not(.dg-grid) .pli-lang:not(:empty) {
    width: 100%;
    max-width: none;
    padding-right: 0;
  }
  .column-view.hide-russian.hide-english:not(.dg-grid) .right-column { display: none; }

  /* Pali editions (megareader.js editionLines, owner 2026-10-29..31). Lines: one line per chosen edition, a small
     quiet plate with its short name at the start, "—" where the edition lacks the line, no plates on headings.
     One other edition: its text, a line it lacks taken from Mahāsaṅgīti and plated "MS". The plates are the
     translators' .dg-tag (search/css/home.css), one look for both. */
  .dg-ed-line { display: block; position: relative; }   /* relative: each line's copy marker (.copyLink-start, left:-1em) sits at its own line */
  .dg-ed-line + .dg-ed-line { margin-top: .2em; }
  .dg-ed-line.is-empty { display: none; }
  .dg-ed-line.is-gap { color: var(--dg-text-muted, #8a8a8f); }
  /* The titles' plates in one column with the text's, at the left edge (owner 2026-11-01: «чтобы они все были на уровне…
     ровно и одинаково с самого начала текста»): centred, each plate sat before its own title wherever it began. The
     title stays centred between equal side paddings; the plate is centred on the title's first line (--dg-line: that
     line's height, a registered length so 1lh is the title's, not the small plate's). */
  #sutta:not(.column-view) :is(header, h1) .dg-tag { position: relative; padding-inline: 2.6rem; --dg-line: 1lh; }
  #sutta:not(.column-view) :is(header, h1) .dg-tag::before { position: absolute; left: 0; top: calc(var(--dg-line) / 2 - .8em); margin: 0; }
  /* ...and the speakers in a column right after the plates, all the size of the Pali's (owner 2026-11-01: «плашки идут,
     потом динамики… все одинаково, как самый первый»): a translation's smaller title made its speaker smaller */
  #sutta:not(.column-view) :is(header, h1) .dg-tag:has(> .title-play-btn) { padding-inline: 4.6rem; }
  #sutta:not(.column-view) :is(header, h1) .dg-tag > .title-play-btn { position: absolute; left: 2.7rem; bottom: auto; margin: 0;
    font-size: 1.05rem; top: calc(var(--dg-line) / 2 - .5em); }
  #sutta:not(.column-view) :is(header, h1) .dg-tag > .title-play-btn > .title-svg-icon { vertical-align: top; }
  .dg-ed-note { font-size: .85em; color: var(--dg-text-muted, #8a8a8f); margin: 0 0 1em; }
  /* "Differences" between prev and next (megareader.js) */
  #dg-diff-btn { all: unset; flex: none; margin: 0 auto; align-self: center; display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
    font: 600 13px/1.4 var(--dg-font, Lato, system-ui, sans-serif); color: var(--dg-text, inherit); white-space: nowrap; }
  #dg-diff-btn[aria-pressed="true"] .dg-tgl { background: #42426a; border-color: #42426a; }   /* the contents button's dark blue (search/index.html --dark-blue) */
  #dg-diff-btn[aria-pressed="true"] .dg-tgl::after { transform: translateX(14px); }
  #dg-diff-btn:focus-visible { outline: 2px solid var(--dg-tblue, #3434be); outline-offset: 3px; border-radius: 6px; }
  #dg-diff-btn[hidden] { display: none; }
  /* "Pāḷi MS · BJT · SR · PTS" ran into "Пер. о с Пали" on one line (f3-ultra's review) */
  .dg-eds-byline > p > .pli-lang { margin-right: 1.2em; }
  /* "Show differences": the words most of the shown texts do not have (megareader.js markEditionDiffs) */
  /* the marks' look: megareader.js (#dg-ed-diff-style), shipped with the script so a cached stylesheet cannot leave them stuck */


  /* Column view with three texts or more (megareader.js useGrid): one grid column per text - editions first, then
     each translation - a header with the full names pinned under the site header, and on a phone the text scrolls
     sideways inside the article (the page itself and the header stay screen-wide; edge swipes keep working). The
     header lives outside the article and follows its scroll (megareader.js, the capturing scroll listener). */
  #sutta.column-view.dg-grid {
    max-width: none;
    --dg-colw: min(16rem, 78vw);
    --dg-colgap: 1.4rem;
    --dg-gridw: calc(var(--dg-ncols) * var(--dg-colw) + (var(--dg-ncols) - 1) * var(--dg-colgap));
  }
  /* the scroll box reaches 1.1em into the left margin: the first column's copy markers (left:-1em) are not cut off */
  /* a range text (an1.11-20) holds its suttas in section.range > article: that section is the one scroll box, or the
     page itself scrolled sideways with the site header (owner 2026-11-07, tablet, an1.11-20 in columns) */
  #sutta.column-view.dg-grid > article,
  #sutta.column-view.dg-grid > section.range { overflow-x: auto; overscroll-behavior-x: contain; padding-left: 1.1em; margin-left: -1.1em; }
  /* content-visibility:auto on the paragraphs (index.css) clips painting to their own box: the columns past the screen
     width stayed blank while scrolled to. The paragraph is made as wide as its grid instead, so it keeps skipping the
     layout of what is off the screen: switching it off for the whole text cost ~0.4 s per layout (Ultra 2026-11-01). */
  /* ...and a verse's, inside blockquote.gatha: its columns past the screen stayed blank (owner 2026-11-05, Trello BPYP00Xv) */
  #sutta.column-view.dg-grid > article > p,
  #sutta.column-view.dg-grid > article > blockquote p,
  #sutta.column-view.dg-grid > section.range > article > p,
  #sutta.column-view.dg-grid > section.range > article > blockquote p { min-width: calc(var(--dg-gridw) + 2em); }   /* + its left padding (index.css), border-box */
  #sutta.column-view.dg-grid span[id],
  #sutta.column-view.dg-grid .dg-cols-head-in {
    display: grid;
    grid-template-columns: repeat(var(--dg-ncols), minmax(var(--dg-colw), 1fr));
    column-gap: var(--dg-colgap);
    min-width: var(--dg-gridw);
    align-items: start;
  }
  #sutta.column-view.dg-grid span[id] > .pli-lang { width: auto; max-width: none; padding: 0; grid-column: var(--c, 1); }   /* --c: its place (megareader.js dgColOrder) */
  #sutta.column-view.dg-grid.dg-eds span[id] > .pli-lang { display: contents; }
  /* ...and a box that is not drawn paints no background: the tapped line's highlight (.active-word on that .pli-lang) went
     on the edition lines it holds (owner 2026-11-01: no highlight in the columns with editions, fine with one or two) */
  #sutta.column-view.dg-grid.dg-eds span[id] > .pli-lang > .dg-ed-line { transition: background-color 260ms ease-in-out; }   /* fades in and out as one, like [class*="-lang"] everywhere */
  #sutta.column-view.dg-grid.dg-eds span[id] > .pli-lang.active-word > .dg-ed-line { 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 #sutta.column-view.dg-grid.dg-eds span[id] > .pli-lang.active-word > .dg-ed-line { background-color: rgba(var(--bs-primary-rgb), 0.25); }
  #sutta.column-view.dg-grid .dg-ed-line { grid-column: var(--c); grid-row: 1; margin: 0; }
  /* a title row's speaker sits inside its first edition line (reader/common.js), on the title's line, lines and grid alike */
  /* the header names every column: no plates in the grid (editions' nor translators') */
  #sutta.column-view.dg-grid .dg-ed-line::before, #sutta.column-view.dg-grid .right-column > .dg-tag::before { display: none; }
  #sutta.column-view.dg-grid.dg-eds span[id] > .pli-lang > font.variant { display: block; grid-column: 1 / -1; grid-row: 2; font-size: .85em; }
  #sutta.column-view.dg-grid.dg-eds span[id] > .pli-lang > font.variant > br:first-child { display: none; }
  #sutta.column-view.dg-grid span[id] > .right-column { display: contents; }
  #sutta.column-view.dg-grid span[id] > .right-column > [class*="-lang"] { grid-column: var(--c); grid-row: 1; width: auto; margin: 0; padding: 0; position: relative; }
  .dg-cols-head { display: none; }
  /* ...but not under the phone's status bar: in the apps the page runs edge to edge (html margin-top = the inset, dg-apps
     build-assets.js dg-edge) and a pin at the viewport's top 0 sat behind the bar - the names "did not stick" (owner
     2026-11-01, two phones; the browsers have no inset and the emulator draws below its bar) */
  body.dg-header-hidden #sutta.column-view.dg-grid > .dg-cols-head { transform: translateY(calc(-1 * var(--dg-cols-top, var(--dg-stack-height, 65px)) + max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px)))); }
  /* the body's own clip (overflow-x: clip, home.css) cut that shadow at the body's side margins; html still clips at the screen */
  body:has(#sutta.column-view.dg-grid) { overflow-x: visible; }
  #sutta.column-view.dg-grid > .dg-cols-head {
    display: block;
    position: sticky;
    top: var(--dg-cols-top, var(--dg-stack-height, 65px));   /* megareader.js placeColsHead */
    z-index: 3;
    /* one block with the site header: up by the header's height on hide, with its transition (search/index.html
       transform .25s ease); the shadow is a strip of the page's colour above, over the header's longer travel */
    transition: transform .25s ease;
    /* ...and past both sides too, with its line: the text scrolled under it showed in the gaps at the screen's edges
       and above it (owner 2026-11-01: «с запасом… чтобы не показалось никаких дырок»). Spread S moved up by S: wider
       and taller, never lower. A shadow is not clipped by the box's own overflow and adds no scroll width. 96px covers
       the body's side margins and the header's travel; a screen-sized spread (100vw) on this pinned box made the page
       scroll heavily under a finger (owner 2026-11-01: «еле-еле двигается… лагает»). */
    box-shadow: 0 -97px 0 96px var(--dg-page, #fff), 0 -96px 0 96px var(--dg-border, rgba(127, 127, 127, .25));
    overflow: hidden;
    background: var(--dg-page, #fff);
    border-bottom: 1px solid var(--dg-border, rgba(127, 127, 127, .25));
    margin-bottom: .6rem;
  }
  /* the header names every column: the byline above it ("Pāḷi MS · BJT · SR", the translators) would say it twice */
  #sutta.column-view.dg-grid > #trn { display: none; }
  #sutta.column-view.dg-grid .dg-cols-head-in {
    align-items: center;   /* the last cell's − + buttons are taller: the names stay on one line */
    font: 700 .72rem/1.35 var(--dg-font, Lato, system-ui, sans-serif);
    letter-spacing: .03em;
    color: var(--dg-text-muted, #808086);
    padding: .4rem 0;
  }
  .dg-col-cell { display: flex; align-items: center; gap: 6px; min-width: 0; touch-action: pan-y; }
  .dg-col-cell > [data-col] { all: unset; touch-action: pan-y; /* all:unset dropped the cell's pan-y: a finger drag was a pan, cancelled */ flex: 0 1 auto; min-width: 0; cursor: grab; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dg-col-cell > [data-col]::after { content: " ▾"; opacity: .6; }
  .dg-col-cell > [data-col]:hover, .dg-col-cell > [data-col][aria-expanded="true"] { color: var(--dg-text, inherit); }
  .dg-col-cell.is-drag { opacity: .35; }
  .dg-col-cell.is-drop { box-shadow: inset 3px 0 0 var(--dg-accent, #14967b); }
  .dg-col-cell.is-drop-end { box-shadow: inset -3px 0 0 var(--dg-accent, #14967b); }
  .dg-col-pm { margin-left: auto; display: inline-flex; gap: 4px; flex: none; }
  /* on every column now: quiet grey, darker on hover (owner 2026-10-31: «чуть посерее, менее броскими») */
  .dg-col-pm > button { all: unset; width: 1.3rem; height: 1.3rem; line-height: 1.25rem; text-align: center; border-radius: 50%; cursor: pointer;
    border: 1px solid var(--dg-border, rgba(127,127,127,.25)); font-size: .85rem; color: var(--dg-text-muted, #8a8a8f); opacity: .75; }
  .dg-col-pm > button:hover, .dg-col-pm > button[aria-expanded="true"] { opacity: 1; color: var(--dg-text, inherit); background: var(--dg-surface-hover, rgba(127,127,127,.12)); }
  .dg-colmenu { position: fixed; z-index: 1000; min-width: 12rem; max-width: min(20rem, 90vw); max-height: 60vh; overflow-y: auto;
    padding: 4px; border-radius: 10px; background: var(--dg-surface, #fff); border: 1px solid var(--dg-border, rgba(127,127,127,.3));
    box-shadow: 0 8px 26px rgba(0, 0, 0, .22); font: 13.5px/1.3 var(--dg-font, Lato, system-ui, sans-serif); }
  .dg-colmenu button { display: flex; justify-content: space-between; gap: 10px; width: 100%; border: 0; background: none; color: var(--dg-text, inherit);
    text-align: left; padding: 8px 10px; border-radius: 7px; cursor: pointer; font: inherit; }
  .dg-colmenu button:hover { background: var(--dg-surface-hover, rgba(127,127,127,.12)); }
  .dg-colmenu button[aria-current="true"] { color: var(--dg-accent, #14967b); font-weight: 700; }
  .dg-colmenu button small { color: var(--dg-text-muted, #808086); font-size: 11px; }
  /* the two groups (Pali, translations), each folds by its title (home.js colMenuOpen) */
  .dg-colmenu .dg-colmenu-gh { position: sticky; top: -4px; z-index: 1; background: var(--dg-surface, #fff); color: var(--dg-text-muted, #808086);
    font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 8px 10px 4px; border-radius: 0; }
  .dg-colmenu .dg-colmenu-gh:hover { background: var(--dg-surface, #fff); color: var(--dg-text, inherit); }
  .dg-colmenu-gh > i { font-style: normal; transition: transform .15s ease; }
  .dg-colmenu-group + .dg-colmenu-group { border-top: 1px solid var(--dg-border, rgba(127,127,127,.25)); margin-top: 4px; }
  .dg-colmenu-group.is-folded .dg-colmenu-items { display: none; }
  .dg-colmenu-group.is-folded .dg-colmenu-gh > i { transform: rotate(-90deg); }

  /* Ширина контейнера — #sutta.column-view (ID+класс, специфичность 110), НЕ .sutta.column-view
     (только классы, 20): index.css/rus-multi.css задают базовую ширину через #sutta{max-width:
     45rem} (специфичность 100, тот же приём, что и на проде) — чисто классовый селектор здесь
     проигрывал ему всегда, независимо от .column-view, поэтому 2-колоночный режим на десктопе
     никогда реально не расширялся (владелец: "можно шире, см. прод"). На проде (read/css/
     uiextra.css) этот же override — #sutta.column-view, тот же приём, здесь разошлось при
     переносе. */
  #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;
  /* Поднимали до 1090 (выше дровера) — откат: владелец проверил живьём, кнопка налезала на
     пункты открытого дровера и мешала по ним кликать. Обратно ниже дровера. */
  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;
      bottom: 0.2em;
      -webkit-tap-highlight-color: transparent;
      /* Owner: this invisible end-of-line marker (opacity:0, but still a real inline-block box)
         was consuming real layout width — since browsers won't split an inline-block across a
         line break, it could tip a line over its available width and force a wrap the matching
         translation paragraph (with no such marker) wouldn't take, misaligning Pali/translation
         line breaks. width:0 + overflow:visible removes it from the width calculation entirely
         while letting its ::before glyph still paint past the zero-width box, same visual spot.
         ::after's glow highlight below switches from left:0/right:0 (relative to this box, which
         would now also compute to zero width) to an explicit width instead. */
      width: 0;
      overflow: visible;
    /*   touch-action: manipulation;
      user-select: none;
      -webkit-user-select: none;
      -webkit-touch-callout: none; */
  }


  .copyLink::after {
      content: "";
      position: absolute;
      left: -0.2em;
      width: 1.2em;
      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;
        
          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;
     
      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;
     
      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;
      }
  }

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


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

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

  .copyLink {
        opacity: 0;
        cursor: pointer;
      transition: opacity 0.3s ease;
  }

  .copyLink-start {
      position: absolute;
      top: -0.2em;
      left: -1.0em;
      /* The start marker carries BOTH classes (copyLink copyLink-start), so it inherits
         .copyLink's `bottom: 0.2em` above (a nudge meant for the inline-block END marker).
         On an absolutely positioned box `top` + `bottom` together stretch it to the full
         height of the segment, and the ::after glow then paints as a bar down the whole
         block instead of a one-line badge like the search results' .quoteLink-start.
         `bottom: auto` keeps the box glyph-sized; `top` alone does the nudge here. */
      bottom: auto;

      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;
  }


/* Базовое состояние для ссылок: прозрачность 0 и плавный переход */
.copyLink .copyLink-start {
    opacity: 0;
    transition: opacity 0.4s ease-in-out; /* 0.4 секунды — достаточно плавно и приятно */
}

@media (min-width: 992px) {
  [class*="-lang"]:hover .copyLink-start,
  .variant:hover .copyLink-start {
      /* Цвет с прозрачностью 30% (0.3) */
    opacity: 0.9;
  }
}



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

  /* apple-design audit: large display text reads too loose at this size with default (0)
     tracking; tighten it slightly, same discipline Apple applies to display type. */
  h1.sutta-title {
    letter-spacing: -0.01em;
  }

.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);
  */
/* Класс для подсветки текущего предложения при чтении */

/* Реальное скрытие языка в тексте — раньше такого правила для .sutta не было вообще
   (было только для #smart-toc-panel ниже), поэтому переключатель Pāḷi/Рус ничего не прятал.
   [class*="-lang"] работает для любого кода языка (ru-lang, en-lang, ...), не только rus-lang/eng-lang.
   Скрываем только .quote (сегменты текста, см. megareader.js) — не заголовок/byline
   переводчика, у них того же .pli-lang, но это не цитата текста. */
.sutta.hide-pali .pli-lang.quote {
    display: none !important;
}
.sutta.hide-english [class*="-lang"].quote:not(.pli-lang),
.sutta.hide-russian [class*="-lang"].quote:not(.pli-lang) {
    display: none !important;
}

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

/* 2. СПЕЦИАЛЬНОЕ правило для стихов: убираем отступ */
.sutta.hide-pali .verse-line [class*="-lang"]:not(.pli-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(100 * var(--dg-vh, 1vh) - 80px); /* --dg-vh: vh without the page zoom (home.css) */ 
    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;

    font-family: sans-serif;
    font-size: 1rem;
    color: #535353;
}

#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;
    
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
}

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

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

.dark #smart-panel {
    background-color: #333;
    border-color: #555;
    /* Цвет шрифта для темной темы */
    color: #909090;
}

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

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

/* Новые классы для замены инлайн-стилей из JS */
.hidden-toc {
    display: none !important;
}

.toc-item span {
    cursor: pointer;
}


#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(100 * var(--dg-vh, 1vh) - 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;
}

.smart-btn {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    color: inherit;
}

.smart-btn img {
    flex-shrink: 0;
}



/* Специальный зеленый варнинг для 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);
}

[class*="-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;
  /* Откат до 99 — см. комментарий у #language-button выше: 1090 (выше дровера) перекрывало
     пункты открытого меню. */
  z-index: 99;
  /* Matches #language-button's rendered height (38px) — see same note in search/index.html. */
  width: 38px;
  height: 38px;

  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 {
  /* 90 + 38 (button, border included) + 8 (gap) — was 132 for the old 30px/34px button. */
  right: 136px;
}

.dynamic-tts-btn:hover {
  opacity: 1 !important;
  transform: scale(1.1) !important;
}

.dynamic-tts-btn img {
  width: 18px;
  height: 18px;
  display: block;
  margin: 0 auto;
  transform: none !important;
  /* Same fade as #arrowImg (uiextra.css) — matches the pill's own muted look instead of
     standing out as a solid black glyph against it. */
  opacity: 0.8;
}
.dynamic-tts-btn:hover img { opacity: 1; }

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

/* apple-design audit: on narrow screens, this fixed bottom-right cluster (play/language
   toggle, 38px, bottom:30px) permanently covered the last lines of the page with no way to
   scroll them clear. Reserve a safe zone so content always clears the buttons.
   Was on #sutta — right when #sutta really was the last element. Now hr/#navigation
   (previous2/next2)/.links-area (footer icons) all follow it (search/index.html), so #sutta's
   own padding just pushed an oversized gap in front of that hr instead of protecting anything
   — .links-area is the real last element now, the safe zone belongs there. */
@media (max-width: 600px) {
  .links-area {
    padding-bottom: 96px;
  }
}

/* Владелец: "почему они такие разношёрстные по цвету, можно сделать одинаковые?" — .links-area's
   footer icons (history/pdf/memo/table-columns/copy/makelist/dharmachakra, plus a couple of
   raster favicons) are each an independently authored SVG/PNG file with its own baked-in color;
   nothing ever unified them, and color/fill in CSS has no effect on a rasterized <img> or an
   externally-referenced SVG — only filter reaches those pixels. brightness(0) crushes ANY source
   color to black regardless of hue, then invert(X) dials that back to the site's existing flat
   icon-gray (.gray-icon, extrastyles.css: #989898 ≈ invert(0.6) on black) — same recipe
   #smart-gear-btn already uses for its own dark-mode icon, just above. Loaded last of the
   reader's three stylesheets (index.css/rus-multi.css/uiextra.css), so this wins their cascade.
   logo4nt_plain.png is excluded: an actual partner wordmark, not a generic feature glyph —
   recoloring someone else's logo reads as defacing it, not as "joining our icon language". */
.links-area img:not([src*="logo4nt"]),
.links-area svg {
  filter: brightness(0) invert(0.6);
}
.dark .links-area img:not([src*="logo4nt"]),
.dark .links-area svg {
  filter: brightness(0) invert(0.75);
}

.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(100 * var(--dg-vh, 1vh) - 80px); /* --dg-vh: vh without the page zoom (home.css) */
    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; }

/* Footer export icon + its PDF/MD menu. The wrap keeps the menu anchored to the icon; the menu
   pops ABOVE it because the footer sits near the bottom of the page. */
.reader-export-wrap { position: relative; display: inline-flex; }
#reader-export-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.15);
    padding: 4px;
    z-index: 1000;
    min-width: 72px;
}
#reader-export-menu a {
    display: block;
    padding: 6px 14px;
    border-radius: 6px;
    color: #333;
    text-decoration: none;
    font-family: sans-serif;
    font-size: 14px;
    text-align: center;
    cursor: pointer;
}
#reader-export-menu a:hover { background-color: rgba(0,0,0,0.06); }
.dark #reader-export-menu { background: #333; border-color: #555; }
.dark #reader-export-menu a { color: #e0e0e0; }
.dark #reader-export-menu a:hover { background-color: rgba(255,255,255,0.1); }

/* Адаптация для мобильных как у шестеренки */
@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(100 * var(--dg-vh, 1vh) - 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;
}


/* Адаптация оглавления для мобильных экранов по ширине (портретный режим) */
@media (max-width: 600px) {
    #smart-toc-panel {
        position: fixed; /* Отвязываем от контейнера */
        top: 60px; /* Отступ сверху под кнопкой */
        right: max(20px, env(safe-area-inset-right, 0px)); /* Прижимаем вплотную к правому краю экрана */
        max-width: calc(100vw - 40px); /* Гарантируем, что панель уместится по ширине с аккуратными отступами */
    }
}


.lang-2nd {
  color: #666;
}

/*меню ссылок copylink*/

/* --- СТИЛИ ВЫПАДАЮЩЕГО МЕНЮ (НАЖАТИЕ НА ✦) --- */
#segment-context-menu {
  position: absolute;
  z-index: 100000;
  background: #ffffff;
  border: 1px solid #ccc;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-width: 160px;
  
  /* Добавляем это для стабильности */
  margin-top: 8px; 
}


.dark #segment-context-menu {
  background: #333333;
  border-color: #555555;
  color: #e0e0e0;
}

.segment-menu-hidden {
  display: none !important;
}

#segment-context-menu ul {
  list-style: none;
  margin: 0;
  padding: 8px 0;
}

#segment-context-menu li {
  padding: 10px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: sans-serif;
  font-size: 1rem;
}

#segment-context-menu li:hover {
  background: rgba(0,0,0,0.05);
}

.dark #segment-context-menu li:hover {
  background: rgba(255,255,255,0.1);
}

.menu-icon {
  width: 16px;
  height: 16px;
  opacity: 0.5; /* Делает черные иконки серыми */
}

.dark .menu-icon {
  filter: invert(1);
  opacity: 0.7; /* Светло-серые иконки в темной теме */
}

@media (max-width: 768px) {
  .sutta {
    padding-left: 5px;
  }
}

/* Общие стили для скрытия дублирующих иконок во втором языке */
.trn-title-icon { 
    display: none !important; 
}

.sutta.hide-pali .trn-title-icon { 
    display: inline-block !important; 
}

.title-play-btn {
    display: inline-block;
    vertical-align: middle;
    font-size: 1.1em;
    line-height: 1;
    margin-right: 8px;
    position: relative;
    bottom: 0.2em;
    user-select: none;
    cursor: pointer;
}

/* === ССЫЛКА В СТРОКЕ 0.1 === */
[id="0.1"] .copy-Link-special {
    display: inline-block !important;
    opacity: 1 !important;
    margin-left: 8px;
    text-decoration: none;
}

[id="0.1"] .copy-Link-special::before {
    content: none !important;
}

/* Сохраняем логику скрытия/показа для оригинальной ссылки */
[id="0.1"] .copy-Link-special.trn-title-icon {
    display: none !important;
}

.sutta.hide-pali [id="0.1"] .copy-Link-special.trn-title-icon {
    display: inline-block !important;
}

.title-svg-icon {
    width: 1em;
    height: 1em;
    opacity: 0.5;
    vertical-align: -0.1em;

    transition: none !important;
    animation: none !important;
}

.title-play-btn:hover .title-svg-icon,
.copy-Link-special:hover .title-svg-icon {
    opacity: 0.8;
}

.dark .title-svg-icon {
    filter: invert(1);
    opacity: 0.7;
}

.dark .title-play-btn:hover .title-svg-icon,
.dark .copy-Link-special:hover .title-svg-icon {
    opacity: 1;
}

/* ==========================================================================
   Шапка ридера: домик — поле с лупой внутри — бургер.
   Собрана так же, как на странице поиска (search/index.html), чтобы обе страницы
   выглядели одинаково. Домик приехал сюда из ряда иконок #form-div, кнопка отправки
   перестала быть отдельной подписанной кнопкой справа от поля.
   ========================================================================== */
.dg-reader-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: nowrap;
  margin-bottom: 8px;
}

/* Кнопки шапки без рамки и заливки — иконка читается лучше, чем «пилюля» вокруг неё. */
.dg-reader-hero .dg-plain-btn {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
  color: var(--dark-gray);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.dg-reader-hero .dg-plain-btn:hover,
.dg-reader-hero .dg-plain-btn:focus-visible { color: var(--off-black); }
.dark .dg-reader-hero .dg-plain-btn { color: var(--off-white); }
.dark .dg-reader-hero .dg-plain-btn:hover,
.dark .dg-reader-hero .dg-plain-btn:focus-visible { color: #fff; }

/* Домик крупнее остальных — главная точка возврата. */
/* Домик — <div id="home-button"> со вложенной <a> (id и вложенность нужны обработчикам в
   settings.js/megareader.js и смарт-панели), поэтому кликабельной делаем именно ссылку. */
.dg-reader-hero .dg-home-btn a { display: inline-flex; align-items: center; }
.dg-reader-hero .dg-home-btn img { width: 30px; height: 30px; }
.dark .dg-reader-hero .dg-home-btn img { filter: invert(1); }

/* Поле поиска: лупа лежит ПОВЕРХ поля слева, поле освобождает под неё отступ. */
.dg-reader-hero .dg-search-field {
  position: relative;
  display: block;
  flex: 0 1 380px;
  min-width: 0;
}
/* Селектор с #form.ui-widget — не для красоты: выше в этом же файле есть
   "#form.ui-widget #paliauto, #paliauto.ui-autocomplete-input, #paliauto { padding-left: 10px
   !important }". Там ДВА id против одного, поэтому и !important, и более поздняя позиция в
   файле не помогали — правило проигрывало по специфичности, отступ оставался 10px, и текст
   начинался на 144px при лупе, кончающейся на 163px (наезд 19px, замерено). Уравниваем
   количество id и добавляем свой класс, чтобы выиграть. */
#form.ui-widget .dg-search-field #paliauto,
.dg-reader-hero .dg-search-field #paliauto {
  width: 100%;
  margin: 0;
  padding-left: 42px !important;
}
.dg-reader-hero .dg-search-field #searchbtn {
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  /* Выше поля: непрозрачный инпут иначе закрывает иконку собой (ровно эта ошибка была на
     странице поиска — иконка существовала, но её не было видно, и клик уходил в поле). */
  z-index: 12;
  width: 34px;
  height: 34px;
  border-radius: 50%;
}
.dg-reader-hero .dg-search-field #searchbtn:hover { background: rgba(128, 128, 128, 0.18); }
/* Линза справа, ручка влево-вниз. */
.dg-reader-hero .dg-search-icon { transform: scaleX(-1); }

/* === MEMORIZE MODE (mode-table.json "mem") — ported from prod's read/js/memorize.js + its
   inline style block and read/css/uiextra.css's .mem-trigger/.mem-bubble rules. Scoped under
   body.dg-mode-mem (set by megareader.js only while this mode is active) so the bigger
   .pli-lang/.copyLink sizing doesn't leak into every other reading mode. */
body.dg-mode-mem .pli-lang {
  font-size: 1.4em !important;
}
/* a tablet's base is 1.2, a phone's 1.1: the same 1.4em came out ~10% bigger than on a phone, too big for the spaced
   first letters (owner 2026-11-06, an10.69 on his tablet) - the phone's size there */
html.dg-tablet body.dg-mode-mem #sutta article .pli-lang {
  font-size: 1.25em !important;
}
body.dg-mode-mem .byline .pli-lang {
  font-size: 1em !important;
}
body.dg-mode-mem .copyLink {
  font-size: 0.8em !important;
}
body.dg-mode-mem .copyLink:not(.copyLink-start) {
  bottom: 0em !important;
  right: -0.6em !important;
}
body.dg-mode-mem .mem-bubble::selection {
  background: transparent;
}

/* === DEVANAGARI MODE (mode-table.json "devanagari", dualScript) — the converted script
   (.pli-lang, main line) reads visually smaller than Latin at the same font-size, so bump it
   up to match; the ISO/Latin second line (".greyedout", not .pli-lang) stays at 1em. Scoped
   under body.dg-mode-dev (set by megareader.js only while this mode is active). */
body.dg-mode-dev .pli-lang {
  font-size: 1.2em !important;
}
body.dg-mode-dev .byline .pli-lang {
  font-size: 1em !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;
  pointer-events: auto;
  cursor: pointer;
  transform: translateY(-100%);
  margin-top: -8px;
  opacity: 0;
  transition: opacity 0.2s ease-out;
}
@media (max-width: 400px) {
  .mem-bubble { max-width: 85vw; }
}
.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;
}

/* the titles' plates (#sutta header .dg-tag): the height of the title's own line, computed there; top level, as @property must be */
@property --dg-line { syntax: '<length>'; inherits: true; initial-value: 24px; }

/* The quiet line under the text (Principles · Rationale · Glossary · 6 Pali editions, and MP3): right under the tools row, with
   the room the floating buttons need (to top, Pāli/En) below it rather than above it - the tools row's 96px bottom margin stood
   between them and the line sat under the buttons in the app (owner 2026-11-12, DG 612/613: «не юзабельно», «слишком низко»).
   Larger, fingertip-sized links. The line's own style is inline (core/search-core.js principlesLineHtml). */
.links-area:has(+ .dg-principles) { margin-bottom: .4em !important; }
.dg-principles { font-size: .9em !important; opacity: .85 !important; margin-top: .4em !important; margin-bottom: 1em !important; }
/* the app has no site footer below the line: the floating buttons' room goes there (html.dg-app: the app's page) */
html.dg-app .dg-principles { margin-bottom: calc(6rem + env(safe-area-inset-bottom, 0px)) !important; }
.dg-principles a { display: inline-block; padding: .3em .2em; }
.dg-principles .dg-audio-mp3 { display: inline-block; margin-top: .2em; }
