/* Scriptura — wspólne tokeny, nawigacja i podstrony.
   Workbench dokłada układ czatu; ten arkusz nie ustawia obszarów jego siatki. */

:root {
  color-scheme: light;
  --bg: #f5f0e6;
  --bg-subtle: #ede5d5;
  --panel: #fcfaf5;
  --panel-accent: #f4ecdf;
  --text: #231815;
  --muted: #6e5e4f;
  --line: #dfd3c3;
  --line-strong: #c2b19b;
  --accent: #871c2b;
  --accent-soft: #f5e8ea;
  --gold: #b3822a;
  --gold-soft: #fbf5e7;
  --ok: #235c3b;
  --ok-soft: #eaf3ec;
  --warn: #924516;
  --warn-soft: #faeee4;
  --user: #ece3d2;
  --hl: #faeaaf;
  --control-line: #9c8b78;
  --on-accent: #ffffff;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Times New Roman", serif;
  --shadow: 0 4px 18px rgba(35, 24, 21, 0.06), 0 1px 4px rgba(35, 24, 21, 0.04);
  --shadow-lg: 0 12px 36px rgba(35, 24, 21, 0.1), 0 2px 8px rgba(35, 24, 21, 0.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #14110e;
    --bg-subtle: #1c1713;
    --panel: #1e1914;
    --panel-accent: #26201a;
    --text: #e9dfcc;
    --muted: #a79782;
    --line: #3d3226;
    --line-strong: #5c4b39;
    --accent: #e58593;
    --accent-soft: #381e23;
    --gold: #d6a44d;
    --gold-soft: #352b1b;
    --ok: #8fd5ad;
    --ok-soft: #193325;
    --warn: #f2b88b;
    --warn-soft: #3c2a1e;
    --user: #272019;
    --hl: #4c3f21;
    --control-line: #7c6d5b;
    --on-accent: #14110e;
    --shadow: 0 4px 18px rgba(0, 0, 0, 0.45), 0 1px 4px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-block: 20px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 var(--sans); }
a { color: var(--accent); text-underline-offset: .2em; text-decoration-thickness: 1px; }
button, input, select, textarea { font: inherit; }
button, input, select, textarea, summary { accent-color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
::selection { background: var(--gold-soft); color: var(--text); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: fixed; z-index: 100; inset: 12px auto auto 12px; max-width: calc(100% - 24px); padding: 12px 18px; border: 1px solid var(--accent); border-radius: 8px; background: var(--panel); color: var(--accent); box-shadow: var(--shadow-lg); font-weight: 650; transform: translateY(calc(-100% - 24px)); }
.skip-link:focus { transform: none; }

/* ---------- pasek górny (wspólny dla czatu i podstron) ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px 20px;
  flex-wrap: wrap;
  min-width: 0;
  padding: 12px clamp(16px, 2.5vw, 32px);
  border-bottom: 2px solid var(--line);
  background: var(--panel);
  box-shadow: 0 2px 10px rgba(35, 24, 21, 0.04);
  position: relative;
}
.topbar::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--gold) 20%, var(--gold) 80%, transparent 100%);
  opacity: 0.4;
}
.brand { display: inline-flex; align-items: center; flex-shrink: 0; text-decoration: none; border-radius: 8px; }
.brand-logo { display: block; width: 76px; height: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: 0 2px 5px rgba(35, 24, 21, 0.05); }
.mainnav {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: nowrap;
  min-width: 0;
  max-width: 100%;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-accent);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scroll-padding-inline: 6px;
}
.mainnav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  flex-shrink: 0;
  color: var(--text);
  font: 500 16px/1.4 var(--sans);
  text-decoration: none;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  white-space: nowrap;
  letter-spacing: .01em;
  transition: background-color .15s, color .15s, border-color .15s, box-shadow .15s;
}
.mainnav a.on {
  color: var(--accent);
  background: var(--panel);
  border-color: var(--line-strong);
  box-shadow: 0 2px 6px rgba(35, 24, 21, 0.07);
  font-weight: 700;
}
.mainnav a:focus-visible { outline-offset: -3px; }
.topbar .right { min-width: 0; margin-left: auto; display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.topbar .right > a, .topbar .right > details > summary, .topbar button.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  color: var(--text);
  font: 550 14px/1.4 var(--sans);
  text-decoration: none;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  transition: all .15s ease;
}
.topbar button.ghost {
  border-color: var(--line-strong);
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-accent) 100%);
}
.topbar .right > .who { display: block; max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-color: transparent; }
.topbar form.inline { display: inline; margin: 0; padding: 0; background: transparent; grid-area: auto; }
.topbar .right > a[href^='/login/'] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.topbar .access .menu { border-color: var(--line-strong); box-shadow: var(--shadow-lg); background: var(--panel); border-radius: 10px; }
.topbar .access .menu a { min-height: 44px; overflow-wrap: anywhere; }
@media (hover: hover) {
  .mainnav a:hover, .topbar .right > a:hover, .topbar .right > details > summary:hover, .topbar button.ghost:hover {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
  }
}
@media (max-width: 1360px) {
  .mainnav { order: 3; flex-basis: 100%; width: 100%; }
  .topbar .right { flex: 1; }
}
@media (max-width: 720px) {
  .topbar { position: relative; gap: 10px 12px; padding: 10px 12px; }
  .brand-logo { width: 64px; }
  .mainnav { border-radius: 10px; }
  .mainnav a { font-size: 15px; padding-inline: 11px; }
  .topbar .right > a, .topbar .right > details > summary, .topbar button.ghost { font-size: 14px; padding-inline: 10px; }
  .topbar .right > .who { max-width: 13ch; }
  .topbar .access { position: static; }
  .topbar .access .menu, .topbar .access > label { top: calc(100% + 8px); left: 12px; right: 12px; width: auto; max-height: 65dvh; overflow-y: auto; z-index: 10; }
}

/* ---------- podstrony (site.html) ---------- */
.site { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.page { flex: 1; min-width: 0; width: 100%; max-width: 900px; margin: 0 auto; padding: 52px clamp(16px, 4vw, 44px) 80px; overflow-wrap: anywhere; }
.page.wide { max-width: 1200px; }
.page h1 { font: 700 clamp(32px, 4vw, 46px)/1.15 var(--serif); letter-spacing: -.02em; margin: 0 0 20px; text-wrap: balance; color: var(--text); }
.page h1 span { color: var(--accent); font-style: italic; }
.page h2 { font: 700 clamp(23px, 2.5vw, 29px)/1.25 var(--serif); letter-spacing: -.015em; margin: 52px 0 18px; text-wrap: balance; color: var(--text); border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.page h3 { font: 700 19px/1.35 var(--serif); margin: 30px 0 10px; color: var(--text); }
.page .lead { font: 400 19px/1.7 var(--serif); color: var(--muted); margin: 0 0 36px; max-width: 720px; }
.page p, .page li { line-height: 1.75; }
.page p { margin: 0 0 18px; }
.page ul, .page ol { padding-left: 24px; margin: 0 0 18px; }
.page li { margin-bottom: 8px; }
.page code { font: .875em/1.5 var(--mono); background: var(--panel-accent); border: 1px solid var(--line); padding: 2px 6px; border-radius: 4px; }
.page pre { max-width: 100%; overflow-x: auto; white-space: pre-wrap; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-accent); font: 14px/1.6 var(--mono); }
.page kbd { font: 13px var(--mono); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 2px 6px; background: var(--panel); }
.page blockquote { margin: 24px 0; padding: 20px 24px; border: 1px solid var(--line); border-left: 4px solid var(--accent); background: var(--panel); border-radius: 0 8px 8px 0; color: var(--text); font-family: var(--serif); font-style: italic; font-size: 17px; line-height: 1.7; }
.eyebrow { display: flex; align-items: center; gap: 8px; font: 700 12px/1.5 var(--serif); font-variant-caps: all-small-caps; letter-spacing: .16em; color: var(--accent); margin-bottom: 16px; }
.eyebrow::before { content: '✦'; font-size: 9px; color: var(--gold); }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); gap: 16px; margin: 26px 0 14px; }
.card { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 10px; padding: 22px; box-shadow: var(--shadow); transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--line-strong); border-top-color: var(--accent); }
.card h3 { margin: 0 0 10px; font: 700 18px/1.3 var(--serif); color: var(--text); }
.card p { margin: 0; font-size: 15px; color: var(--muted); line-height: 1.65; }
.card .num { display: block; font: 700 38px/1.1 var(--serif); letter-spacing: -.02em; color: var(--accent); margin-bottom: 10px; font-variant-numeric: tabular-nums; }

.page .steps { counter-reset: step; list-style: none; padding: 0; margin: 28px 0; }
.page .steps li { position: relative; padding: 0 0 24px 54px; margin: 0; }
.steps li::before { counter-increment: step; content: counter(step); position: absolute; left: 0; top: 2px; width: 36px; height: 36px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--gold-soft); color: var(--accent); font: 700 17px/34px var(--serif); text-align: center; box-shadow: 0 1px 3px rgba(35,24,21,0.06); }
.steps li strong { display: block; margin-bottom: 4px; font-family: var(--serif); font-size: 17px; color: var(--text); }

/* Tylko tabele informacyjne mają stałą siatkę; konto i tekst zachowują własny układ. */
.page table.stats { width: 100%; max-width: 100%; table-layout: fixed; overflow-wrap: anywhere; }
.page table.stats th, .page table.stats td { min-width: 0; hyphens: auto; }
table.stats { border-collapse: separate; border-spacing: 0; font-size: 15px; line-height: 1.6; margin: 20px 0 28px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
table.stats th, table.stats td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.stats th { font-size: 13px; font-family: var(--serif); font-variant-caps: all-small-caps; letter-spacing: .08em; color: var(--text); font-weight: 700; background: var(--panel-accent); border-bottom: 2px solid var(--line-strong); }
table.stats tr:hover td { background: var(--gold-soft); }
table.stats tr:last-child td { border-bottom: 0; }
table.stats td.n, table.stats th.n { text-align: right; font-variant-numeric: tabular-nums; }
/* Korpus → Dokumenty Kościoła: szeroka kolumna tytułu, wąskie rok i źródło */
.page table.stats.church-docs th:nth-child(1) { width: 8%; }
.page table.stats.church-docs th:nth-child(2) { width: 42%; }
.page table.stats.church-docs th:nth-child(3) { width: 17%; }
.page table.stats.church-docs th:nth-child(4) { width: 18%; }
.page table.stats.church-docs th:nth-child(5) { width: 15%; }
.tag { display: inline-block; max-width: 100%; border-radius: 5px; font-size: 12px; line-height: 1.5; padding: 2px 7px; font-weight: 650; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-soft); vertical-align: middle; }
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-soft); }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-soft); }

.callout { display: flex; gap: 14px; padding: 22px; margin: 24px 0; border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); }
.callout > span { flex-shrink: 0; color: var(--accent); font-size: 22px; line-height: 1.4; }
.callout > p, .callout > div { min-width: 0; }
.callout p { margin: 0; font-size: 16px; }
.callout.warn { border-left-color: var(--warn); background: var(--warn-soft); }

details.more { margin: 18px 0 26px; border: 1px solid var(--line); border-radius: 10px; padding: 0 18px; background: var(--panel); box-shadow: var(--shadow); }
details.more > summary { cursor: pointer; color: var(--accent); font-family: var(--serif); font-size: 16px; font-weight: 700; min-height: 48px; padding: 12px 0; }
details.more[open] > summary { margin-bottom: 12px; border-bottom: 1px solid var(--line); }

.cta { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; max-width: 100%; background: linear-gradient(180deg, var(--accent) 0%, #681420 100%); color: var(--on-accent); text-decoration: none; padding: 12px 22px; border: 1px solid #58101a; border-radius: 8px; font-family: var(--serif); font-weight: 700; font-size: 16px; line-height: 1.4; letter-spacing: .02em; margin: 6px 10px 6px 0; box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 3px 8px rgba(104,20,32,0.3); transition: all .15s ease; }
.cta:hover { background: linear-gradient(180deg, #992132 0%, #751825 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), 0 4px 14px rgba(104,20,32,0.4); transform: translateY(-1px); color: var(--on-accent); text-decoration: none; }
.cta.ghost { background: var(--panel); color: var(--text); border-color: var(--control-line); box-shadow: var(--shadow); }
.cta.ghost:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Większe kontrolki na podstronach */
.page input:not([type=hidden]):not([type=checkbox]):not([type=radio]), .page select, .page textarea,
.site .subbar input[type=text] { min-width: 0; max-width: 100%; min-height: 48px; padding: 11px 14px; border: 1px solid var(--control-line); border-radius: 8px; font: 16px/1.5 var(--sans); background: var(--bg); color: var(--text); }
.page textarea { min-height: 120px; resize: vertical; }
.page input::placeholder, .page textarea::placeholder, .site .subbar input::placeholder { color: var(--muted); opacity: 0.9; }
.page button, .site .subbar button { min-height: 48px; max-width: 100%; padding: 12px 20px; border: 1px solid #58101a; border-radius: 8px; background: linear-gradient(180deg, var(--accent) 0%, #681420 100%); color: var(--on-accent); font: 700 16px/1.4 var(--serif); cursor: pointer; letter-spacing: .02em; box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 3px 8px rgba(104,20,32,0.3); transition: all .15s ease; }
.page button:hover, .site .subbar button:hover { background: linear-gradient(180deg, #992132 0%, #751825 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), 0 4px 14px rgba(104,20,32,0.4); transform: translateY(-1px); }
.page button:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.form-card { background: var(--panel); border: 1px solid var(--line-strong); border-top: 3px solid var(--accent); border-radius: 12px; padding: 34px; width: min(450px, 100%); margin: 24px auto; box-shadow: var(--shadow-lg); }
.form-card label { display: block; font: 700 15px/1.4 var(--serif); color: var(--text); margin: 20px 0 8px; }
.form-card input { width: 100%; }
.form-card button { margin-top: 24px; width: 100%; }
.form-card .err { color: var(--warn); font-size: 14px; margin-top: 12px; }
.page .acct { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.page .acct section { min-width: 0; border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 10px; padding: 24px; box-shadow: var(--shadow); background: var(--panel); }
.page .acct h2 { font: 700 21px/1.4 var(--serif); border-bottom: 0; margin-top: 0; }
.page .acct label { font: 600 15px/1.4 var(--serif); margin: 16px 0 8px; }
.page .acct button { font: 700 16px/1.4 var(--serif); color: var(--on-accent); }
.page .acct button.ghost { background: var(--panel); color: var(--accent); border-color: var(--control-line); box-shadow: var(--shadow); }
.page .acct form > div > div { min-width: 0; }
.page .acct .table-scroll { width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
.page .acct .table-scroll table { table-layout: auto; overflow-wrap: break-word; }
.site .subbar form { min-width: min(280px, 100%); }
.site .subbar input[type=text] { background: var(--panel); }
.page nav.pager { flex-wrap: wrap; }
.page nav.pager a { display: inline-flex; align-items: center; min-height: 44px; }

@media (hover: hover) {
  .page a:not(.cta):hover, .site-footer a:hover { color: var(--accent); text-decoration: underline; }
  .cta:hover { box-shadow: var(--shadow-lg); }
  .page button:not(:disabled):hover, .site .subbar button:hover { box-shadow: var(--shadow-lg); }
}
@media (max-width: 760px) {
  .page .acct { grid-template-columns: minmax(0, 1fr); }
  .page .acct .table-scroll table { min-width: 650px; }
}
@media (max-width: 600px) {
  .page { padding-top: 30px; padding-bottom: 48px; }
  .page h2 { margin-top: 36px; }
  .page .lead { font-size: 17px; }
  .card, .callout, .page .acct section { padding: 18px; }
  .form-card { padding: 24px 20px; margin-block: 8px; }
  table.stats th, table.stats td { padding: 10px 8px; }
  table.stats .tag { padding-inline: 4px; }
  .page .acct form > div[style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }
}

/* ---------- stopka ---------- */
.site-footer {
  border-top: 2px solid var(--line);
  background: var(--panel);
  padding: 28px clamp(16px, 3vw, 32px);
  color: var(--muted);
  font-family: var(--serif);
  font-size: 14px;
  position: relative;
}
.site-footer::before {
  content: '';
  position: absolute;
  top: -2px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--gold) 20%, var(--gold) 80%, transparent 100%);
  opacity: 0.35;
}
.site-footer .inner { max-width: 1200px; margin: 0 auto; display: flex; gap: 12px 24px; flex-wrap: wrap; align-items: center; overflow-wrap: anywhere; }
.site-footer .inner > * { min-width: 0; max-width: 100%; }
.site-footer a { color: var(--muted); text-decoration: underline; }
.site-footer .fill { flex: 1; }
.site-footer code { font: 13px var(--mono); background: var(--panel-accent); padding: 2px 5px; border-radius: 4px; border: 1px solid var(--line); }
@media (max-width: 600px) {
  .site-footer .inner { align-items: flex-start; flex-direction: column; gap: 16px; }
  .site-footer .fill { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .mainnav a.on { border-color: Highlight; }
  .page input:not([type=hidden]), .page select, .page textarea, .page button, .cta { border-color: ButtonText; }
}
