/* TGL — правила поиска v2. Только то, чего нет в sao-ui.css / adaptation.css.
   Цвета — переменные Bootstrap, поэтому обе темы работают без отдельных правил. */

/* Чипы слов */
.tgl-chip { display: inline-flex; align-items: center; gap: .25rem; max-width: 100%; height: 28px; padding: 0 .25rem 0 .6rem;
  border: 1px solid var(--bs-primary-border-subtle); background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis);
  border-radius: 6px; font-size: .875rem; line-height: 1; white-space: nowrap; cursor: pointer; user-select: none; }
.tgl-chip:hover { border-color: var(--bs-primary); }
.tgl-chip > .tgl-chip-t { overflow: hidden; text-overflow: ellipsis; }
.tgl-chip-part::after { content: '*'; font-weight: 700; margin-left: -.15rem; }
.tgl-chip-n { font-size: .72rem; font-variant-numeric: tabular-nums; color: var(--bs-secondary-color); padding: 0 .15rem; }
.tgl-chip-zero .tgl-chip-n { color: var(--bs-warning-text-emphasis); }
.tgl-chip-x { border: 0; background: none; padding: 0; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center;
  color: inherit; opacity: .55; border-radius: 4px; }
.tgl-chip-x:hover { opacity: 1; background: rgba(127, 127, 127, .18); }
.tgl-chip-not { border-color: var(--bs-danger-border-subtle); background: var(--bs-danger-bg-subtle); color: var(--bs-danger-text-emphasis); }
.tgl-chip-not:hover { border-color: var(--bs-danger); }
.tgl-chip-sm { height: 22px; padding: 0 .45rem; font-size: .78rem; cursor: default; }
.tgl-chip-more { background: transparent; color: var(--bs-secondary-color); border-color: var(--bs-border-color); }
.tgl-chip-list { background: var(--bs-tertiary-bg); color: var(--bs-body-color); border-color: var(--bs-border-color); gap: .3rem; }
.tgl-chip-flash { animation: tgl-flash 1.2s ease-out; }
@keyframes tgl-flash { 0% { box-shadow: 0 0 0 4px rgba(124, 58, 237, .45); } 100% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0); } }

/* Поле с чипами: выглядит как form-control, ввод прямо в нём */
.tgl-chipbox { display: flex; flex-wrap: wrap; gap: .375rem; align-items: center; min-height: 44px; padding: .4rem .5rem;
  border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); background: var(--bs-body-bg); cursor: text; }
.tgl-chipbox:focus-within { border-color: #b197fc; box-shadow: 0 0 0 .25rem rgba(124, 58, 237, .18); }
.tgl-chip-input { flex: 1 0 180px; min-width: 120px; border: 0; outline: 0; background: transparent; color: var(--bs-body-color); font-size: .875rem; height: 28px; }
.tgl-chip-input::placeholder { color: var(--bs-secondary-color); }

/* Группа условий */
.tgl-group { border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); padding: .75rem; background: var(--bs-body-bg); }
.tgl-group-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.tgl-group-n { width: 22px; height: 22px; border-radius: 6px; background: var(--bs-tertiary-bg); color: var(--bs-secondary-color);
  font-size: .75rem; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 22px; }
.tgl-group-label { border: 0; background: transparent; font-weight: 600; padding: .1rem .25rem; border-radius: 4px; min-width: 60px; max-width: 260px; color: var(--bs-body-color); }
.tgl-group-label:hover { background: var(--bs-tertiary-bg); }
.tgl-group-label:focus { outline: 0; background: var(--bs-tertiary-bg); box-shadow: 0 0 0 2px rgba(124, 58, 237, .35); }
.tgl-inline-select { display: inline-flex; align-items: center; gap: .35rem; font-size: .875rem; color: var(--bs-secondary-color); }
.tgl-mode { border: 1px solid var(--bs-border-color); background: var(--bs-body-bg); color: var(--bs-body-color); border-radius: 6px;
  font-size: .8125rem; padding: .1rem .5rem; height: 26px; }
.tgl-mode:hover { border-color: var(--bs-primary); }
.tgl-sugg { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-top: .5rem; font-size: .8rem; }
.tgl-sugg-btn { border: 1px dashed var(--bs-border-color); background: transparent; color: var(--bs-secondary-color); border-radius: 6px; height: 24px; padding: 0 .45rem; font-size: .8rem; }
.tgl-sugg-btn:hover { border-color: var(--bs-primary); color: var(--bs-primary-text-emphasis); }

/* Связка между группами: кликабельная «И / ИЛИ» на линии */
.tgl-join { position: relative; display: flex; align-items: center; justify-content: flex-start; gap: .5rem; height: 40px; padding-left: 1.1rem; }
.tgl-join::before { content: ''; position: absolute; left: 1.4rem; top: 0; bottom: 0; border-left: 2px solid var(--bs-border-color); }
.tgl-join-btn { position: relative; z-index: 1; border: 1px solid var(--bs-primary-border-subtle); background: var(--bs-body-bg); color: var(--bs-primary-text-emphasis);
  border-radius: 6px; font-size: .75rem; font-weight: 700; letter-spacing: .04em; height: 24px; padding: 0 .55rem; }
.tgl-join-btn:hover { background: var(--bs-primary-bg-subtle); }
.tgl-join-hint { font-size: .78rem; color: var(--bs-secondary-color); }
.tgl-add-group { margin-top: .75rem; border-style: dashed; }

/* Исключения */
.tgl-exclude-card { border-left: 3px solid var(--bs-danger); }
.tgl-chipbox-not:focus-within { border-color: var(--bs-danger); box-shadow: 0 0 0 .25rem rgba(220, 53, 69, .15); }
.tgl-lists { border-top: 1px dashed var(--bs-border-color); padding-top: .75rem; }
.tgl-list-pill { display: inline-flex; align-items: center; gap: .35rem; height: 28px; padding: 0 .25rem 0 .6rem; border: 1px solid var(--bs-border-color);
  border-radius: 6px; background: var(--bs-tertiary-bg); font-size: .85rem; }
.tgl-list-pill .small-meta { font-variant-numeric: tabular-nums; }

/* Сводка-предложение */
.tgl-sentence { font-size: .925rem; line-height: 1.9; }
.tgl-sentence .tgl-chip-sm { vertical-align: 1px; }
.tgl-op { font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--bs-secondary-color); margin: 0 .2rem; }
.tgl-op-not { color: var(--bs-danger-text-emphasis); }

/* Проверка */
.tgl-check-stats { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--bs-secondary-color); }
.tgl-check-stats b { color: var(--bs-body-color); font-variant-numeric: tabular-nums; }
.tgl-feed { max-height: calc(100vh - 360px); min-height: 220px; overflow-y: auto; }
.tgl-msg { padding: .7rem 1rem; border-bottom: 1px solid var(--bs-border-color-translucent); }
.tgl-msg:last-child { border-bottom: 0; }
.tgl-msg-meta { display: flex; gap: .5rem; font-size: .75rem; color: var(--bs-secondary-color); margin-bottom: .2rem; }
.tgl-msg-text { font-size: .875rem; line-height: 1.5; overflow-wrap: anywhere; }
.tgl-msg-why { font-size: .78rem; margin-top: .3rem; color: var(--bs-secondary-color); display: flex; flex-wrap: wrap; gap: .15rem .6rem; }
.tgl-msg-why .ok { color: var(--bs-success-text-emphasis); }
.tgl-msg-why .no { color: var(--bs-warning-text-emphasis); }
.tgl-msg-why .ex { color: var(--bs-danger-text-emphasis); }
mark.tgl-hit { background: rgba(25, 135, 84, .18); color: inherit; padding: 0 1px; border-radius: 3px; box-shadow: inset 0 -2px 0 rgba(25, 135, 84, .55); }
mark.tgl-hit-not { background: rgba(220, 53, 69, .16); box-shadow: inset 0 -2px 0 rgba(220, 53, 69, .6); }
[data-bs-theme="dark"] mark.tgl-hit { background: rgba(117, 183, 152, .22); }
[data-bs-theme="dark"] mark.tgl-hit-not { background: rgba(234, 134, 143, .2); }
.tgl-msg-act { border: 0; background: none; padding: 0; font-size: .78rem; color: var(--bs-primary-text-emphasis); }
.tgl-msg-act:hover { text-decoration: underline; }
.tgl-own { padding: 1rem; }
.tgl-empty { padding: 2rem 1rem; text-align: center; color: var(--bs-secondary-color); font-size: .875rem; }

/* Меню по выделенному слову */
.tgl-selmenu { position: absolute; display: none; z-index: 1080; min-width: 220px; }
.tgl-selmenu.show { display: block; }

/* Текстовый режим */
.tgl-bool { font-size: .85rem; line-height: 1.6; }

/* Название правила — заголовок, который редактируется на месте */
.tgl-title-input { font-size: 1.35rem; font-weight: 600; border-color: transparent; background: transparent; padding: .1rem .35rem; margin-left: -.35rem; max-width: 520px; }
.tgl-title-input:hover { border-color: var(--bs-border-color); }

/* Нижняя панель сохранения */
.tgl-savebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; background: var(--shell-header-bg, var(--bs-body-bg)); border-top: 1px solid var(--bs-border-color); box-shadow: 0 -4px 16px rgba(0, 0, 0, .06); }
.tgl-savebar-in { display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; padding-left: calc(var(--sao-sidebar-width, 232px) + 1.5rem); }
@media (max-width: 767.98px) { .tgl-savebar-in { padding-left: 1rem; } }
.tgl-dot { font-size: .5rem; vertical-align: 2px; }
body.tgl-dirty .sao-content { padding-bottom: 72px; }

.tgl-toast { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); z-index: 1090; background: #14161b; color: #fff; border-radius: 6px;
  padding: .5rem .75rem; font-size: .875rem; display: flex; align-items: center; gap: .75rem; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); max-width: calc(100vw - 32px); }
.tgl-toast button { border: 0; background: none; color: #c4b5fd; font-weight: 600; padding: 0; }
[data-bs-theme="dark"] .tgl-toast { background: #f1f3f5; color: #14161b; }
[data-bs-theme="dark"] .tgl-toast button { color: #6d28d9; }

/* Список правил */
.tgl-col-switch { width: 56px; }
.tgl-rule-line { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; }
.tgl-row-off td > a, .tgl-row-off .tgl-rule-line { opacity: .55; }
.tgl-spark { display: inline-flex; align-items: flex-end; gap: 2px; height: 18px; margin-left: .4rem; vertical-align: -3px; }
.tgl-spark span { width: 4px; background: var(--bs-primary); opacity: .55; border-radius: 1px; }
.tgl-list-preview { max-width: 520px; }
.tgl-tpl { display: flex; gap: .75rem; align-items: flex-start; padding: .75rem; border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius);
  color: inherit; text-decoration: none; }
.tgl-tpl:hover { border-color: var(--bs-primary); background: var(--bs-primary-bg-subtle); }
.tgl-tpl > i { font-size: 1.25rem; color: var(--bs-primary); line-height: 1.2; }

@media (max-width: 1199.98px) { .tgl-feed { max-height: none; } }
@media (max-width: 575.98px) {
  .tgl-title-input { font-size: 1.15rem; }
  .tgl-check .nav-link { padding-left: .25rem; padding-right: .25rem; font-size: .75rem; }
  .tgl-check .nav-link .badge { font-size: .65rem; }
}

.tgl-check .nav-tabs .nav-link { padding: .5rem .55rem; white-space: nowrap; }
.tgl-check .nav-tabs .nav-item:last-child { margin-left: auto; }
.tgl-mobile-check { display: flex; align-items: center; gap: .4rem; padding: .5rem .75rem; margin-bottom: .75rem; border: 1px solid var(--bs-success-border-subtle);
  background: var(--bs-success-bg-subtle); color: var(--bs-success-text-emphasis); border-radius: var(--bs-border-radius); font-size: .85rem; text-decoration: none; }

.tgl-menu { font-size: .875rem; max-width: 300px; }
.tgl-menu .dropdown-item { white-space: normal; }
.tgl-menu .dropdown-item.active, .tgl-menu .dropdown-item:active { background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); }
.tgl-menu .dropdown-item.active .small-meta { color: var(--bs-primary-text-emphasis); opacity: .8; }

/* Production integration: shared SAO shell, keyboard controls and narrow screens. */
:root { --sao-topbar-height: 59px; }
.sao-sidebar {
  --sao-sidebar-text: var(--shell-menu-text); --sao-sidebar-text-strong: var(--shell-menu-text-strong);
  --sao-sidebar-label: var(--shell-menu-label); --sao-sidebar-hover-bg: var(--shell-menu-hover-bg);
  --sao-sidebar-active-bg: var(--shell-menu-active-bg); --sao-sidebar-active-text: var(--shell-menu-active-text);
  background: linear-gradient(var(--shell-menu-bg), var(--shell-menu-bg)); border-right-color: var(--shell-menu-border);
}
.sao-topnav { background: var(--shell-header-bg); }
.sao-nav .nav-link { min-height: 40px; }
.tgl-chip-open { display: inline-flex; align-items: center; gap: .25rem; min-width: 0; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; }
.tgl-chip-open:focus-visible,.tgl-chip-x:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 2px; }
.tgl-chip-open:disabled { opacity: 1; cursor: default; }
.tgl-chip .tgl-chip-t { overflow: hidden; text-overflow: ellipsis; }
.tgl-chipbox > .dropdown { max-width: 100%; }
.tgl-group-label { max-width: min(260px,100%); }
.tgl-summary-group { display: inline-flex; gap: .25rem; align-items: center; flex-wrap: wrap; border: 1px solid var(--bs-border-color); padding: .2rem; border-radius: 6px; }
.tgl-rule-line .tgl-chip-sm { max-width: 170px; overflow: hidden; text-overflow: ellipsis; display: inline-block; line-height: 20px; }
.tgl-feed .tgl-msg-text { white-space: pre-wrap; }
.tgl-sentence { overflow-wrap: anywhere; }
.tgl-list-pill { height: auto; min-height: 28px; max-width: 100%; overflow-wrap: anywhere; }
.tgl-list-preview { max-width: 420px; }
.tgl-rules-table { min-width: 600px; }
[data-rule-editor] { padding-bottom: 60px; }
[data-rule-editor] .card { border: 1px solid var(--bs-border-color); box-shadow: none; }
[data-rule-editor] .card-header { background: var(--bs-tertiary-bg); }
[data-rule-editor] #check { scroll-margin-top: 75px; }
.tgl-savebar-in { max-width: 1700px; margin: auto; }
.tgl-check .nav-tabs { overflow-x: auto; overflow-y: hidden; }
@media(min-width:1200px){.sao-sticky-summary{position:sticky;top:calc(var(--sao-topbar-height) + 1rem)}}
@media(min-width:768px){.sao-topnav .navbar-brand{width:calc(var(--sao-sidebar-width) - 1rem)}.sao-topnav .navbar-brand span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.sao-topnav .tm-context{margin-left:1.5rem}}
@media(max-width:575.98px){
  .tgl-savebar-in { flex-wrap: wrap; gap: .4rem; padding-bottom: max(.6rem,env(safe-area-inset-bottom)); }
  .tgl-savebar-in > span:first-child { width: 100%; }
  .tgl-chip-input { flex-basis: 120px; min-width: 80px; }
  .tgl-group { padding: .6rem; }
  .tgl-group-label { max-width: 210px; }
  .tgl-check .nav-tabs .nav-link { padding: .5rem .3rem; }
  .tgl-list-preview { max-width: 180px; }
}
@media(prefers-reduced-motion:reduce){.tgl-chip-flash{animation:none}}

.tgl-h-0{height:0px}
.tgl-h-1{height:1px}
.tgl-h-2{height:2px}
.tgl-h-3{height:3px}
.tgl-h-4{height:4px}
.tgl-h-5{height:5px}
.tgl-h-6{height:6px}
.tgl-h-7{height:7px}
.tgl-h-8{height:8px}
.tgl-h-9{height:9px}
.tgl-h-10{height:10px}
.tgl-h-11{height:11px}
.tgl-h-12{height:12px}
.tgl-h-13{height:13px}
.tgl-h-14{height:14px}
.tgl-h-15{height:15px}
.tgl-h-16{height:16px}
.tgl-h-17{height:17px}
.tgl-h-18{height:18px}
