/* LAMA BPO teisės aktų asistentas — sąsaja.
   Spalvos apibrėžtos kintamaisiais, kad būtų lengva pritaikyti prie
   lamabpo.lt dizaino, kai bus įterpiama į svetainę.

   Kontrastas (WCAG 2.2 AA, patikrinta 2026-10-06 abiem temomis):
   --text / --muted / --accent / --danger ant --bg, --surface, --bot-bg >= 4,5:1;
   --on-accent ant --accent >= 4,5:1; --control (valdiklių rėmeliai) >= 3:1.
   --border — tik dekoratyvinės skirtukės, kurioms kontrasto nereikia.
   Tema: auto pagal OS arba data-theme="light|dark" (assets/theme.js). */

/* Nunito Sans — kaip lamabpo.lt (YOOtheme tema). Talpinama čia (public/assets/fonts,
   SIL OFL 1.1 — fonts/OFL.txt): lankytojo IP nepatenka į Google. Kintamas storis 200–1000;
   lotynų išplėstinė — lietuviškoms raidėms. */
@font-face {
  font-family: 'Nunito Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url(fonts/nunito-sans-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Nunito Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url(fonts/nunito-sans-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Paletė — lamabpo.lt (dizaino kritika 2026-10-13, P2): tekstas #212c34, nuorodos #03648d,
   prekės ženklo tamsiai mėlyna #002939, oranžinis akcentas #ff905f. Tamsi tema — tamsiai
   mėlynos pagrindu, ne pilka. Kontrastas (patikrinta 2026-10-13): tekstas, --muted ir
   --accent ant --bg, --surface, --bot-bg, --accent-soft >= 5,5:1 abiem temomis;
   --on-accent ant --accent >= 6,5:1; --on-cta ant --cta >= 6,3:1; --cta ant --surface
   >= 6,8:1 (valdiklio kraštas); --control >= 3,3:1. Oranžinis šviesioje temoje mygtukui
   netinka (2,2:1 ant baltos), todėl ten mygtukas tamsiai mėlynas. */
:root {
  color-scheme: light;
  --font: 'Nunito Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --bg: #f8f8f8;
  --surface: #ffffff;
  --border: #e6e8ea;
  --control: #7f8a91;
  --text: #212c34;
  --muted: #545f68;
  --accent: #03648d;
  --on-accent: #ffffff;
  --accent-soft: #e3eff5;
  --bot-bg: #f3f4f5;
  --cta: #002939;
  --on-cta: #ffffff;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  /* Diagramų serijos (modeliai) — validuota spalvų aklumui (dataviz validate_palette) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4;
  --radius: 12px;
  --maxw: 760px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #001c27;
    --surface: #002939;
    --border: #13465a;
    --control: #6f95a5;
    --text: #eaf1f4;
    --muted: #a6bac3;
    --accent: #7cc6e6;
    --on-accent: #00202d;
    --accent-soft: #0d3b4e;
    --bot-bg: #06303f;
    --cta: #ff905f;
    --on-cta: #212c34;
    --danger: #f2b8b5;
    --danger-soft: #3b2120;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #001c27;
  --surface: #002939;
  --border: #13465a;
  --control: #6f95a5;
  --text: #eaf1f4;
  --muted: #a6bac3;
  --accent: #7cc6e6;
  --on-accent: #00202d;
  --accent-soft: #0d3b4e;
  --bot-bg: #06303f;
  --cta: #ff905f;
  --on-cta: #212c34;
  --danger: #f2b8b5;
  --danger-soft: #3b2120;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

a { color: var(--accent); }

/* Matomas fokusas klaviatūrai (2.4.7) — visiems valdikliams vienodai */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chat {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 16px 32px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.chat__head { margin-bottom: 16px; }

.chat__title {
  margin: 0 0 4px;
  font-size: 1.4rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.chat__sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.chat__sub a { color: var(--accent); }
.chat__updated { white-space: nowrap; }

/* --- pokalbio juosta --- */

.chat__log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 0 16px;
}

.msg { display: flex; }
.msg--user { justify-content: flex-end; }

.msg__body {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--bot-bg);
  border: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.msg--user .msg__body {
  background: var(--accent-soft);
  border-color: transparent;
}

.msg__body p { margin: 0 0 0.7em; }
.msg__body p:last-child { margin-bottom: 0; }
.msg__body ul, .msg__body ol { margin: 0 0 0.7em; padding-left: 1.3em; }

/* Lentelė atsakyme (common.js tableHtml) — plati slenka į šoną pati, ne puslapis */
.msg__table {
  /* relative: citatų .sr-only (position: absolute) kitaip „ištrūksta" iš slinkimo
     ir visas pokalbis telefone slenka į šoną */
  position: relative;
  max-width: 100%;
  overflow-x: auto;
  margin: 0 0 0.5em;
  /* Be atskiro rėmelio (kortelė kortelėje); kai lentelė platesnė už burbulą, krašte
     atsiranda šešėlis — matyti, kad galima slinkti (local dangalai jį paslepia kraštuose) */
  --table-bg: var(--bot-bg);  /* dangalų spalva = fonas po lentele (istorijoje — kitas) */
  background:
    linear-gradient(to right, var(--table-bg) 40%, transparent) left / 28px 100% no-repeat local,
    linear-gradient(to left, var(--table-bg) 40%, transparent) right / 28px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgb(0 0 0 / 0.18), transparent) left / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgb(0 0 0 / 0.18), transparent) right / 12px 100% no-repeat scroll;
}
.qa__body .msg__table { --table-bg: var(--surface); }
.msg__table:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.msg__table table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.875rem;
  line-height: 1.4;
}
.msg__table th,
.msg__table td {
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.msg__table th {
  font-weight: 650;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.msg__table th:first-child, .msg__table td:first-child { padding-left: 0; }
.msg__table tbody tr:last-child td { border-bottom: 0; }
.msg__table td { font-variant-numeric: tabular-nums; }
.msg__table .num { text-align: right; white-space: nowrap; }
.msg__table .nw { white-space: nowrap; }

/* Telefone (siauras burbulas) lentelė su antrašte — eilutė virsta bloku: pavadinimas
   viršuje, kitos reikšmės po juo su stulpelio pavadinimu. Taip nereikia slinkti į šoną,
   o pirmas stulpelis nebesuspaudžiamas po žodį eilutėje (kritika 2026-11-17). */
@media (max-width: 520px) {
  .msg__table:has(thead) { overflow: visible; background: none; }
  .msg__table:has(thead) table,
  .msg__table:has(thead) tbody,
  .msg__table:has(thead) tr,
  .msg__table:has(thead) td { display: block; width: auto; }
  .msg__table:has(thead) thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
  }
  .msg__table:has(thead) tr { padding: 8px 0; border-bottom: 1px solid var(--border); }
  .msg__table:has(thead) tbody tr:first-child { border-top: 2px solid var(--border); }
  .msg__table:has(thead) tbody tr:last-child { border-bottom: 0; }
  .msg__table:has(thead) td { padding: 1px 0; border: 0; text-align: left; white-space: normal; }
  .msg__table:has(thead) td:first-child { min-width: 0; margin-bottom: 2px; }
  .msg__table:has(thead) td[data-label] { display: flex; gap: 12px; justify-content: space-between; }
  .msg__table:has(thead) td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
  }
  .msg__table:has(thead) td[data-label]:empty { display: none; }
}
/* Pirmas stulpelis — eilutės pavadinimas; siaurame ekrane per daug nesuspaudžiamas */
.msg__table td:first-child { min-width: 8em; font-weight: 600; }
.msg__body li { margin-bottom: 0.3em; }
.msg__body strong { font-weight: 640; }

/* Atsakymo struktūra (common.js render): esmė — antraštės su metais — suskleistos išimtys */
.msg__lead {
  font-weight: 600;
  font-size: 1.0625rem;
  line-height: 1.5;
}
.msg__h {
  margin: 1em 0 0.35em;
  font-size: 0.9375rem;
  font-weight: 650;
  line-height: 1.35;
}
.msg__body > .msg__h:first-child { margin-top: 0; }
.msg__year {
  display: inline-block;
  margin-right: 0.35em;
  padding: 0 0.45em;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.msg__more {
  margin: 0.8em 0 0.4em;
  border-top: 1px solid var(--border);
  padding-top: 0.5em;
}
.msg__more > summary {
  cursor: pointer;
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 0.4em;
  font-weight: 650;
  font-size: 0.9375rem;
  color: var(--accent);
  list-style: none;
}
.msg__more > summary::-webkit-details-marker { display: none; }
.msg__more > summary::before {
  content: "";
  width: 0.5em; height: 0.5em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease-out;
}
.msg__more[open] > summary::before { transform: rotate(45deg); }
.msg__more > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { .msg__more > summary::before { transition: none; } }

/* Citata [1] atsakyme — tylus viršutinis indeksas, prigludęs prie žodžio (dizaino kritika
   2026-11-17: užpildyti 24 px ženkliukai buvo sunkesni už patį tekstą). Paspaudimo plotas
   lieka ≥24x24 px (2.5.8) — nematomas ::after. */
.cite {
  position: relative;
  /* inline (ne inline-block): be tarpo eilutė prieš citatą nelūžta — indeksas nenukrenta
     į atskirą eilutę po „val." */
  display: inline;
  padding: 0 1px;
  color: var(--accent);
  font-size: 0.72em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  vertical-align: 0.5em;
  text-decoration: none;
}
.cite::after { content: ""; position: absolute; inset: -6px -8px; }
/* Dvi citatos iš eilės — su kableliu, kad „¹²" neatrodytų kaip 12 */
.cite + .cite::before { content: ","; margin-right: 2px; color: var(--muted); font-weight: 400; }
a.cite:hover { text-decoration: underline; text-underline-offset: 2px; }
a.cite:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* „Šaltinis: 1" po lentele ar sąrašu (common.js tidyCites) — tyli eilutė, numeris įprasto dydžio */
.msg__body .msg__src { font-size: 0.8125rem; color: var(--muted); }
.msg__src .cite { font-size: 1em; vertical-align: baseline; padding: 0 2px; }
/* „Šaltiniai nesutaria: …" (prompto 7 taisyklė) — matomas įspėjimas */
.msg__body .msg__warn {
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--text);
}

/* --- šaltiniai --- */

.sources {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

/* Šaltiniai — patikrinimo vieta, ne smulkus užrašas: įprastos raidės, teksto spalva */
.sources__title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 650;
  color: var(--text);
}

/* Šaltiniai suskleisti (common.js renderSources): atsakymas — pirmas, šaltiniai — paspaudus
   arba paspaudus citatą [n] */
.sources > summary,
.sources__more > summary {
  cursor: pointer;
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 0.45em;
  list-style: none;
}
.sources > summary::-webkit-details-marker,
.sources__more > summary::-webkit-details-marker { display: none; }
.sources > summary::before,
.sources__more > summary::before {
  content: "";
  width: 0.45em; height: 0.45em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease-out;
}
.sources[open] > summary::before,
.sources__more[open] > summary::before { transform: rotate(45deg); }
.sources > summary:hover,
.sources__more > summary:hover { color: var(--accent); }
.sources > summary:focus-visible,
.sources__more > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sources[open] > .sources__list { margin-top: 6px; }
.sources__more {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--muted);
}
.sources__more[open] > .sources__list { margin-top: 6px; }
.sources__ns { flex: 0 0 auto; display: inline-flex; gap: 3px; }
@media (prefers-reduced-motion: reduce) {
  .sources > summary::before, .sources__more > summary::before { transition: none; }
}

.sources__list { margin: 0; padding: 0; list-style: none; }

.sources__item {
  display: flex;
  gap: 7px;
  font-size: 0.82rem;
  margin-bottom: 5px;
  line-height: 1.45;
}

.sources__n {
  flex: 0 0 auto;
  min-width: 1.3em;
  height: 1.3em;
  border-radius: 4px;
  background: var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.3em;
}

.sources__item a { color: var(--accent); text-underline-offset: 2px; }
a.sources__n { text-decoration: none; color: var(--muted); }
a.sources__n:hover { background: var(--accent-soft); color: var(--accent); }
.sources__item a:hover { text-decoration-thickness: 2px; }
.sources__item:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sources__meta { color: var(--muted); }

/* --- rašymo indikatorius --- */

.typing { display: inline-flex; gap: 4px; padding: 3px 0; }

.typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1.3s infinite both;
}

.typing span:nth-child(2) { animation-delay: 0.18s; }
.typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes blink {
  0%, 70%, 100% { opacity: 0.25; }
  35% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .typing span { animation: none; opacity: 0.6; }
}

/* --- pavyzdiniai klausimai --- */

.chat__examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
/* Pavyzdžiai — po pasveikinimu pokalbio juostoje, ne prie formos: tuščioje būsenoje
   turinys kartu viršuje, o ne išsklaidytas per visą rėmelį (dizaino kritika P3) */
.chat__log > .chat__examples { margin: 2px 0 0; }
/* Telefone — viena slenkama eilutė, ne trys */
@media (max-width: 520px) {
  .chat__examples {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
  }
  .chat__examples .chip { flex: 0 0 auto; scroll-snap-align: start; }
}

.chip {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--control);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.chip:hover { border-color: var(--accent); color: var(--accent); }

/* --- forma --- */

.chat__form {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--control);
  border-radius: var(--radius);
}

/* Laukas pats rėmelio neturi — fokusą rodo visa forma */
.chat__form:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chat__form textarea {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  resize: none;
  max-height: 160px;
  padding: 6px 4px;
  outline: none;
}

.chat__form button {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: var(--cta);
  color: var(--on-cta);
  cursor: pointer;
}

.chat__form button:disabled { opacity: 0.45; cursor: default; }

/* Generuojant siuntimo mygtukas — „Sustabdyti" (kvadratas) */
.chat__form button.is-stop { background: var(--text); color: var(--surface); }

/* --- paveikslėlis (chat.js: atestatas, egzaminų rezultatai, ekrano kopija) --- */
.chat__form .chat__attach-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}
.chat__form .chat__attach-btn:hover { color: var(--accent); border-color: var(--border); }
.chat__form .chat__attach-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chat__form .chat__attach-btn[hidden] { display: none; }

.chat__attached {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: var(--danger-soft);
}
.chat__attached[hidden] { display: none; }
body.embed .chat__attached { flex: 0 0 auto; }
.chat__attached img {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.chat__attached-text { flex: 1; min-width: 0; display: grid; gap: 2px; font-size: 0.8125rem; }
.chat__attached-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat__attached-warn { color: var(--text); line-height: 1.35; }
.chat__attached-x {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 1px solid var(--control);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.chat__attached-x:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chat__attached .chat__pdf { flex: 0 0 auto; width: 44px; height: 44px; color: var(--danger); }
.msg__file { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: 0.875rem; font-weight: 600; }
.msg__file .chat__pdf { flex: 0 0 auto; color: var(--accent); }
.msg__img { margin: 0 0 6px; }
.msg__img img { display: block; max-width: min(220px, 100%); max-height: 220px; border-radius: 8px; }
.msg__read { margin-top: 6px; font-size: 0.8125rem; }
.msg__read summary { cursor: pointer; font-weight: 600; }
.msg__read pre {
  margin: 6px 0 0;
  white-space: pre-wrap;
  font: inherit;
  max-height: 240px;
  overflow: auto;
}
.msg__read p { margin: 4px 0 0; color: var(--danger); }

.chat__privacy {
  max-width: min(520px, calc(100vw - 32px));
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9375rem;
  line-height: 1.45;
}
.chat__privacy::backdrop { background: rgb(0 0 0 / 0.45); }
.chat__privacy h2 { margin: 0 0 10px; font-size: 1.125rem; }
.chat__privacy ul { padding-left: 1.2em; margin: 8px 0 16px; }
.chat__privacy li { margin: 4px 0; }
.chat__privacy-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.chat__privacy-actions button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 9px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.chat__privacy-no { border: 1px solid var(--control); background: var(--surface); color: var(--text); }
.chat__privacy-ok { border: 0; background: var(--cta); color: var(--on-cta); }
.chat__privacy-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* „Naujas pokalbis" — virš pokalbio, tik kai pokalbis yra */
.chat__tools {
  display: flex;
  justify-content: flex-end;
  margin: -4px 0 6px;
}
.chat__tools[hidden] { display: none; }
body.embed .chat__tools { flex: 0 0 auto; }
.chat__new,
.chat__retry {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}
.chat__new:hover,
.chat__retry:hover { border-color: var(--accent); }
.chat__new:focus-visible,
.chat__retry:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.msg__retry { font-size: 0.875rem; color: var(--muted); }
.msg__retry .chat__retry { margin-right: 8px; vertical-align: middle; }
.msg__retry a { color: var(--accent); }
.msg__stopped { margin-top: 0.6em; font-size: 0.875rem; color: var(--muted); font-style: italic; }

/* „Į pabaigą": pokalbis per srautą nebeslenka pats — atsakymas skaitomas nuo pradžios */
/* Dešinėje, ne per vidurį: mažiau uždengia tekstą ir lenteles (kritika 2026-11-17) */
.chat__form .chat__jump {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 12px;
  width: auto;
  height: auto;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.12);
}
.chat__form .chat__jump[hidden] { display: none; }
.chat__form .chat__jump:hover { border-color: var(--accent); }
.chat__form .chat__jump:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chat__foot {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
  text-align: center;
}

.error {
  color: var(--danger);
  font-size: 0.86rem;
}

/* --- Navigacija tarp puslapių --- */
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 18px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: fit-content;
  max-width: 100%;
}
.nav a {
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
}
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent); color: var(--on-accent); }

/* Navigacija + temos perjungiklis vienoje eilutėje (assets/theme.js) */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin: 0 0 18px;
}
.topbar .nav { margin: 0; }
.theme {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.theme button {
  min-height: 28px;
  padding: 3px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.theme button:hover { color: var(--text); }
.theme button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--control);
}

/* --- Modelio pasirinkimas --- */
.chat__model {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--muted);
}
.chat__model select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--control);
  border-radius: 8px;
  padding: 4px 8px;
  max-width: 100%;
}

/* Pastaba po kiekvieno atsakymo: DI klaidos ir kontaktai */
.msg__note {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border, currentColor);
  font-size: 0.8125rem;
  color: var(--muted);
}
.msg__note a { color: var(--accent); overflow-wrap: anywhere; }

.msg__meta {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* --- Istorija --- */
.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 16px 48px;
}
.page h1 { margin: 0 0 4px; font-size: 1.4rem; font-weight: 650; }
.page .lead { margin: 0 0 18px; color: var(--muted); font-size: 0.92rem; }

.qa {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 14px;
  overflow: hidden;
}
.qa__head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: baseline;
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.qa__q { flex-basis: 100%; margin: 2px 0 0; font-size: 1rem; font-weight: 620; color: var(--text); }
.qa__badge {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.qa__badge--bad { background: var(--danger-soft); color: var(--danger); }
.qa__body { padding: 12px 14px; font-size: 0.93rem; }
.qa__body p { margin: 0 0 0.6em; }
.qa__body ul, .qa__body ol { margin: 0 0 0.6em; padding-left: 1.3em; }
.qa details { padding: 0 14px 12px; font-size: 0.82rem; color: var(--muted); }
.qa details ul { margin: 6px 0 0; padding-left: 1.2em; }
.qa details a { color: var(--accent); }

.more {
  display: block;
  margin: 18px auto 0;
  font: inherit;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--control);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.more:hover { border-color: var(--accent); }
.notice {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}
.notice code { color: var(--text); }
.more[hidden] { display: none; }

/* Pokalbis istorijoje: keli klausimai vienoje kortelėje */
.turn { padding: 12px 14px 4px; border-top: 1px solid var(--border); }
.turn:first-of-type { border-top: 0; }
.turn__meta {
  display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline;
  font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums;
}
.turn .qa__q { margin: 4px 0 6px; font-size: 0.98rem; }
.turn .qa__body { padding: 0; }
.turn details { padding: 0 0 8px; }
.qa__head a { color: var(--accent); }
.lead code, .lead a { color: var(--accent); }

/* Istorijos prieigos valdymas */
.admin {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; margin: 0 0 18px; font-size: 0.9rem;
}
.admin summary { cursor: pointer; font-weight: 620; }
.admin__hint { color: var(--muted); margin: 10px 0 6px; }
.admin__ips { list-style: none; margin: 0 0 10px; padding: 0; }
.admin__ips li {
  display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center;
  padding: 6px 0; border-bottom: 1px solid var(--border);
}
.admin__note, .admin__fixed { color: var(--muted); font-size: 0.82rem; flex: 1; }
.admin__add { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; align-items: flex-end; }
.admin__add label {
  display: flex; flex-direction: column; gap: 2px; flex: 1 1 180px;
  font-size: 0.8rem; color: var(--muted);
}
.admin__add input {
  font: inherit; font-size: 0.9rem; padding: 6px 10px; color: var(--text);
  background: var(--bg); border: 1px solid var(--control); border-radius: 8px;
}
.admin button {
  font: inherit; font-size: 0.85rem; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--control); background: var(--bg); color: var(--text);
}
.admin button:hover { border-color: var(--accent); }
.admin__feature { border-top: 1px solid var(--border); padding-top: 10px; margin-bottom: 12px; }
.admin__feature p { margin: 0 0 8px; }
.admin__feature #img-state { font-weight: 700; color: var(--accent); }
.admin__feature #img-state.bad { color: var(--danger); }
.admin__danger { border-top: 1px solid var(--border); padding-top: 10px; }
.admin__danger p { margin: 0 0 8px; color: var(--muted); }
.admin__danger button { border-color: var(--danger); color: var(--danger); }
.admin__msg { margin: 8px 0 0; color: var(--accent); min-height: 1.2em; }
.admin__msg.bad { color: var(--danger); }
.admin[hidden] { display: none; }

/* Šaltinių puslapis */
.src-filter {
  width: 100%; font: inherit; padding: 8px 12px; margin: 0 0 18px; color: var(--text);
  background: var(--surface); border: 1px solid var(--control); border-radius: var(--radius);
}
.src-group h2 { font-size: 1.05rem; margin: 22px 0 6px; }
.src-group h3 { font-size: 0.9rem; margin: 12px 0 4px; color: var(--muted); font-weight: 600; }
.src-list { list-style: none; margin: 0; padding: 0; }
.src-list li {
  padding: 8px 12px; margin: 0 0 6px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
}
.src-list a { color: var(--accent); text-underline-offset: 2px; }
.src-list a:hover { text-decoration-thickness: 2px; }
.src-meta { display: block; font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

/* Išlaidų puslapis (costs.html) */
.page--wide { max-width: 960px; }
.page h2 { font-size: 1.1rem; margin: 28px 0 8px; }
.costs__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 16px; }
.costs__csv { margin: 0; }
.costs__csv:disabled { opacity: 0.5; cursor: default; }
/* Analizės puslapis (analize.html) */
.an__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin: 0 0 16px; }
.an__bar .costs__csv { margin-left: auto; }
.an__check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.88rem; color: var(--muted); cursor: pointer; }
.an__check input { width: 16px; height: 16px; accent-color: var(--accent); }
.tiles .tile--text dd { font-size: 1rem; line-height: 1.3; }
.an__bar .seg { flex-wrap: wrap; max-width: 100%; border-radius: 20px; }
.an__bar .seg button { white-space: nowrap; }
.an__tbl tbody tr.is-on th, .an__tbl tbody tr.is-on td { background: var(--accent-soft); }
.an__tbl .is-col { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
.an__topic {
  font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer;
  text-align: left; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
  text-underline-offset: 3px;
}
.an__topic:hover { text-decoration-color: currentColor; }
.an__topic[aria-pressed="true"] { font-weight: 650; }
.an__barcell { position: relative; min-width: 120px; width: 30%; }
.an__bar-fill { position: absolute; left: 12px; top: 50%; height: 10px; max-width: calc(100% - 64px); transform: translateY(-50%); background: var(--accent); border-radius: 0 3px 3px 0; }
.an__pct { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.an__zero { color: var(--muted); }
.an__top, .an__list { margin: 0; padding: 0; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.an__top li, .an__list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.an__top li:last-child, .an__list li:last-child { border-bottom: 0; }
.an__count { min-width: 2.5em; font-weight: 650; font-variant-numeric: tabular-nums; }
.an__q { flex: 1 1 260px; overflow-wrap: anywhere; }
.an__when { flex-basis: 100%; font-size: 0.78rem; color: var(--muted); }
.an__conv { margin-left: auto; font-size: 0.82rem; color: var(--accent); white-space: nowrap; }
.an__n { font-weight: 400; color: var(--muted); }
.an__clear { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }
@media (max-width: 520px) { .an__bar .costs__csv { margin-left: 0; } }
/* Segmentuotas pasirinkimas — kaip temos perjungiklis */
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--control); border-radius: 999px; }
.seg button {
  min-height: 32px; padding: 4px 14px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); font: inherit; font-size: 0.88rem; cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0 0 18px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tile dt { font-size: 0.8rem; color: var(--muted); }
.tile dd { margin: 2px 0 0; font-size: 1.45rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile__sub { display: block; font-size: 0.75rem; font-weight: 400; color: var(--muted); }

.chart { margin: 0 0 8px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.chart__wrap { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart__grid { stroke: var(--border); stroke-width: 1; }
.chart__axis { stroke: var(--control); stroke-width: 1; }
.chart__tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart__hit { fill: transparent; }
.chart__col { transition: opacity 0.12s; }
.chart svg.has-active .chart__col:not(.is-active) { opacity: 0.45; }
@media (prefers-reduced-motion: reduce) { .chart__col { transition: none; } }
.chart__tip {
  position: absolute; z-index: 2; pointer-events: none; min-width: 190px;
  padding: 8px 10px; background: var(--surface); color: var(--text);
  border: 1px solid var(--control); border-radius: 8px;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.18); font-size: 0.8rem;
}
.chart__tip p { margin: 0 0 4px; }
.chart__tipdate { font-weight: 600; }
.chart__tip table { border-collapse: collapse; width: 100%; }
.chart__tip td { padding: 1px 0; }
.chart__tip td.num { padding-left: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.chart__tiptotal td { border-top: 1px solid var(--border); padding-top: 3px; font-weight: 600; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 8px; padding: 0; list-style: none; font-size: 0.82rem; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }

.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.tbl { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.tbl th, .tbl td { padding: 7px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.tbl thead th { font-size: 0.78rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tbl tbody th { font-weight: 500; }
.tbl tbody tr:last-child th, .tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tfoot th, .tbl tfoot td { border-top: 1px solid var(--control); border-bottom: 0; font-weight: 650; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .src-meta { margin-top: 0; }

/* Istorija: klausimo perrašymas paieškai (app/rewrite.py) */
.turn__queries { margin: -2px 0 8px; font-size: 0.8rem; color: var(--muted); }

/* --- Įterptas „Klausk" (klausk.html, body.embed) lamabpo.lt iframe --- */
/* permatomas tik šviesioje temoje (lamabpo.lt šviesus); tamsi/auto turi savo foną, kitaip tekstas nesimatytų */
:root[data-theme="light"] body.embed { background: transparent; }
body.embed .chat {
  height: 100vh;          /* iframe aukštį nustato embed.js; slenka pokalbis, ne puslapis */
  min-height: 0;
  max-width: none;
  margin: 0;
  padding: 12px 14px 10px;
}
body.embed .chat__sub { margin-bottom: 10px; }
body.embed .chat__log { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-bottom: 8px; } /* relative: .sr-only (absolute) turi būti apkirpti, kitaip išplečia visą iframe dokumentą */
body.embed { overflow: hidden; }
body.embed .chat__form { position: relative; flex: 0 0 auto; } /* relative: „Į pabaigą" (.chat__jump) virš formos */
body.embed .chat__examples { flex: 0 0 auto; }
body.embed .chat__foot { flex: 0 0 auto; margin-top: 6px; }
