/* Aggressive override of LingConLab/Tsakorpus UI. Loaded LAST. */
:root {
  --acc:     #b45309;
  --acc-2:   #7c2d12;
  --acc-soft:#fef3c7;
  --bg:      #f7f4ee;
  --surface: #ffffff;
  --surface-2:#fbf9f3;
  --ink:     #18181b;
  --ink-soft:#3f3f46;
  --muted:   #71717a;
  --border:  #e7e2d6;
}

html, body {
  background: var(--bg) !important;
  color: var(--ink) !important;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif !important;
  font-feature-settings: "cv11";
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

/* ─── Hide their corpus header — we have our own brand in top-left ─── */
#corpus_header, header#corpus_header { display: none !important; }
/* the row that contained the header — collapse spacing */
.row_section_fixed:first-of-type { display: none !important; }

/* ─── Wider centered container ─── */
.box_column {
  background: var(--bg) !important;
  max-width: 1100px;
  margin: 0 auto;
  padding: 80px 32px 60px !important;
}
.container, .container-fluid { max-width: 1100px !important; padding: 0 !important; }

/* ─── Sticky brand strip at top (matches landing) ─── */
body::before {
  content: "";
  position: fixed; top: 0; left: 0; right: 0; height: 64px;
  background: rgba(247,244,238,0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 50;
  pointer-events: none;
}

/* Top-left brand strip — only the «← Лендинг» part is clickable. */
#_corpus_brand {
  position: fixed !important;
  top: 14px; left: 32px;
  z-index: 100;
  display: flex; align-items: center; gap: 12px;
  font-family: "Inter", sans-serif;
}
#_corpus_brand::before {
  content: "Аҧ";
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #f59e0b, #b45309 60%, #7c2d12);
  color: white; border-radius: 8px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13.5px;
}
#_corpus_brand ._back_landing {
  color: var(--ink) !important;
  font-weight: 600 !important; font-size: 15px !important;
  text-decoration: none !important;
  transition: color 0.15s ease;
}
#_corpus_brand ._back_landing:hover { color: var(--acc-2) !important; }
#_corpus_brand ._section_label {
  color: var(--muted);
  font-weight: 500; font-size: 12.5px;
  padding-left: 12px; margin-left: 0;
  border-left: 1px solid var(--border);
  cursor: default;
}

/* ─── Big page heading injected before the search row ─── */
.row_section_fixed:has(#search_div)::before {
  content: "Поиск по корпусу";
  display: block;
  font-family: "Fraunces", serif;
  font-size: 44px; font-weight: 700;
  letter-spacing: -0.025em; line-height: 1.05;
  color: var(--ink);
  margin: 0 0 28px;
}

/* ─── Kill Tsakorpus's fixed-centering on initial load ─── */
/* Their `.centered` puts #search_div at position:fixed; top:450px which
   floats it out of flow and breaks our card layout. Use relative so the
   absolute children (toolbar icons) anchor to it. */
#search_div.centered, #search_div {
  position: relative !important;
  top: auto !important; left: auto !important;
  right: auto !important; bottom: auto !important;
  transform: none !important;
}
#search_div.init-hidden { visibility: visible !important; opacity: 1 !important; }
.transitions { transition: none !important; }

/* ─── Search form card (single card, narrower, centered) ─── */
.row_section_fixed:has(#search_div) {
  display: flex; flex-direction: column; align-items: center;
}
.row_section_fixed:has(#search_div)::before {
  align-self: flex-start;
  max-width: 1080px; width: 100%;
}
#search_div {
  position: relative !important;  /* anchor for absolute toolbar icons */
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 20px !important;
  padding: 64px 44px 36px !important;  /* extra top padding for toolbar */
  margin: 0 !important;
  width: 100% !important; max-width: 1080px !important;
  min-width: 0 !important;
  box-shadow: 0 24px 64px -20px rgba(180,83,9,0.10) !important;
}
/* Tsakorpus puts `.tab-content { float: left }` which collapses to fit-content.
   Kill the float everywhere — same issue affects modals. */
.tab-content {
  float: none !important; display: block !important;
  width: 100% !important;
}
#search_div form { display: block; }

/* modal tabs */
.modal-body .nav-tabs {
  border-bottom: 1px solid var(--border) !important;
  margin-bottom: 18px;
  gap: 4px;
}
.modal-body .nav-tabs .nav-link {
  background: transparent !important;
  border: 0 !important;
  color: var(--ink-soft) !important;
  font: 500 14px Inter, sans-serif !important;
  padding: 9px 16px !important;
  border-radius: 8px 8px 0 0 !important;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.modal-body .nav-tabs .nav-link:hover { background: var(--surface-2) !important; color: var(--ink) !important; }
.modal-body .nav-tabs .nav-link.active {
  background: var(--surface) !important;
  color: var(--ink) !important;
  border-bottom: 2px solid var(--acc) !important;
  font-weight: 600 !important;
}

/* subcorpus selector & metadata layout — wider modals */
.modal-lg .modal-dialog { max-width: 900px !important; }
#subcorpus_selector.modal .modal-dialog,
#metadata_dialogue.modal .modal-dialog,
#display_settings.modal .modal-dialog,
#help_dialogue.modal .modal-dialog,
#dictionary_dialogue.modal .modal-dialog,
#citation_dialogue.modal .modal-dialog {
  max-width: 880px !important;
  margin: 1.75rem auto;
}
#subcorpus_selector.modal .modal-dialog { max-width: 980px !important; }
#subcorpus_selector .modal-body,
#metadata_dialogue .modal-body,
#display_settings .modal-body {
  padding: 24px 28px !important;
  max-height: 75vh; overflow-y: auto;
}

/* Metadata modal: make the inner content + table fill the full width */
#metadata_dialogue .modal-body > * { width: 100%; }
#metadata_dialogue table, #metadata_dialogue table#fulltext_meta {
  width: 100% !important;
  max-width: none !important;
  border-collapse: separate; border-spacing: 0;
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  overflow: hidden;
  font-size: 14px;
}
#metadata_dialogue table td {
  padding: 12px 16px !important;
  border-bottom: 1px solid var(--border) !important;
  vertical-align: top;
}
#metadata_dialogue table tr:last-child td { border-bottom: 0 !important; }
#metadata_dialogue table tr td:first-child {
  width: 220px; color: var(--muted); font-weight: 500;
  background: var(--surface-2);
  border-right: 1px solid var(--border) !important;
}
#metadata_dialogue table tr td:last-child { color: var(--ink); }

/* Display-settings modal: make the inner settings_div block-level */
#display_settings .settings_div {
  display: block !important;
  width: 100% !important;
}
/* Tsakorpus's .settings_column floats left with max-width 375px and dotted
   border — stack them full-width with proper card style. */
#display_settings .settings_column,
#display_settings .settings_column_leftalign {
  float: none !important;
  display: block !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 0 14px !important;
  text-align: left !important;
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  padding: 18px 22px !important;
  background: var(--surface-2);
}
#display_settings .settings_column .row,
#display_settings .settings_column_leftalign .row {
  margin: 8px 0 !important;
}
#display_settings .settings_div fieldset,
#display_settings fieldset {
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  padding: 16px 20px !important;
  margin: 0 0 16px 0 !important;
}
#display_settings .settings_div fieldset legend,
#display_settings legend {
  font-family: "Fraunces", serif !important;
  font-size: 14px !important; font-weight: 600 !important;
  color: var(--ink-soft) !important;
  width: auto !important;
  padding: 0 8px !important;
  margin: 0 !important;
  float: none;
}
#display_settings .row {
  margin: 0 0 8px 0 !important;
  align-items: center;
}
#display_settings .col-sm-6 {
  flex: 1; width: auto !important; max-width: none !important;
}
#display_settings .col-form-label {
  font-size: 13.5px;
  color: var(--ink) !important;
  font-weight: 500 !important;
  margin: 0; padding: 0 14px 0 0 !important;
  text-align: left !important;
}
#display_settings select, #display_settings input[type=text],
#display_settings input[type=number] {
  width: 100% !important; max-width: 280px;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  padding: 8px 12px !important;
  font-size: 14px !important;
  background: var(--surface) !important;
}
#display_settings .form-check {
  padding-left: 28px; margin: 6px 0 !important;
}
#subcorpus_selector h3, .modal h3, .modal-body h4 {
  font-family: "Fraunces", serif;
  font-weight: 700; font-size: 18px;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
  color: var(--ink);
}
/* form labels (year-from/to etc.) */
.modal-body label {
  display: block; font-size: 13px;
  color: var(--muted); font-weight: 500;
  margin-bottom: 6px;
}
.modal-body input[type=text], .modal-body input[type=number] {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  padding: 7px 11px !important;
  font: 14px Inter, sans-serif !important;
  width: auto; max-width: 220px;
  transition: all 0.15s;
}
.modal-body input[type=text]:focus, .modal-body input[type=number]:focus {
  outline: 0 !important;
  border-color: var(--acc) !important;
  box-shadow: 0 0 0 3px rgba(180,83,9,0.12) !important;
}
/* checkbox/radio rows */
.modal-body .form-check { padding-left: 28px; margin: 4px 0; }
.modal-body .form-check-input { accent-color: var(--acc); }
.modal-body .form-check-label { font-size: 14px; color: var(--ink); cursor: pointer; }

/* multi-column author/place lists */
.modal-body select[multiple], .modal-body .meta_field_selector {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  padding: 4px !important;
  font: 13px Inter, sans-serif !important;
  min-width: 220px;
  max-height: 280px;
}
.modal-body select[multiple] option {
  padding: 5px 10px !important; border-radius: 6px;
}
.modal-body select[multiple] option:checked {
  background: var(--acc-soft) linear-gradient(0deg, var(--acc-soft), var(--acc-soft)) !important;
  color: var(--acc-2) !important; font-weight: 500;
}
.show-hide { width: 100% !important; }
.query_slide { padding: 0 !important; }
#search_main { background: transparent !important; display: block !important; }
#search_main::after { content: ""; display: table; clear: both; }

/* ─── .words_search container: stack word blocks vertically ─── */
/* Tsakorpus's CSS has display:flex row + float:left on .word_search children,
   so multiple words end up side-by-side and overflow. Force column. */
.words_search {
  display: flex !important; flex-direction: column !important;
  gap: 16px;
}

/* ─── word_search: flex row (form on left + action icons on right) ─── */
.word_search {
  display: flex !important; flex-direction: row;
  align-items: flex-start; gap: 16px;
  float: none !important; clear: both;
  width: 100% !important; max-width: none !important;
  background: transparent !important;
  border: 0 !important; border-radius: 0 !important;
  padding: 0 !important; margin: 0 !important;
  box-sizing: border-box;
}
.word_search > .word_search_l { flex: 1 1 auto; min-width: 0; }
/* Visual separator between word blocks #2+ */
.word_search + .word_search {
  padding-top: 16px !important;
  border-top: 1px dashed var(--border) !important;
}
/* word_search_l uses CSS grid so every row gets the same alignment:
   col1 = label (96px), col2 = input (flex), col3 = optional icon.
   Tsakorpus's grammar row isn't wrapped, so flex on .autocomplete_word_input_div
   wouldn't apply — grid+display:contents fixes both at once. */
.word_search_l {
  display: grid !important;
  grid-template-columns: 170px 1fr 36px;
  column-gap: 14px; row-gap: 12px;
  align-items: center;
  background: transparent !important;
}
.word_search_l > .query_word_header,
.word_search_l > hr.separator,
.word_search_l > .word_rel {
  grid-column: 1 / -1;
}

/* Distance widget between words — small inline form */
.word_search_l > .word_rel {
  display: flex !important; flex-wrap: wrap;
  align-items: center; gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin-top: 4px;
  font-size: 13.5px; color: var(--ink-soft);
}
.word_rel br { display: none !important; }
.word_rel input.search_input, .word_rel .distance_input {
  width: 60px !important; max-width: 60px !important;
  padding: 6px 10px !important;
  text-align: center;
  font-size: 13.5px !important;
  grid-column: auto !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
}
.word_rel .distance_input { width: 48px !important; max-width: 48px !important; }
.word_search_l > .autocomplete_word_input_div { display: contents; }
.word_search_l > input[type=hidden],
.word_search_l > select[id^=lang],
.word_search_l > br { display: none !important; }
/* Advanced fields (Разборы, sentence-index distance) — collapsed by default.
   Tsakorpus's expand_word_input() toggles max-height between 0 and 600px and
   visibility hidden/visible. We must use max-height (not display:none) so the
   JS can re-show them. */
.word_search_l > .add_word_fields {
  grid-column: 1 / -1;
  display: grid !important;
  grid-template-columns: 170px 1fr 36px;
  column-gap: 14px; row-gap: 12px;
  align-items: center;
  max-height: 0;
  overflow: hidden;
  visibility: hidden;
  margin-top: 0;
  transition: max-height 0.25s ease;
}
.word_search_l > .add_word_fields > label {
  grid-column: 1;
  font-size: 13.5px; color: var(--muted); text-align: right;
  margin: 0 !important;
}
.word_search_l > .add_word_fields > select,
.word_search_l > .add_word_fields > input {
  grid-column: 2;
  width: 100% !important; max-width: none !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  padding: 10px 14px !important;
  font-size: 14.5px !important;
  background: var(--surface) !important;
  box-sizing: border-box;
}
.word_search_l > .add_word_fields > br { display: none !important; }

.query_word_header {
  font-family: "Fraunces", serif !important;
  font-size: 16px !important; font-weight: 700 !important;
  color: var(--ink) !important;
  margin: 0 0 6px !important;
  display: flex !important; align-items: center; gap: 10px;
}
.circle, .circle_w1 {
  width: 9px !important; height: 9px !important;
  background: var(--acc) !important;
  border-radius: 50% !important;
  border: 0 !important; box-shadow: 0 0 0 4px rgba(180,83,9,0.15);
  display: inline-block;
}

.autocomplete_word_input_div { margin: 0 !important; }
.search_label {
  font-size: 13.5px; font-weight: 500;
  color: var(--muted); text-align: right;
  margin: 0 !important; padding: 0 !important;
  grid-column: 1;
}
.search_input {
  width: 100% !important; max-width: none !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  background: var(--surface) !important;
  font-family: inherit !important; font-size: 14.5px !important;
  padding: 10px 14px !important;
  transition: all 0.15s ease;
  box-sizing: border-box;
  grid-column: 2;
}
.search_input:focus {
  outline: 0 !important;
  border-color: var(--acc) !important;
  box-shadow: 0 0 0 3px rgba(180,83,9,0.12) !important;
}
/* Grammar selector icon — sits in col 3 of the grid */
.gram_selector_link {
  width: 36px !important; height: 36px !important;
  display: inline-grid !important; place-items: center;
  border-radius: 9px !important;
  border: 1px solid var(--border) !important;
  background: var(--surface) !important;
  color: var(--ink-soft) !important;
  font-size: 16px !important;
  cursor: pointer;
  text-decoration: none !important;
  transition: all 0.15s ease;
  grid-column: 3;
  margin: 0 !important; padding: 0 !important;
}
.gram_selector_link:hover {
  background: var(--acc-soft) !important; color: var(--acc-2) !important;
  border-color: #fbbf24 !important;
}

/* ─── Card toolbar: gear/history at top-left, word actions at top-right ─── */
/* Both panes positioned absolute relative to #search_div */
.vertical_settings_pane {
  display: flex !important; flex-direction: row; gap: 8px;
  position: absolute !important;
  top: 16px !important; left: 18px !important;
  margin: 0 !important; float: none !important;
  z-index: 5;
}
.vertical_settings_pane a {
  width: 36px; height: 36px;
  display: inline-grid !important; place-items: center;
  border-radius: 9px; background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-soft) !important; font-size: 15px;
  transition: all 0.15s ease;
  position: relative;
}
.vertical_settings_pane a:hover { background: var(--acc-soft); color: var(--acc-2) !important; border-color: #fbbf24; }

/* word_search_r: vertical column of per-word action icons on the right
   side of each word block (matches Tsakorpus's original placement). */
.word_search_r {
  display: flex !important; flex-direction: column !important; gap: 8px !important;
  position: static !important;
  width: auto !important; min-width: 0 !important; height: auto !important;
  flex: 0 0 auto;
  background: transparent !important;
  border: 0 !important; padding: 0 !important;
  align-items: center !important;
  z-index: 5;
}
.word_search_r br { display: none !important; }
/* Tsakorpus inserts empty `.add_minus_stub` / `.add_distance_stub` anchors on
   word #1 to keep icon-column heights aligned across word blocks. Show them
   as faded placeholders rather than hiding (so word #1 and word #2 line up). */
.word_search_r .add_minus_stub, .word_search_r .add_distance_stub {
  display: inline-grid !important;
  opacity: 0.25;
  pointer-events: none;
  background: transparent !important;
  border-color: var(--border) !important;
}
.word_search_r .add_minus_stub::before { content: "−"; font-size: 18px; color: var(--muted); }
.word_search_r .add_distance_stub::before { content: "↗"; font-size: 16px; color: var(--muted); }
.word_search_r > a, .word_search_r > a.bi, .word_search_r .link_icon {
  width: 36px !important; height: 36px !important;
  min-width: 36px !important; min-height: 36px !important;
  display: inline-grid !important; place-items: center;
  border-radius: 9px !important;
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  color: var(--ink-soft) !important;
  font-size: 15px !important;
  text-decoration: none !important;
  transition: all 0.15s ease;
  cursor: pointer;
  flex: 0 0 36px !important;
  padding: 0 !important;
}
.word_search_r a:hover { background: var(--acc-soft); color: var(--acc-2) !important; border-color: #fbbf24; }

/* ─── Negation visual state ───────────────────────────────────────────
   Tsakorpus toggles `.negated` class on .word_search (and .word_search_r)
   when user clicks the ⏻ button. Paint the block in soft red instead of
   Tsakorpus's solid black. */
.word_search.negated {
  background: linear-gradient(0deg, rgba(254,226,226,0.5), rgba(254,226,226,0.5)),
              repeating-linear-gradient(135deg, transparent 0 12px, rgba(220,38,38,0.06) 12px 13px) !important;
  border: 1px solid #fecaca !important;
  border-radius: 14px !important;
  padding: 14px 18px !important;
  margin: 0 !important;
  position: relative;
}
.word_search.negated::before {
  content: "НЕ";
  position: absolute;
  top: 10px; right: 60px;
  font: 700 11px Inter, sans-serif;
  letter-spacing: 0.08em;
  color: #b91c1c;
  background: white;
  border: 1px solid #fecaca;
  padding: 3px 8px;
  border-radius: 999px;
}
.word_search.negated .query_word_header,
.word_search.negated .search_label {
  color: #991b1b !important;
}
.word_search.negated .circle,
.word_search.negated .circle_w1 {
  background: #dc2626 !important;
  box-shadow: 0 0 0 4px rgba(220,38,38,0.15) !important;
}
.word_search.negated .search_input,
.word_search.negated .gram_selector_link {
  border-color: #fecaca !important;
  background: rgba(255,255,255,0.7) !important;
}
.word_search_r.negated a.neg_query,
.word_search.negated .word_search_r a.neg_query {
  background: #dc2626 !important;
  color: white !important;
  border-color: #dc2626 !important;
}

/* Tooltips are handled natively by Bootstrap's tooltip plugin (Tsakorpus
   initialises them with data-tooltip="tooltip"). We only restyle the bubble. */
.tooltip { font-family: "Inter", sans-serif !important; }
.tooltip-inner {
  background: var(--ink) !important; color: white !important;
  font: 500 12px/1.3 Inter, sans-serif !important;
  padding: 6px 10px !important;
  border-radius: 7px !important;
  max-width: 240px !important;
  box-shadow: 0 8px 24px -6px rgba(24,24,27,0.3) !important;
}
.tooltip .tooltip-arrow::before { border-bottom-color: var(--ink) !important; }
.tooltip.bs-tooltip-top .tooltip-arrow::before { border-top-color: var(--ink) !important; }
.tooltip.bs-tooltip-left .tooltip-arrow::before { border-left-color: var(--ink) !important; }
.tooltip.bs-tooltip-right .tooltip-arrow::before { border-right-color: var(--ink) !important; }

hr.separator {
  border: 0; border-top: 1px solid var(--border);
  margin: 22px 0 18px;
  position: relative;
}

/* ─── Full-text search row inside the search form's .tab-content ──────────
   Scoped to #search_main so modals (e.g. word_stats) keep their natural
   layout. */
#search_main .tab-content {
  display: grid !important;
  grid-template-columns: 170px 1fr auto auto;
  column-gap: 14px; row-gap: 16px;
  align-items: center;
}
#search_main .tab-content > .words_search,
#search_main .tab-content > .row_section_expand { grid-column: 1 / -1; }
#search_main .tab-content > br { display: none !important; }
#search_main .tab-content > label[for=txt] {
  grid-column: 1; margin: 0 !important;
  font-size: 13.5px; font-weight: 500;
  color: var(--muted); text-align: right;
}
#search_main .tab-content > input#txt {
  grid-column: 2; width: 100% !important; max-width: none !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  padding: 10px 14px !important;
  font-size: 14.5px !important;
  background: var(--surface) !important;
  margin: 0 !important;
}
#search_main .tab-content > input#precise { grid-column: 3; margin: 0 !important; }
#search_main .tab-content > label[for=precise],
#search_main .tab-content > #precise_label {
  grid-column: 4; margin: 0 !important;
  font-size: 13px; color: var(--ink-soft);
  white-space: nowrap; cursor: pointer;
}
#sentence_full_text_search_div { display: contents !important; }
input[type=checkbox] { accent-color: var(--acc); cursor: pointer; }

/* ─── Search action buttons: clear hierarchy ───
   primary  : #search_sent  (Поиск предложений) — dark
   secondary: #search_word, #search_lemma, #show_word_stat — outlined
   tertiary : #search_doc (Выбор подкорпуса) — pulled left, pill style
   icons    : #share_query, #load_query — outlined square icon */
.search_buttons {
  display: flex !important; align-items: center; gap: 12px;
  flex-wrap: wrap; margin: 22px 0 0 !important;
}
/* Bootstrap's .btn-group merges adjacent buttons (shared borders, gap 0).
   Untie them so flex gap applies to every individual button. */
.search_buttons .btn-group {
  display: flex !important; gap: 10px;
  background: transparent !important;
}
.search_buttons .btn-group > .btn {
  border-radius: 11px !important;
  margin: 0 !important;
}
.search_buttons .btn-group > .btn:not(:first-child),
.search_buttons .btn-group > .btn:not(:last-child) {
  border-radius: 11px !important; /* override BS btn-group radius reset */
  margin-left: 0 !important;
}
/* small icon buttons live in their own btn-group — keep them tighter */
.search_buttons .btn-group:last-of-type { gap: 8px; }
/* primary action */
#search_sent, button#search_sent.btn-primary {
  background: var(--ink) !important;
  color: white !important;
  border: 0 !important;
  border-radius: 11px !important;
  padding: 11px 22px !important;
  font: 600 14px Inter, sans-serif !important;
  cursor: pointer;
  box-shadow: 0 4px 14px -4px rgba(24,24,27,0.4);
  transition: all 0.15s ease;
}
#search_sent:hover {
  background: var(--acc-2) !important;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px -4px rgba(124,45,18,0.4);
}
/* secondary actions (other search modes) — outlined */
#search_word, #search_lemma, #show_word_stat,
button#search_word.btn-primary, button#search_lemma.btn-primary, button#show_word_stat.btn-primary {
  background: var(--surface) !important;
  color: var(--ink) !important;
  border: 1px solid var(--border) !important;
  border-radius: 11px !important;
  padding: 10px 18px !important;
  font: 600 14px Inter, sans-serif !important;
  cursor: pointer;
  box-shadow: none !important;
  transition: all 0.15s ease;
}
#search_word:hover, #search_lemma:hover, #show_word_stat:hover {
  background: var(--surface-2) !important;
  border-color: #d6cfbf !important;
}
#show_word_stat { padding: 10px 14px !important; }

/* subcorpus — pill, separated with a left margin auto */
#search_doc, button#search_doc.btn-outline-primary {
  background: transparent !important;
  color: var(--acc-2) !important;
  border: 1px solid #fbbf24 !important;
  border-radius: 999px !important;
  padding: 9px 18px !important;
  font: 600 13.5px Inter, sans-serif !important;
  margin-left: auto !important;
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer;
}
#search_doc::before {
  content: "⌃"; font-size: 14px; color: var(--acc);
  display: inline-block; transform: translateY(-1px);
}
#search_doc:hover {
  background: var(--acc-soft) !important;
  border-color: var(--acc) !important;
  color: var(--acc-2) !important;
}

/* small icon buttons (share, load) — outlined squares */
#share_query, #load_query,
button#share_query.btn-outline-dark, button#load_query.btn-outline-dark {
  background: var(--surface) !important;
  color: var(--ink-soft) !important;
  border: 1px solid var(--border) !important;
  width: 38px !important; height: 38px !important;
  display: inline-grid !important; place-items: center;
  border-radius: 10px !important;
  padding: 0 !important; font-size: 16px !important;
  cursor: pointer;
  transition: all 0.15s ease;
}
#share_query:hover, #load_query:hover {
  background: var(--acc-soft) !important; color: var(--acc-2) !important;
  border-color: #fbbf24 !important;
}

/* welcome help box */
.welcome_text, #welcome, .alert, .alert-info, .alert-warning {
  background: #fffbeb !important;
  border: 1px solid #fde68a !important;
  border-radius: 14px !important;
  padding: 24px 28px !important;
  color: #78350f !important;
  font-size: 14.5px !important;
  line-height: 1.65 !important;
  margin: 24px 0 !important;
}
.welcome_text b, .welcome_text strong { color: #7c2d12; }
.welcome_text a, .alert a { color: var(--acc-2); text-decoration: underline; }
/* Close button in alert — visible on yellow bg */
.alert .btn-close {
  position: relative !important;
  background: transparent !important;
  border: 0 !important; opacity: 1 !important;
  width: 28px !important; height: 28px !important;
  border-radius: 7px !important;
  padding: 0 !important;
  transition: background 0.15s;
}
.alert .btn-close::before, .alert .btn-close::after {
  content: ""; position: absolute;
  top: 50%; left: 50%;
  width: 14px; height: 2px;
  background: #7c2d12; border-radius: 2px;
}
.alert .btn-close::before { transform: translate(-50%, -50%) rotate(45deg); }
.alert .btn-close::after  { transform: translate(-50%, -50%) rotate(-45deg); }
.alert .btn-close:hover { background: #fde68a !important; }

/* Return-to-search button:
   - Hidden while the form (.query_slide) is visible
   - Shown when Tsakorpus's JS hides the form (inline style display:none) after
     a search runs */
#search_div:has(.query_slide:not([style*="display: none"]):not([style*="display:none"])) #hide_query_button {
  display: none !important;
}
#search_div #hide_query_button {
  display: inline-flex !important;
  margin: 0 0 18px !important;
}

/* small icon buttons (link/share, download) */
.share_query, .download_query, .row_section_fixed > div > a.bi {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--ink-soft) !important;
  text-decoration: none !important;
  margin: 0 6px 0 0;
  transition: all 0.15s ease;
}
.share_query:hover, .download_query:hover { background: var(--acc-soft); color: var(--acc-2) !important; }

/* dropdowns / modals from bootstrap */
.modal-content { border-radius: 16px !important; border: 0 !important; box-shadow: 0 30px 80px -20px rgba(24,24,27,0.25) !important; }
.modal-header { border-bottom: 1px solid var(--border) !important; padding: 20px 24px !important; }
.modal-title { font-family: "Fraunces", serif !important; font-size: 20px !important; font-weight: 700 !important; }
.modal-body { padding: 20px 24px !important; }
.dropdown-menu {
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  box-shadow: 0 16px 40px -8px rgba(24,24,27,0.15) !important;
  padding: 6px !important;
}
.dropdown-item { border-radius: 7px !important; padding: 8px 14px !important; font-size: 14px; }
.dropdown-item:hover { background: var(--acc-soft) !important; color: var(--acc-2) !important; }

/* results tables / KWIC */
.table { background: var(--surface); border-radius: 14px; overflow: hidden; border: 1px solid var(--border); }
.table th { background: var(--surface-2) !important; border-bottom: 1px solid var(--border) !important; font-weight: 600 !important; color: var(--ink-soft); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; padding: 12px 16px !important; }
.table td { border-color: var(--border) !important; padding: 12px 16px !important; }
.table-striped tbody tr:nth-of-type(odd) { background: var(--surface-2) !important; }
.table-hover tbody tr:hover { background: var(--acc-soft) !important; }

/* ─── «Поиск слов» / «Поиск лексем» result table ─── */
.word_results { width: 100% !important; max-width: none !important; }
.words_list_table {
  width: 100% !important; max-width: none !important;
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 14px !important;
  border-collapse: separate; border-spacing: 0;
  overflow: hidden;
  margin: 14px 0;
  font-size: 14.5px;
}
.words_list_table thead th {
  background: var(--surface-2) !important;
  color: var(--ink-soft) !important;
  font-family: "Inter", sans-serif !important;
  font-weight: 600 !important;
  font-size: 12.5px !important;
  text-transform: lowercase;
  letter-spacing: 0.02em;
  padding: 14px 16px !important;
  border-bottom: 1px solid var(--border) !important;
  border-right: 0 !important;
  text-align: left !important;
  white-space: nowrap;
}
.words_list_table thead th .bi { font-size: 16px; color: var(--ink-soft); }
.words_list_table tbody td {
  padding: 11px 16px !important;
  border-bottom: 1px solid var(--border) !important;
  border-right: 0 !important;
  background: transparent !important;
  color: var(--ink);
  vertical-align: middle;
}
.words_list_table tbody tr:nth-of-type(odd) td { background: var(--surface-2) !important; }
.words_list_table tbody tr:last-child td { border-bottom: 0 !important; }
.words_list_table tbody tr:hover td { background: var(--acc-soft) !important; }
.words_list_table tbody td .bi {
  font-size: 16px; color: var(--ink-soft);
  cursor: pointer; padding: 4px;
  border-radius: 6px; transition: all 0.15s;
}
.words_list_table tbody td .bi:hover {
  background: var(--surface); color: var(--acc-2);
}
/* the small ▼ "show more" footer button */
.words_list_table tfoot, .words_list_table .show_more_table {
  background: var(--surface-2) !important;
  text-align: center;
  padding: 10px !important;
}

/* ─── «Выбор подкорпуса» → «Выбор из списка» table ─────────────────────
   Tsakorpus paints this table in saturated yellows (header #e2d076,
   odd #fff9b2, even #f7f0a0). Repaint in our palette. */
.documents_list_table {
  width: 100% !important;
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 14px !important;
  border-collapse: separate; border-spacing: 0;
  overflow: hidden;
  font-size: 14px;
  margin: 14px 0;
}
.documents_list_table th {
  background: var(--surface-2) !important;
  color: var(--ink-soft) !important;
  font-family: "Inter", sans-serif !important;
  font-weight: 600 !important;
  font-size: 12.5px !important;
  text-transform: lowercase;
  letter-spacing: 0.02em;
  padding: 14px 16px !important;
  border-bottom: 1px solid var(--border) !important;
  text-align: left !important;
  white-space: normal;
  cursor: pointer;
  min-width: 0 !important;
}
.documents_list_table th:hover { background: #f5f0e3 !important; color: var(--ink) !important; }
.documents_list_table tr:nth-child(2n+1) { background-color: var(--surface) !important; }
.documents_list_table tr:nth-child(2n)   { background-color: var(--surface-2) !important; }
.documents_list_table tbody tr:hover { background: var(--acc-soft) !important; }
.documents_list_table td {
  padding: 12px 16px !important;
  border-bottom: 1px solid var(--border) !important;
  color: var(--ink);
  vertical-align: middle;
}
.documents_list_table tbody tr:last-child td { border-bottom: 0 !important; }
.documents_list_table input[type=checkbox] {
  accent-color: var(--acc);
  width: 16px; height: 16px;
  cursor: pointer;
}
/* "Очистить подкорпус" button — Tsakorpus uses btn-danger; keep but soften */
#subcorpus_selector .btn-danger, #clear_subcorpus {
  background: #ef4444 !important;
  border: 0 !important;
  color: white !important;
  border-radius: 10px !important;
  font: 600 14px Inter, sans-serif !important;
  padding: 9px 18px !important;
}
#subcorpus_selector .btn-danger:hover { background: #dc2626 !important; }

/* ─── Search results ──────────────────────────────────────────────── */
#search_results, #lower_part { background: transparent !important; }
.sent_results {
  background: transparent !important;
  margin: 24px 0;
  overflow: visible !important;
  max-height: none !important; height: auto !important;
}
/* Tsakorpus also sets fixed heights on the inner scroll container — kill them */
#search_results, #search_results_inner {
  overflow: visible !important;
  max-height: none !important; height: auto !important;
}

/* return-to-search button */
#hide_query_button {
  display: inline-flex !important; align-items: center; gap: 8px;
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  color: var(--ink-soft) !important;
  font: 500 13.5px/1 Inter, sans-serif !important;
  padding: 9px 16px !important;
  border-radius: 10px !important;
  cursor: pointer; margin: 0 auto 18px !important;
  transition: all 0.15s ease;
}
#hide_query_button:hover { background: var(--acc-soft) !important; color: var(--acc-2) !important; border-color: #fbbf24 !important; }
#hide_query_button .bi { font-size: 14px; color: var(--ink-soft); }

/* result card: outer .context is the card; .ch_container inside is just a
   wrapper for the header — keep it transparent so we don't get card-in-card. */
.context {
  display: block !important;
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 14px !important;
  margin: 14px 0 !important;
  padding: 0 !important;
  box-shadow: 0 2px 8px -4px rgba(24,24,27,0.06);
  overflow: hidden;
}
.ch_container {
  display: block !important;
  background: transparent !important;
  border: 0 !important; border-radius: 0 !important;
  margin: 0 !important; padding: 0 !important;
  box-shadow: none !important;
}
.ch_container > * { display: block; }

/* result header strip — compact, blends with the card edges (no double border) */
.context_header {
  display: flex !important; align-items: center; gap: 14px;
  background: var(--surface-2) !important;
  padding: 12px 18px !important;
  margin: 0 !important;
  border: 0 !important;
  border-bottom: 1px solid var(--border) !important;
  border-radius: 14px 14px 0 0 !important;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.context_header:hover { background: #f5f0e3 !important; }
.ch_title {
  font-weight: 600 !important; color: var(--ink) !important;
  font-family: "Inter", -apple-system, sans-serif !important;
  font-size: 15px !important;
  line-height: 1.35; flex: 1; min-width: 0;
}
.ch_author {
  display: inline-block;
  background: var(--acc-soft) !important;
  color: var(--acc-2) !important;
  font-weight: 600 !important; font-size: 12.5px !important;
  padding: 3px 10px !important;
  border-radius: 999px !important;
  white-space: nowrap;
}

/* result body */
.cx_main {
  padding: 18px 22px !important;
  background: var(--surface) !important;
}
.cx_toggle_div {
  display: inline-block !important;
  margin-right: 10px; vertical-align: middle;
}
.cx_toggle_chk { accent-color: var(--acc); transform: scale(1.1); }

/* sentence text */
.sentence, .sent_lang {
  display: inline !important;
  font-size: 15.5px !important;
  line-height: 1.85 !important;
  color: var(--ink) !important;
  font-family: "Inter", -apple-system, sans-serif !important;
}

/* individual words — make them clickable but subtle */
.word {
  display: inline; cursor: pointer;
  padding: 1px 2px; border-radius: 3px;
  transition: background 0.1s ease;
}
.word:hover { background: var(--acc-soft) !important; }

/* highlight matched words (Tsakorpus uses several classes) */
.word.target, .word.found, .target, .keyword, mark, .highlight,
.word.highlight, .word[class*=highlight] {
  background: linear-gradient(transparent 55%, #fde68a 55%) !important;
  color: var(--ink) !important;
  font-weight: 600;
  padding: 1px 2px;
  border-radius: 3px;
}
.word.target:hover, .target:hover { background: linear-gradient(transparent 50%, #fcd34d 50%) !important; }

/* source-icon strip on the right of headers */
.context_header .bi {
  font-size: 16px; color: var(--muted);
  width: 28px; height: 28px;
  display: inline-grid !important; place-items: center;
  border-radius: 7px;
  transition: all 0.15s;
}
.context_header .bi:hover { background: white; color: var(--acc-2); }

/* pagination */
.pages, .pages.alert-info {
  display: flex !important; align-items: center; justify-content: center;
  gap: 4px !important; flex-wrap: wrap;
  background: transparent !important;
  border: 0 !important;
  padding: 8px 0 !important;
  margin: 24px 0 !important;
}
.pages button, .pages .page_link, .pages a {
  display: inline-grid; place-items: center;
  min-width: 38px; height: 38px;
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  color: var(--ink-soft) !important;
  border-radius: 10px !important;
  font: 500 14px Inter, sans-serif !important;
  cursor: pointer; padding: 0 12px !important;
  transition: all 0.15s ease;
}
.pages button:hover, .pages .page_link:hover {
  background: var(--acc-soft) !important;
  color: var(--acc-2) !important;
  border-color: #fbbf24 !important;
}
.pages .cur_page {
  display: inline-grid; place-items: center;
  min-width: 38px; height: 38px;
  background: var(--ink) !important;
  border: 1px solid var(--ink) !important;
  color: white !important;
  border-radius: 10px !important;
  font: 600 14px Inter, sans-serif !important;
  padding: 0 12px;
}

/* popup_word - the tooltip that shows on word hover */
.popup_word, .ui-tooltip {
  background: white !important;
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  box-shadow: 0 16px 40px -8px rgba(24,24,27,0.18) !important;
  padding: 14px 18px !important;
  font-size: 14px !important;
  max-width: 380px;
  z-index: 200;
}
.popup_word .popup_wf {
  font-family: "Fraunces", serif; font-weight: 700; font-size: 17px;
  color: var(--ink); display: block; margin-bottom: 8px;
}

/* general buttons fallback */
.btn-primary { background: var(--ink) !important; border-color: var(--ink) !important; color: white !important; border-radius: 10px !important; font-weight: 600 !important; }
.btn-primary:hover { background: var(--acc-2) !important; border-color: var(--acc-2) !important; }
.btn-secondary, .btn-outline-secondary { background: transparent !important; color: var(--ink-soft) !important; border: 1px solid var(--border) !important; border-radius: 10px !important; font-weight: 500 !important; }
.btn-secondary:hover, .btn-outline-secondary:hover { background: var(--acc-soft) !important; color: var(--acc-2) !important; }
.btn-success { background: #047857 !important; border-color: #047857 !important; }
.btn-danger  { background: #be123c !important; border-color: #be123c !important; }
.btn-link { color: var(--acc) !important; text-decoration: none; }

/* misc */
a { color: var(--acc); }
a:hover { color: var(--acc-2); }
hr { border-color: var(--border); opacity: 0.6; }
code, pre, kbd, samp { font-family: "JetBrains Mono", ui-monospace, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 0.92em; }

@media (max-width: 900px) {
  .box_column { padding: 70px 18px 40px !important; }
  .vertical_settings_pane { position: static; flex-direction: row; margin-bottom: 12px; }
  .word_search { flex-direction: column; }
  .word_search_r { flex-direction: row; border-left: 0; border-top: 1px solid var(--border); padding: 14px 0 0; padding-left: 0; }
  .search_label { min-width: auto; display: block; text-align: left; margin-bottom: 4px; }
  .search_input { width: 100% !important; }
}
