:root {
  --bg: #f4f1ea;
  --panel: #fffdf8;
  --ink: #1c1a17;
  --muted: #6b655c;
  --line: #ddd6c8;
  --accent: #7a1f2b;        /* burgund — sądowa powaga */
  --accent-soft: #f0e3e1;
  --support: #1f5c4a;       /* zieleń — "popiera" */
  --contra: #9a2f2f;        /* czerwień — "zaprzecza" */
  --shadow: 0 2px 14px rgba(40, 30, 20, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* atrybut hidden musi wygrać z display:flex/grid/block */
html, body { margin: 0; }
body.modal-open { overflow: hidden; }   /* brak scrolla strony, gdy otwarty modal */
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* --- Topbar --- */
.topbar {
  /* 3 kolumny: brand | nav | status. Środek (1fr auto 1fr) trzyma nav wycentrowane
     niezależnie od szerokości brandu (dłuższy tagline na „/" nie przesuwa nav). */
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 16px 28px; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand-link { text-decoration: none; color: inherit; }
.brand-link:hover .logo { background: var(--accent); color: var(--panel); }
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  font: 700 30px/1 Georgia, serif; color: var(--accent);
  width: 46px; height: 46px; display: grid; place-items: center;
  background: var(--accent-soft); border-radius: 10px;
}
.topbar h1 { margin: 0; font: 600 22px/1 Georgia, serif; letter-spacing: .3px; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.status {
  font-size: 12px; color: var(--muted); background: var(--bg);
  padding: 6px 12px; border-radius: 20px; border: 1px solid var(--line);
}

.nav { display: flex; gap: 6px; justify-self: center; }
.status { justify-self: end; }
.nav a {
  font-size: 13px; color: var(--muted); text-decoration: none;
  padding: 7px 14px; border-radius: 8px; border: 1px solid transparent;
}
.nav a:hover { background: var(--bg); }
.nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* Mobile: topbar nie mieści się w jednym rzędzie → zawijaj.
   Nawigacja schodzi do własnego rzędu, tagline znika, status się kurczy. */
@media (max-width: 640px) {
  .topbar { display: flex; flex-wrap: wrap; gap: 10px 12px; padding: 12px 16px; }
  .nav { justify-self: auto; }
  .status { justify-self: auto; }
  .brand { gap: 10px; }
  .logo { width: 38px; height: 38px; font: 700 24px/1 Georgia, serif; }
  .topbar h1 { font-size: 19px; }
  .tagline { display: none; }          /* oszczędność wysokości */
  .status { order: 2; font-size: 11px; padding: 5px 10px; white-space: nowrap; }
  .nav { order: 3; width: 100%; justify-content: center; }
  .nav a { padding: 7px 12px; }
}

main { max-width: 1080px; margin: 0 auto; padding: 26px 20px 60px; }

.loading {
  background: var(--accent-soft); color: var(--accent); font-size: 13px;
  padding: 9px 10px 9px 16px; border-radius: 10px; margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px;
}
.loading::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 2px solid var(--accent); border-top-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* Wszystkie przyciski sterujące = lekkie pigułki w stylu .badge (spójność).
   Bazowy wygląd: stonowane tło, cienka ramka, akcent na hover. */
#loadingMsg { flex: 1; }
.pill-btn, .stop-btn, .action-btn, .card-btn {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  font-size: 12px; font-weight: 600; line-height: 1.4; cursor: pointer;
  padding: 5px 12px; border-radius: 20px;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
  transition: background .12s, color .12s, border-color .12s;
}
.pill-btn:hover, .action-btn:hover, .card-btn:hover {
  color: var(--accent); border-color: var(--accent); background: var(--accent-soft);
}

/* Akcje w pasku podsumowania — lekko mocniejszy akcent */
.summary-actions { display: flex; gap: 8px; }
.action-btn { color: var(--accent); }
.action-btn.ghost { color: var(--muted); }
.action-btn.ghost:hover { color: var(--ink); border-color: var(--line); background: var(--bg); }

/* Przyciski na karcie wyniku */
.card-actions { margin-left: auto; display: inline-flex; gap: 6px; align-items: center; }
.stance-actions { display: inline-flex; gap: 6px; align-items: center; }
.info-btn {
  border: 0; background: none; cursor: pointer; color: var(--muted);
  font-size: 15px; line-height: 1; padding: 2px 4px; border-radius: 50%;
}
.info-btn:hover { color: var(--accent); background: var(--accent-soft); }

/* Ignoruj wynik (czarna lista) — ikona obok ⓘ, czerwona na hover */
.ignore-btn {
  border: 0; background: none; cursor: pointer; color: var(--muted);
  font-size: 13px; line-height: 1; padding: 2px 5px; border-radius: 50%;
}
.ignore-btn:hover { color: var(--contra); background: #f5e0e0; }
.v2 #restoreIgnoredBtn { font-size: 12.5px; padding: 5px 11px; }

/* Popover ze szczegółami dopasowania */
.info-pop {
  position: absolute; z-index: 30; width: 240px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(40,30,20,.18); padding: 12px 14px;
  font-size: 12.5px; color: var(--ink);
}
.info-pop-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); font-weight: 600; margin-bottom: 8px;
}
.info-row { padding: 2px 0; color: #45433d; }
.card-btn { padding: 4px 11px; }
.card-btn.classify { color: var(--accent); }
.card-btn.refresh { padding: 4px 10px; }

/* Stop — jedyny w kolorze danger, ale ten sam kształt pigułki */
.stop-btn { color: var(--contra); background: #fff; border-color: var(--contra); }
.stop-btn:hover { background: var(--contra); color: #fff; border-color: var(--contra); }

.more {
  display: block; width: 100%; margin-top: 6px; padding: 12px;
  font-size: 14px; font-weight: 600; color: var(--accent); cursor: pointer;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 12px;
}
.more:hover { background: var(--accent-soft); }
.more:disabled { cursor: progress; opacity: .75; }
.more.busy { display: flex; align-items: center; justify-content: center; gap: 8px; }
.more.busy::before {
  content: ""; width: 13px; height: 13px; border-radius: 50%; flex: none;
  border: 2px solid var(--accent); border-top-color: transparent;
  animation: spin .7s linear infinite;
}

.badge.pending { background: #fff3da; color: #8a6d1f; }

/* --- Searchbar --- */
.searchbar { display: flex; gap: 10px; margin-bottom: 22px; align-items: stretch; }
.searchbar input {
  flex: 1; min-width: 0; padding: 14px 18px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
  box-shadow: var(--shadow);
}
.searchbar input:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* Pole sygnatury + dropdown historii wyszukiwań (🕘) */
.sig-input-wrap { position: relative; display: flex; flex: 1; min-width: 0; }
.sig-input-wrap input { flex: 1; padding-right: 46px; }
.sig-history-btn {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  border: 0; background: none; cursor: pointer; font-size: 17px; line-height: 1;
  padding: 6px; border-radius: 8px; opacity: .6; transition: opacity .12s, background .12s;
}
.sig-history-btn:hover, .sig-history-btn[aria-expanded="true"] { opacity: 1; background: var(--accent-soft); }
.sig-history-menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 20; list-style: none;
  margin: 0; padding: 6px; width: 320px; max-width: 90vw; max-height: 56vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 36px rgba(40,30,20,.22);
}
.sig-history-item {
  padding: 9px 12px; font-size: 14px; color: var(--ink); border-radius: 8px; cursor: pointer;
}
.sig-history-item:hover { background: var(--accent-soft); color: var(--accent); }
.sig-history-empty { padding: 10px 12px; font-size: 13px; color: var(--muted); }
.sig-history-clear {
  margin-top: 4px; padding: 9px 12px; font-size: 12.5px; color: var(--muted);
  border-top: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
.sig-history-clear:hover { background: var(--accent-soft); color: var(--contra); }

.tpl-wrap { position: relative; display: flex; }
.tpl-btn {
  display: inline-flex; align-items: center; white-space: nowrap;
  font-size: 13.5px; color: var(--muted); background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; padding: 0 16px; cursor: pointer;
  box-shadow: var(--shadow);
}
.tpl-btn:hover, .tpl-btn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }
.tpl-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 20;
  width: 360px; max-width: 78vw; max-height: 60vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 36px rgba(40,30,20,.22); padding: 6px;
}
.tpl-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); padding: 8px 12px 6px; font-weight: 600;
}
.tpl-item {
  display: block; width: 100%; text-align: left; padding: 9px 12px;
  font-size: 13.5px; line-height: 1.35; color: var(--ink); background: none; border: 0;
  border-radius: 8px; cursor: pointer;
}
.tpl-item:hover { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 600px) { .tpl-btn { padding: 0 10px; font-size: 12px; } }
#searchBtn, #exploreBtn {
  padding: 0 26px; font-size: 15px; font-weight: 600; color: #fff;
  background: var(--accent); border: 0; border-radius: 12px; cursor: pointer; white-space: nowrap;
}
#searchBtn:hover, #exploreBtn:hover { background: #631824; }
#searchBtn:disabled, #exploreBtn:disabled { opacity: .6; cursor: progress; }

/* Gwiazdka ulubionych */
.star-btn {
  border: 0; background: none; cursor: pointer; font-size: 16px; line-height: 1;
  color: var(--line); padding: 2px 4px; border-radius: 6px; transition: color .12s;
}
.star-btn:hover { color: #d9a400; }
.star-btn.on { color: #e8b500; }

/* --- Layout --- */
.layout { display: grid; grid-template-columns: 230px 1fr; gap: 24px; }
@media (max-width: 760px) { .layout { grid-template-columns: 1fr; } }

.filters {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; height: fit-content; box-shadow: var(--shadow);
}
.filters h2 { margin: 0 0 14px; font: 600 14px/1 Georgia, serif; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.filters label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.filters select, .filters input[type=date], .filters input[type=number] {
  width: 100%; margin-top: 5px; padding: 8px 10px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
.filters .checkbox { display: flex; align-items: center; gap: 8px; }
.filters .checkbox input { width: auto; margin: 0; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* --- Results --- */
.placeholder { color: var(--muted); padding: 40px 10px; text-align: center; }
.result {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 20px; margin-bottom: 14px; box-shadow: var(--shadow);
  cursor: pointer; transition: border-color .12s, transform .12s;
}
.result:hover { border-color: var(--accent); transform: translateY(-1px); }
.result .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.badge {
  font-size: 11.5px; padding: 3px 9px; border-radius: 20px;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
}
.badge.sig { font-weight: 600; color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.badge.court { font-weight: 600; }
.recall-note { margin-top: 6px; font-size: 13.5px; color: #6b6258; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge.score { margin-left: auto; font-variant-numeric: tabular-nums; }
.result .snippet { font-size: 14.5px; color: #2c2822; }
.snippet mark, .document mark { padding: 0 2px; border-radius: 3px; }
.snippet mark.exact, .document mark.exact { background: #bfe6c9; color: #1f5c4a; } /* dokładne — zielony */
.snippet mark.fam, .document mark.fam { background: #fbe7a2; }                /* rodzina form — żółty */
.snippet mark:not(.exact):not(.fam) { background: #bfe6c9; }                  /* fallback */
.result .ranks { margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.result .reason {
  margin-top: 8px; font-size: 13px; color: #4a443b; font-style: italic;
  border-left: 3px solid var(--line); padding-left: 10px;
}

/* Badge stanowiska (popiera / zaprzecza / neutralny) */
.badge.stance { font-weight: 600; border: 0; }
.badge.stance.support { background: #e1efe9; color: var(--support); }
.badge.stance.contra  { background: #f5e0e0; color: var(--contra); }
.badge.stance.neutral { background: var(--bg); color: var(--muted); }
.badge.stance .votes { opacity: .7; font-variant-numeric: tabular-nums; font-weight: 700; }

/* Pasek filtra po stanowisku (popiera/zaprzecza/neutralny) */
.stance-filter {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin: -2px 0 16px;
}
.stance-filter .sf-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); font-weight: 600; margin-right: 2px;
}
.stance-chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: 12px; font-weight: 600; line-height: 1.4;
  padding: 5px 11px; border-radius: 20px;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
  transition: background .12s, color .12s, border-color .12s;
}
.stance-chip:hover { border-color: var(--accent); }
.stance-chip .cnt {
  font-variant-numeric: tabular-nums; font-weight: 700;
  background: rgba(0,0,0,.05); border-radius: 10px; padding: 0 6px; font-size: 11px;
}
.stance-chip.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.stance-chip.active .cnt { background: rgba(255,255,255,.22); }
.stance-chip.popiera.active   { background: var(--support); border-color: var(--support); }
.stance-chip.zaprzecza.active { background: var(--contra);  border-color: var(--contra); }

.summary {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; font-size: 13px; color: var(--muted); gap: 12px;
  flex-wrap: wrap;
}
.summary-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mode-badge {
  font-weight: 600; color: var(--accent); background: var(--accent-soft);
  padding: 3px 10px; border-radius: 20px;
}

/* --- Modal --- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(28, 24, 18, .5);
  display: grid; place-items: center; padding: 20px; z-index: 10;
}
.modal-backdrop[hidden] { display: none; }  /* atrybut hidden musi wygrać z display:grid */
.modal {
  background: var(--panel); border-radius: 16px; max-width: 980px; width: 100%;
  max-height: 86vh; overflow: auto; padding: 28px 32px; position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal .close {
  position: absolute; top: 14px; right: 16px; border: 0; background: none;
  font-size: 30px; line-height: 1; color: var(--muted); cursor: pointer;
}
.modal h2 { font: 600 20px/1.3 Georgia, serif; margin: 0 0 6px; color: var(--accent); }
.modal .doc-meta { font-size: 13px; color: var(--muted); }

/* Sędziowie: klikalne chipy + panel „sprawy sędziego" */
.judges-line { margin-top: 6px; }
.judge-chip {
  display: inline-flex; font-size: 12px; font-weight: 600; padding: 2px 9px;
  margin: 3px 3px 0 0; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--panel); color: var(--accent);
}
.judge-chip:hover { background: var(--accent-soft); }
.judges-panel {
  margin: 14px 0; padding: 12px; border: 1px solid var(--accent);
  border-radius: 12px; background: var(--accent-soft);
}
.judges-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.judges-head .muted { flex: 1; color: var(--muted); font-size: 12px; }
/* Stan ładowania liczby z SAOS + wyszarzony przycisk dociągania */
.saos-wait { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-style: italic; }
.mini-spin {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none;
  border: 2px solid var(--accent); border-top-color: transparent;
  animation: spin .7s linear infinite;
}
.action-btn:disabled { opacity: .5; cursor: progress; }
.action-btn:disabled:hover { color: var(--muted); border-color: var(--line); background: var(--bg); }
.judge-cases { display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow: auto; }
.judge-case {
  display: flex; justify-content: space-between; gap: 10px; text-align: left;
  padding: 8px 10px; border: 1px solid transparent; border-radius: 8px;
  background: var(--panel); cursor: pointer;
}
.judge-case:hover { border-color: var(--accent); }
.jc-sig { font-weight: 600; color: var(--accent); }
.jc-meta { color: var(--muted); font-size: 12px; }

/* Powiązane orzeczenia (graf cytowań SAOS) */
.related-panel {
  margin: 14px 0; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--bg);
}
.related-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
  font-weight: 600; color: var(--muted); font-size: 13px;
}
.related-web { margin-left: auto; font-weight: 400; font-size: 12px; }
.related-empty { color: var(--muted); font-size: 13px; margin: 4px 0; }
.related-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow: auto; }
.related-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: var(--panel); }
.related-sig { font-weight: 600; color: var(--accent); }
.related-open {
  font-size: 12px; padding: 2px 8px; border: 1px solid var(--line);
  border-radius: 7px; background: var(--bg); color: var(--ink); cursor: pointer;
  text-decoration: none;
}
.related-open:hover { border-color: var(--accent); }
.related-open.ext { color: var(--muted); }
.related-open.explore { color: var(--accent); font-weight: 600; }
.related-ext-pair { display: inline-flex; align-items: center; gap: 4px; }
.related-saos {
  font-size: 11px; color: var(--muted); text-decoration: none;
  padding: 2px 6px; border-radius: 6px;
}
.related-saos:hover { color: var(--accent); background: var(--accent-soft); }

/* Powołane przepisy (artykuły ustaw cytowane w orzeczeniu) */
/* „Powołane przepisy" — zwijane okienko (domyślnie zamknięte) */
.legal-details { margin: 14px 0; }
.legal-details > summary {
  cursor: pointer; font: 600 13px/1 Georgia, serif; color: var(--muted);
  padding: 8px 0; border-top: 1px solid var(--line); list-style-position: inside;
}
.legal-details > summary:hover { color: var(--accent); }
.legal-details[open] > summary { margin-bottom: 8px; }
.legal-panel {
  padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--bg);
}
.legal-head { font-weight: 600; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.legal-count { font-weight: 400; }
.legal-hint { font-weight: 400; font-size: 11px; color: var(--muted); }
.legal-empty { color: var(--muted); font-size: 13px; margin: 4px 0; }
.legal-groups { display: flex; flex-direction: column; gap: 12px; max-height: 360px; overflow: auto; }
.legal-act-name { font-weight: 600; color: var(--accent); font-size: 13px; margin-bottom: 5px; }
.legal-unknown { font-weight: 400; color: var(--muted); font-size: 11px; }
.legal-art-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.legal-art-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.legal-art {
  flex: none; font-size: 12px; font-weight: 600; padding: 2px 9px;
  border: 1px solid var(--accent); border-radius: 8px; background: var(--panel);
  color: var(--accent); text-decoration: none; white-space: nowrap;
}
.legal-art:hover { background: var(--accent-soft); }
.legal-app {
  flex: none; font-size: 12px; font-weight: 600; padding: 2px 9px; cursor: pointer;
  white-space: nowrap; border: 1px solid var(--accent); border-radius: 8px;
  background: var(--panel); color: var(--accent);
}
.legal-app:hover { background: var(--accent-soft); }
.legal-app:disabled { opacity: .5; cursor: progress; }
.legal-art-label { flex: none; font-size: 12px; font-weight: 600; color: var(--accent); white-space: nowrap; }
.legal-art-ext { flex: none; font-size: 11px; color: var(--muted); text-decoration: none; }
.legal-art-ext:hover { color: var(--accent); }
.legal-times { flex: none; font-size: 11px; color: var(--muted); }

/* Zakładka Przepisy — wyszukiwarka + lista + szczegół z treścią i czatem */
.prov-search { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 8px; }
.prov-search input {
  flex: 1 1 220px; min-width: 0; padding: 10px 14px; font-size: 14px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--panel); color: var(--ink);
}
.prov-search button { white-space: nowrap; flex: 0 0 auto; }
/* Wąski ekran: pole na całą szerokość, przyciski w jednym rzędzie pod spodem */
@media (max-width: 560px) {
  .prov-search input { flex-basis: 100%; }
  .prov-search button { flex: 1 1 0; }
}
.prov-search input:focus { outline: none; border-color: var(--accent); }
.prov-search button {
  padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--accent); border-radius: 10px; background: var(--accent); color: #fff;
}
.prov-search button:hover { filter: brightness(1.05); }
.prov-search button:disabled { opacity: .5; cursor: progress; }
.prov-search .prov-clear { background: var(--panel); color: var(--muted); border-color: var(--line); }
.prov-search .prov-clear:hover { color: var(--accent); border-color: var(--accent); filter: none; }
.prov-repealed {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0 18px;
  padding: 12px 16px; border-radius: 10px; background: #fdf3e7; border: 1px solid #e6c79a; color: #7a5b1e;
  font-size: 14px;
}
.prov-repealed a { color: var(--accent); font-weight: 600; }
.prov-layout { display: grid; grid-template-columns: 280px 1fr; gap: 18px; align-items: start; }
.prov-left { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.prov-list { display: flex; flex-direction: column; gap: 14px; max-height: 75vh; overflow: auto; }
/* „Ostatnio oglądane" — szybki powrót do 5 ostatnich przepisów */
.prov-recent { display: flex; flex-direction: column; gap: 5px;
  border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.prov-recent-name {
  font: 600 11px/1 Georgia, serif; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); margin-bottom: 4px;
}
.prov-recent .prov-item { background: #fff; }
.prov-group { display: flex; flex-direction: column; gap: 5px; }
.prov-group-name {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); padding: 0 2px 2px; border-bottom: 1px solid var(--line); margin-bottom: 2px;
}
.prov-item {
  display: flex; flex-direction: column; gap: 2px; text-align: left; cursor: pointer;
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
}
.prov-item:hover { border-color: var(--accent); }
.prov-item.active { border-color: var(--accent); background: var(--accent-soft); }
.prov-item-art { font-weight: 600; color: var(--accent); font-size: 13px; }
.prov-item-title { font-size: 11px; color: var(--muted); line-height: 1.3; }
.prov-detail {
  border: 1px solid var(--line); border-radius: 14px; background: var(--panel);
  padding: 20px 24px; min-height: 200px;
}
.prov-nav { display: flex; gap: 8px; margin-bottom: 8px; }
.prov-nav button {
  font-size: 12px; padding: 4px 10px; cursor: pointer; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
.prov-nav button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.prov-nav button:disabled { opacity: .4; cursor: default; }
.prov-detail-head h2 { font: 600 18px/1.3 Georgia, serif; margin: 0 0 4px; color: var(--accent); }
.prov-detail-meta { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.prov-del {
  margin-left: auto; font-size: 11px; color: var(--muted); cursor: pointer;
  border: 1px solid var(--line); border-radius: 7px; background: var(--bg); padding: 2px 8px;
}
.prov-del:hover { color: #b4453a; border-color: #b4453a; }
.prov-text {
  font: 15px/1.7 Georgia, "Times New Roman", serif; color: #20211f;
  white-space: pre-wrap; margin: 14px 0 18px; padding: 14px 16px;
  background: var(--bg); border-radius: 10px; border: 1px solid var(--line);
}
.prov-chat { margin-top: 6px; }
.qa-input-wrap { position: relative; flex: 1; display: flex; }
.qa-input-wrap input { flex: 1; }
.qa-suggest-spin { position: absolute; right: 10px; top: 50%; margin-top: -5px; }
@media (max-width: 760px) { .prov-layout { grid-template-columns: 1fr; } }
.legal-ctx {
  flex: 1; min-width: 200px; font-size: 11px; color: var(--muted); font-style: italic;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Nagłówek modala */
/* padding-right rezerwuje miejsce na absolutny przycisk × (top:14 right:16), żeby
   prawo-wyrównane akcje (np. „⤳ powiązane") się z nim nie nachodziły. */
.modal-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; padding-right: 52px; }
.modal-head-main { flex: 1; min-width: 0; }
.modal-head .card-btn { flex: none; }
.head-actions { display: flex; align-items: center; gap: 6px; flex: none; flex-wrap: wrap; justify-content: flex-end; }

/* Karta analizy */
.analysis-box {
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 16px;
}
.analysis-head {
  display: flex; align-items: center; gap: 8px;
  font: 600 11px/1 Georgia, serif; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); margin-bottom: 10px;
}
.analysis-head .refresh { margin-left: auto; }
.an-loading { color: var(--accent); font-size: 13px; }
.analysis { display: grid; gap: 8px; }
.an-row { display: grid; grid-template-columns: 130px 1fr; gap: 12px; font-size: 13.5px; }
.an-row .an-k { color: var(--muted); font-weight: 600; }
.an-row .an-v { color: #2c2822; }
/* Wyróżnij najważniejsze pola */
.an-row.rozstrzygniecie .an-v { font-weight: 600; color: var(--accent); }
.an-row.kwoty .an-v { font-weight: 600; }
@media (max-width: 560px) { .an-row { grid-template-columns: 1fr; gap: 2px; } }

/* Q&A nad orzeczeniem */
.qa-box {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  margin-bottom: 16px; background: var(--panel);
}
.qa-head {
  font: 600 11px/1 Georgia, serif; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); margin-bottom: 10px;
}
.qa-log {
  display: flex; flex-direction: column; gap: 8px; max-height: 70vh; overflow-y: auto;
  margin-bottom: 10px; resize: vertical;   /* użytkownik może rozciągnąć czat w pionie */
}
.qa-log:empty { display: none; }
/* Duży ekran — czat domyślnie wyższy (mniej scrollowania) */
@media (min-width: 1200px) { .qa-log:not(:empty) { min-height: 360px; } }
.qa-q {
  align-self: flex-end; max-width: 85%; background: var(--accent); color: #fff;
  padding: 7px 12px; border-radius: 12px 12px 2px 12px; font-size: 13.5px;
}
.qa-a {
  align-self: flex-start; max-width: 90%; background: var(--bg); color: #2c2822;
  padding: 7px 12px; border-radius: 12px 12px 12px 2px; font-size: 13.5px;
  white-space: pre-wrap; line-height: 1.5; border: 1px solid var(--line);
}
/* Odpowiedź po wyrenderowaniu markdown — bloki zamiast pre-wrap */
.qa-a.md { white-space: normal; }
.qa-a.md > div { margin: 0 0 6px; }
.qa-a.md > div:last-child { margin-bottom: 0; }
.qa-a.md .md-h { font: 600 13.5px/1.4 Georgia, serif; margin: 8px 0 4px; color: var(--accent); }
.qa-a.md ul, .qa-a.md ol { margin: 4px 0 8px; padding-left: 22px; }
.qa-a.md li { margin: 2px 0; }
.qa-a.md strong { font-weight: 700; }
.qa-a.md code { background: rgba(0,0,0,.06); padding: 0 4px; border-radius: 4px; font-size: 12.5px; }
.qa-form { display: flex; gap: 8px; }
.qa-form input {
  flex: 1; min-width: 0; padding: 9px 12px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 9px; background: #fff;
}
.qa-form input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.qa-form button {
  padding: 0 16px; font-size: 14px; font-weight: 600; color: #fff;
  background: var(--accent); border: 0; border-radius: 9px; cursor: pointer;
}
.qa-form button:hover { background: #631824; }
/* 🎲 „kolejne pytanie" — neutralny, obok pola (nie akcent jak „Wyślij") */
.qa-reroll {
  padding: 0 12px !important; background: var(--bg) !important; color: inherit !important;
  border: 1px solid var(--line) !important; font-size: 16px !important;
}
.qa-reroll:hover { background: var(--accent-soft) !important; }
.qa-reroll:disabled { opacity: .5; cursor: default; }
/* „wyczyść" w nagłówku czatu — dyskretny link, widoczny gdy jest rozmowa */
.qa-clear, .qa-regen {
  float: right; border: 0; background: none; cursor: pointer; padding: 0 0 0 12px;
  font: inherit; color: var(--muted); text-decoration: underline; letter-spacing: 0;
}
.qa-clear:hover, .qa-regen:hover { color: var(--accent); }
/* Klikalne powołanie „art. X k.c." — w odpowiedzi czatu i wplecione w treść orzeczenia */
.legal-ref {
  border: 0; background: var(--accent-soft); color: var(--accent); cursor: pointer;
  padding: 0 4px; border-radius: 4px; font: inherit; font-weight: 600;
}
.legal-ref:hover { background: var(--accent); color: #fff; }

/* Słowa kluczowe jako chipy */
.kw-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.kw-chip {
  font-size: 11.5px; padding: 3px 10px; border-radius: 20px;
  background: var(--accent-soft); color: var(--accent);
}

/* Rozwijany pełny tekst */
.fav-details > summary {
  cursor: pointer; font: 600 14px/1 Georgia, serif; color: var(--accent);
  padding: 8px 0 12px; list-style-position: inside; user-select: none;
}
.fav-details > summary:hover { opacity: .8; }
.doc-details > summary {
  cursor: pointer; font: 600 13px/1 Georgia, serif; color: var(--muted);
  padding: 8px 0; border-top: 1px solid var(--line); list-style-position: inside;
}
.doc-details > summary:hover { color: var(--accent); }
.doc-details[open] > summary { margin-bottom: 12px; }
.modal pre {
  white-space: pre-wrap; font: 14px/1.6 -apple-system, "Segoe UI", sans-serif;
  color: #2c2822; margin: 0;
}
.modal a { color: var(--accent); }
.spinner { text-align: center; color: var(--muted); padding: 30px; }

/* Render orzeczenia jako dokument */
.document {
  font: 15px/1.7 Georgia, "Times New Roman", serif; color: #20211f;
  max-width: none;            /* pełna szerokość rodzica (modala) — bez ucięcia z prawej */
}
.document h1, .document h2, .document h3, .document h4 {
  font-weight: 600; color: var(--accent); margin: 1.4em 0 .5em;
  line-height: 1.3;
}
.document h1 { font-size: 1.3em; text-align: center; }
.document h2 { font-size: 1.15em; }
.document h3, .document h4 { font-size: 1.02em; }
.document p { margin: 0 0 .85em; text-align: justify; }
.document ul, .document ol { margin: 0 0 .85em 1.4em; }
.document blockquote {
  margin: 0 0 .85em; padding-left: 14px; border-left: 3px solid var(--line);
  color: #45433d;
}
.document table { border-collapse: collapse; margin: 0 0 1em; font-size: .92em; }
.document td, .document th { border: 1px solid var(--line); padding: 5px 9px; }

/* Panel admina */
.admin-stats { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.embed-fix:not(:empty) { display: flex; align-items: center; gap: 12px; margin: -8px 0 20px; padding: 10px 14px; border: 1px solid #e6c79a; background: #fdf3e7; border-radius: 10px; }
.embed-fix-msg { color: #7a5b1e; font-size: 13px; font-weight: 600; }
.stat-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 18px; box-shadow: var(--shadow); min-width: 130px;
}
.stat-card .num { font: 600 24px/1 Georgia, serif; color: var(--accent); }
.stat-card .lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }
.admin-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.admin-bar input, .admin-bar select {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; background: var(--panel);
}
.admin-bar button {
  padding: 9px 16px; font-size: 14px; font-weight: 600; color: #fff;
  background: var(--accent); border: 0; border-radius: 8px; cursor: pointer;
}
.admin-bar button:hover { background: #631824; }
table.grid { width: 100%; border-collapse: collapse; background: var(--panel); }
table.grid th, table.grid td {
  text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
table.grid th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
table.grid tr.row { cursor: pointer; }
table.grid tr.row:hover { background: var(--accent-soft); }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.pill.warn { background: #fff3da; color: #8a6d1f; border-color: transparent; }
.job-status {
  margin-left: auto; font-size: 13px; color: var(--accent);
  background: var(--accent-soft); padding: 7px 14px; border-radius: 20px;
}

/* Podgląd SAOS przed ingestem (smart) */
.preview-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 18px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.preview-head { font-size: 15px; margin-bottom: 12px; }
.preview-head strong { color: var(--accent); font: 600 18px/1 Georgia, serif; }
.pv-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.pv-label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.pv-chip {
  font-size: 12.5px; padding: 4px 10px; border-radius: 20px;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
}
.pv-chip b { color: var(--accent); font-variant-numeric: tabular-nums; }
.kw-suggest {
  font-size: 12.5px; padding: 4px 10px; border-radius: 20px; cursor: pointer;
  background: var(--accent-soft); border: 1px solid transparent; color: var(--accent); font-weight: 600;
}
.kw-suggest:hover { border-color: var(--accent); }
.kw-suggest .cnt { opacity: .6; font-variant-numeric: tabular-nums; }
.pv-sample {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line);
}
.pv-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink); }
.pv-num { width: 64px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.pv-est { font-size: 13px; color: var(--accent); font-weight: 600; margin-left: auto; }
.pv-sample #ingestBtn {
  padding: 9px 18px; font-size: 14px; font-weight: 600; color: #fff;
  background: var(--accent); border: 0; border-radius: 8px; cursor: pointer;
}
.pv-sample #ingestBtn:hover { background: #631824; }

.grid th.sortable { cursor: pointer; user-select: none; }
.grid th.sortable:hover { color: var(--accent); }
.sort-ind { font-size: 10px; }

/* Ban / czarna lista w adminie */
table.grid td.cell-ban { width: 1%; white-space: nowrap; text-align: right; }
table.grid td.cell-date { white-space: nowrap; }
.ban-btn {
  font-size: 11.5px; font-weight: 600; color: var(--muted); background: none;
  border: 1px solid var(--line); border-radius: 8px; padding: 3px 9px; cursor: pointer;
  opacity: .65; transition: opacity .12s, color .12s, border-color .12s, background .12s;
}
table.grid tr.row:hover .ban-btn { opacity: 1; }
.ban-btn:hover { color: var(--contra); border-color: var(--contra); background: var(--accent-soft); }
.ban-panel { margin-top: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); padding: 6px 14px; }
.ban-panel > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); padding: 6px 0; }
.ban-panel > summary:hover { color: var(--accent); }
.ban-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 4px; border-bottom: 1px solid var(--line);
}
.ban-row:last-child { border-bottom: 0; }
.ban-row-label {
  font-size: 13.5px; color: var(--ink); background: none; border: 0; padding: 0;
  text-align: left; cursor: pointer; font-family: inherit;
}
.ban-row-label:hover { color: var(--accent); text-decoration: underline; }
.ban-undo { flex: none; }

/* --- Szukaj v2 composer (all layout rules scoped to .v2 — v1 pages untouched) --- */

/* Centered single-column layout: composer panel on top, results below */
.v2 main { max-width: 960px; margin: 0 auto; }
.v2 .layout { display: block; }
.v2 #composerPanel.filters {
  width: auto; max-width: none; margin: 0 0 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 20px; box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
}
.v2 .panel-section { margin-bottom: 18px; }
.v2 .panel-section:last-child { margin-bottom: 0; }
.v2 #composerPanel h2 { margin: 0 0 8px; }
.v2 .panel-help { margin: 0 0 12px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }

/* Rule cards — vertical; OR-alternatives STACK so nothing overflows right */
.v2 .term-row {
  display: block; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 10px;
}
.v2 .term-head { display: flex; gap: 8px; align-items: center; }
.v2 .term-row input[type=text] {
  flex: 1; min-width: 0; padding: 9px 11px; font-size: 14.5px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
.v2 .term-alts { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.v2 .alt-line { display: flex; gap: 8px; align-items: center; padding-left: 14px; }
.v2 .alt-or {
  flex: 0 0 auto; min-width: 24px; font-size: 11px; font-weight: 600;
  color: var(--accent); text-transform: uppercase; letter-spacing: .04em;
}
.v2 .term-remove, .v2 .alt-remove {
  flex: 0 0 auto; width: 26px; height: 26px; padding: 0; line-height: 1;
  border: 1px solid var(--line); border-radius: 7px; background: #fff;
  color: var(--muted); cursor: pointer; font-size: 15px;
}
.v2 .term-remove:hover, .v2 .alt-remove:hover { color: var(--contra); border-color: var(--contra); }
.v2 .add-or { margin-top: 8px; font-size: 11.5px; padding: 4px 10px; }
.v2 .add-rule { margin-top: 2px; }
.v2 .composer-actions { display: flex; gap: 8px; align-items: center; margin-top: 2px; }

/* Synonimy reguły (LLM) — ✨ w nagłówku reguły. Spoczynkowo dyskretny; gdy kursor
   najedzie na regułę, przycisk „zadrży", by zdradzić, że można go kliknąć. */
.v2 .syn-btn {
  flex: 0 0 auto; width: 26px; height: 26px; padding: 0; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 7px; background: #fff;
  color: var(--muted); cursor: pointer; font-size: 14px; opacity: .55;
  transition: opacity .15s, color .15s, border-color .15s;
}
.v2 .syn-btn:hover { opacity: 1; color: var(--accent); border-color: var(--accent); }
.v2 .syn-btn:disabled { cursor: progress; opacity: .5; }
.v2 .syn-btn.flash { color: var(--contra); border-color: var(--contra); opacity: 1; }
/* Animujemy TYLKO glif (.syn-ico), nie cały kwadratowy przycisk — inaczej rogi
   wychodzą poza obrys („odstaje poza button"). Glif kręci się W MIEJSCU. */
.v2 .syn-ico {
  display: flex; align-items: center; justify-content: center;
  width: 1em; height: 1em; line-height: 1; transform-origin: 50% 50%;
}
.v2 .syn-btn.loading .syn-ico { animation: synSpin .8s linear infinite; }
.v2 .term-row:hover .syn-btn:not(:disabled) .syn-ico { animation: synWiggle .5s ease-in-out; }
.v2 .term-row:hover .syn-btn:not(:disabled) { opacity: 1; }
@keyframes synWiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-16deg); }
  50% { transform: rotate(12deg); }
  75% { transform: rotate(-6deg); }
}
@keyframes synSpin { to { transform: rotate(360deg); } }

/* Filters — readable responsive grid instead of a cramped vertical stack */
.v2 .filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 16px; }
.v2 .filter-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.v2 .filter-grid select, .v2 .filter-grid input {
  padding: 8px 10px; font-size: 14px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink);
}

.v2 .results-pane { max-width: none; }

@media (max-width: 720px) {
  .v2 .filter-grid { grid-template-columns: 1fr; }
}

.v2 .panel-actions { margin-top: 4px; display: flex; flex-direction: column; gap: 14px; }
.topup-anchor-label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--muted);
}
.topup-anchor-label input[type="date"] {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; color: var(--ink); background: var(--bg);
}
.topup-presets { display: flex; flex-direction: column; gap: 6px; }
.topup-presets-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.topup-preset-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.topup-preset { padding: 7px 12px; font-size: 13px; }
.topup-preset:disabled { opacity: .5; cursor: not-allowed; }
.topup-preset.active { background: var(--accent); color: #fff; border-color: var(--accent); }
#searchV2Btn {
  width: 100%; padding: 13px 26px; font-size: 15px; font-weight: 600; color: #fff;
  background: var(--accent); border: 0; border-radius: 12px; cursor: pointer;
}
#searchV2Btn:hover { background: #631824; }
#searchV2Btn:disabled { opacity: .6; cursor: progress; }
#composition { margin-bottom: 10px; font-size: 13px; color: var(--muted); line-height: 1.9; }
#composition .badge { margin: 0 2px; }
#composition .conn { color: var(--muted); }
#composition .comp-label { font-weight: 600; color: var(--ink); margin-right: 4px; }
#composition .op { color: var(--accent); font-weight: 800; margin: 0 5px; font-family: ui-monospace, monospace; }
#composition .paren { color: var(--muted); font-weight: 700; }
.checkbox input:disabled ~ *, .checkbox:has(input:disabled) label { opacity: .5; }
.checkbox input:disabled + span { opacity: .5; }

/* Verdict badges — LLM relevance verification (.v2-scoped only, no global leak) */
.v2 .verdict { font-weight: 600; border: 0; border-radius: 8px; padding: 2px 8px; font-size: 13px; }
.v2 .verdict.ok      { background: #e1efe9; color: var(--support); }
.v2 .verdict.bad     { background: #f5e0e0; color: var(--contra); }
.v2 .verdict.partial { background: #f6ecd8; color: #8a5a1a; }    /* amber — no global token */
.v2 .verdict-reason  { font-size: 12px; color: var(--muted); font-style: italic; }
.v2 .modal-verdict   { margin: 10px 0; padding: 10px 12px; background: var(--surface, #faf8f4); border: 1px solid var(--border, #e5e0d8); border-radius: 10px; }
.v2 .modal-verdict-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.v2 .modal-verdict-q { font-size: 12px; color: var(--muted); }
.v2 .modal-verdict .verdict-reason { display: block; margin-top: 6px; font-size: 13px; }
.v2 .verify-toolbar  { display: flex; gap: 10px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.v2 .verify-spin     { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-size: 12px; font-weight: 600; }
.v2 .verify-spin::before {
  content: ""; width: 12px; height: 12px; flex: none; border-radius: 50%;
  border: 2px solid var(--accent); border-top-color: transparent; animation: spin .7s linear infinite;
}
.v2 .verify-note     { color: var(--muted); font-size: 12px; }
.v2 .verify-progress { color: var(--accent); font-size: 12.5px; font-weight: 600; }
.v2 .results.hide-bad .result[data-verdict="nietrafny"] { display: none; }

/* Cold-start LLM (alfa) — uczciwy spinner, gdy serverless-GPU dopiero się rozgrzewa.
   Kopia DOSŁOWNA (Plan 7). „Analizuję…” = faza generowania po rozgrzaniu. */
.llm-coldstart  { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.llm-generating { color: var(--accent); font-size: 12.5px; font-weight: 600; }
.llm-generating::after {
  content: ""; display: inline-block; width: 10px; height: 10px; margin-left: 6px;
  vertical-align: -1px; border-radius: 50%;
  border: 2px solid var(--accent); border-top-color: transparent; animation: spin .7s linear infinite;
}
/* „alfa" badge przy funkcjach LLM — mała pigułka, spójna z .mode-badge. */
.alpha-badge {
  display: inline-block; margin-left: 6px; font-weight: 700; font-size: 10.5px;
  letter-spacing: .04em; text-transform: lowercase; color: #8a5a1a;
  background: #f6ecd8; padding: 1px 7px; border-radius: 20px; vertical-align: 1px;
  cursor: help;
}

/* Weryfikacja jako osobny krok przy wynikach: toggle + pytanie + akcje.
   Per-wynik „Zweryfikuj" widoczne dopiero, gdy weryfikacja włączona (.verify-on). */
.v2 .verify-enable { font-weight: 600; }
.v2 .verify-toolbar-body { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; flex: 1 1 100%; }
.v2 .verify-toolbar-body[hidden] { display: none; }
.v2 .verify-toolbar .verify-question { width: auto; flex: 1 1 280px; min-width: 220px; }
.v2 #results .verify-btn { display: none; }
.v2 #results.verify-on .verify-btn { display: inline-flex; }

/* --- Top-up z SAOS (.v2-scoped) --- */
.topup-status {
  margin-top: 8px; font-size: 13px; line-height: 1.5;
}
.topup-confirm {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px; background: var(--accent-soft);
  border-radius: 8px; border: 1px solid var(--line); font-size: 13px;
}
.topup-info { line-height: 1.5; }
.topup-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.topup-span-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.topup-advanced { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.topup-advanced[hidden] { display: none; }
.topup-span {
  width: 64px; padding: 5px 8px; font-size: 13px; text-align: right;
  border: 1px solid var(--line); border-radius: 7px; background: var(--bg); color: var(--ink);
}
.topup-span:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.span-steps { display: inline-flex; gap: 3px; }
.span-step {
  padding: 3px 7px; font-size: 11.5px; font-weight: 600; line-height: 1.4;
  color: var(--accent); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
}
.span-step:hover { background: var(--accent-soft); border-color: var(--accent); }
.span-human { font-style: italic; }
.topup-progress { color: var(--accent); font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; }
.topup-progress::before {
  content: ""; flex: none; width: 13px; height: 13px;
  border: 2px solid var(--accent-soft); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
.topup-done { color: var(--support); font-size: 12.5px; font-weight: 600; }
.topup-error { color: var(--contra); font-size: 12.5px; }
.topup-hint { color: var(--muted); font-size: 12px; }
.v2 #topupBtn { margin-left: 0; width: 100%; padding: 11px 18px; }
@media (max-width: 540px) {
  .topup-confirm { flex-direction: column; align-items: flex-start; }
}

/* Pytanie weryfikacyjne LLM (.v2-scoped) */
.v2 .verify-question-wrap { margin-top: 10px; }
.v2 .verify-question {
  width: 100%; box-sizing: border-box;
  padding: 9px 12px; font-size: 13px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
.v2 .verify-question::placeholder { color: var(--muted); }
.v2 .verify-question:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.v2 .verify-question.input-error {
  border-color: var(--contra);
  box-shadow: 0 0 0 3px #f5e0e0;
}

/* --- Presety wyszukiwań (systemowe + własne) --- */
#presetsSection .presets-group { margin-bottom: 12px; }
.presets-group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); font-weight: 600; margin-bottom: 6px;
}
.preset-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.preset-chip {
  display: inline-flex; align-items: stretch;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); overflow: hidden; max-width: 100%;
}
.preset-chip:hover { border-color: var(--accent); }
.preset-chip-go {
  border: 0; background: none; cursor: pointer;
  font-size: 12px; color: var(--accent); font-weight: 600;
  padding: 4px 10px; max-width: 220px; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.preset-chip-go:hover { background: var(--accent-soft); }
.preset-chip-del {
  border: 0; border-left: 1px solid var(--line); background: none;
  cursor: pointer; color: var(--muted); font-size: 14px; line-height: 1;
  padding: 0 8px;
}
.preset-chip-del:hover { color: var(--contra); background: #f5e0e0; }
#savePresetBtn { margin-top: 2px; }

/* --- Pasek narzędzi wyników: sort + facet (instancja) + CSV + legenda (.v2-scoped) --- */
.v2 .results-toolbar {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  margin: 4px 0 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line);
}
.v2 .sort-control { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.v2 .sort-select {
  padding: 5px 8px; font-size: 13px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer;
}
.v2 .facet-chips { display: inline-flex; flex-wrap: wrap; gap: 5px; }
.v2 .facet-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; font-size: 12px; color: var(--accent); font-weight: 600;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg); cursor: pointer;
}
.v2 .facet-chip:hover { border-color: var(--accent); }
.v2 .facet-chip .cnt { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); }
.v2 .facet-chip.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.v2 .facet-chip.active .cnt { color: rgba(255,255,255,.85); }
.v2 #csvBtn { font-size: 12.5px; padding: 5px 11px; }
.v2 .hl-legend { display: inline-flex; gap: 10px; align-items: center; margin-left: auto; }
.v2 .hl-key { font-size: 11.5px; color: var(--ink); padding: 1px 7px; border-radius: 3px; }
.v2 .hl-key.hl-exact { background: #bfe6c9; color: #1f5c4a; }   /* zgodne z mark.exact */
.v2 .hl-key.hl-fam   { background: #fbe7a2; color: #5c4a1f; }   /* zgodne z mark.fam */
.v2 .link-btn {
  border: 0; background: none; color: var(--accent); cursor: pointer;
  font: inherit; text-decoration: underline; padding: 0;
}

/* Podpowiedź, dlaczego przyciski top-up są nieaktywne (.v2-scoped) */
.topup-disabled-hint { margin: 2px 0 0; font-size: 12px; color: var(--muted); font-style: italic; }

/* Szerszy modal na desktopie — długie orzeczenia czytelniejsze (.v2-scoped) */
@media (min-width: 1000px) { body.v2 .modal { max-width: 980px; } }

/* --- Eksploruj: pusty stan z przykładowymi sygnaturami --- */
.explore-empty { text-align: center; padding: 24px 10px; }
.example-sigs { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.example-sig {
  padding: 7px 14px; font-size: 13px; font-weight: 600; color: var(--accent);
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg); cursor: pointer;
}
.example-sig:hover { border-color: var(--accent); background: var(--accent-soft); }

/* --- Strona Info (dokumentacja + FAQ) --- */
/* --- Landing („/") --- */
.landing { max-width: 920px; margin: 0 auto; padding: 8px 4px 40px; }
.hero { text-align: center; padding: 32px 0 24px; }
.hero-badge {
  display: inline-block; margin: 0 0 14px; padding: 4px 12px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 20px; font-size: 12px; font-weight: 600; letter-spacing: .3px;
}
.hero-title { margin: 0; font: 700 48px/1 Georgia, serif; color: var(--accent); letter-spacing: .5px; }
.hero-tagline { margin: 12px 0 0; font: 600 19px/1.4 Georgia, serif; color: var(--ink); }
.hero-lead { max-width: 680px; margin: 16px auto 0; line-height: 1.65; color: #2c2822; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 26px 0 0; }
.btn-primary {
  display: inline-block; text-decoration: none;
  background: var(--accent); color: var(--panel);
  padding: 11px 22px; border-radius: 10px; font-weight: 600; font-size: 15px;
  box-shadow: var(--shadow);
}
.btn-primary:hover { background: #651a24; }
.btn-secondary {
  display: inline-block; text-decoration: none;
  background: var(--panel); color: var(--accent);
  padding: 11px 18px; border-radius: 10px; font-weight: 600; font-size: 15px;
  border: 1px solid var(--line);
}
.btn-secondary:hover { background: var(--accent-soft); }
.features { margin: 40px 0 0; }
.features-head { font: 600 22px/1.3 Georgia, serif; color: var(--accent); margin: 0 0 14px; }
.feature-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.feature-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 18px; box-shadow: var(--shadow);
}
.feature-card h4 { margin: 0 0 8px; font: 600 17px/1.3 Georgia, serif; color: var(--ink); }
.feature-card p { margin: 0 0 8px; line-height: 1.55; font-size: 14px; color: #2c2822; }
.feature-card ul { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.55; color: var(--muted); }
.feature-card li { margin: 3px 0; }
.landing-faq { margin: 40px 0 0; max-width: 760px; }
.hero-cta-foot { margin-top: 22px; color: var(--muted); font-size: 14px; }

.info-page { max-width: 760px; margin: 0 auto; }
.info-page h2 { font: 600 22px/1.3 Georgia, serif; color: var(--accent); margin: 28px 0 10px; }
.info-page h3 { font: 600 16px/1.3 Georgia, serif; color: var(--ink); margin: 18px 0 6px; }
.info-page p { line-height: 1.65; margin: 8px 0; }
.info-page ul { line-height: 1.6; padding-left: 22px; margin: 8px 0; }
.info-page li { margin: 4px 0; }
.info-updated { font-size: 13px; color: var(--muted); }
.info-callout {
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: 8px; font-size: 14px;
}
.info-faq {
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
  padding: 4px 14px; margin: 8px 0;
}
.info-faq > summary {
  cursor: pointer; font-weight: 600; padding: 8px 0; color: var(--ink);
  list-style-position: inside;
}
.info-faq > summary:hover { color: var(--accent); }
.info-faq[open] > summary { color: var(--accent); }
.info-faq p { margin: 4px 0 10px; color: #2c2822; }
.info-foot { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }

/* --- Profil (ikonka w prawym górnym rogu, zamiast licznika korpusu) --- */
.status.profile { display: flex; align-items: center; }
.profile-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; text-decoration: none;
  color: var(--accent); background: var(--accent-soft);
  border: 1px solid var(--line); font: 600 13px/1 inherit; cursor: pointer;
  max-width: 220px;
}
.profile-btn:hover { border-color: var(--accent); }
.profile-btn svg { flex: none; }
.profile-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Kropka stanu silnika AI (GPU) — siedzi po lewej od ikonki profilu w prawym górnym
   rogu. Kolor wnioskowany z wieku ostatniego wywołania LLM (NIE pukamy do GPU). */
.gpu-dot {
  display: inline-block; width: 10px; height: 10px; margin-right: 8px;
  border-radius: 50%; vertical-align: middle; flex: none;
  border: 1px solid rgba(0, 0, 0, 0.15);
}
.gpu-ready { background: #2e9e44; }
.gpu-expiring { background: #1e74d8; }
.gpu-cold { background: #c2384a; }
.gpu-starting { background: #e8a91e; animation: gpu-pulse 1s ease-in-out infinite; }
@keyframes gpu-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* --- Strony konta (login / account) --- */
.auth-wrap { max-width: 460px; margin: 40px auto; padding: 0 16px; }
.auth-card {
  background: var(--card, #fff); border: 1px solid var(--line); border-radius: 12px;
  padding: 26px 28px; box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.auth-card h2 { font: 600 22px/1.2 Georgia, serif; color: var(--accent); margin: 0 0 6px; }
.auth-card h3 { font: 600 15px/1.3 inherit; margin: 22px 0 10px; color: var(--ink); }
.auth-help { color: var(--muted); font-size: 13.5px; margin: 0 0 18px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.auth-form input[type=email], .auth-form input[type=password], .auth-form input[type=text] {
  padding: 9px 11px; font-size: 14px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--bg); color: var(--ink);
}
.auth-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.auth-form button[type=submit] {
  margin-top: 4px; padding: 10px 16px; font-size: 14px; font-weight: 600;
  color: #fff; background: var(--accent); border: none; border-radius: 8px; cursor: pointer;
}
.auth-form button[type=submit]:hover { filter: brightness(1.05); }
.auth-form button[disabled] { opacity: .6; cursor: default; }
.auth-form-row { flex-flow: row wrap; align-items: end; }
.auth-form-row label { flex: 1 1 180px; }
.checkbox-label { flex-direction: row; align-items: center; gap: 6px; }
.auth-msg { margin: 14px 0 0; font-size: 13px; }
.auth-msg.err { color: var(--contra); }
.auth-msg.ok { color: var(--support); }
.account-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.role-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; vertical-align: middle; }
.invite-result { margin-top: 14px; padding: 12px; background: var(--accent-soft); border-radius: 8px; font-size: 13px; }
.invite-link-row { display: flex; gap: 6px; margin-top: 8px; }
.invite-link-row input { flex: 1; padding: 7px 9px; font-size: 12.5px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); color: var(--ink); }
.account-soon { margin-top: 26px; padding-top: 16px; border-top: 1px dashed var(--line); opacity: .7; }
