/* Wywiad z asystentem AI - styl urzędowego portalu miejskiego. Zero zasobów zewnętrznych (CSP: default-src 'self').
   Kontrast (WCAG): tekst #1b2733 na #fff 15,1:1, na #f4f7fa 13,9:1; akcent tekstowy #00659a na #fff 6,4:1, na #f4f7fa 5,9:1;
   biały na #00659a 6,4:1; #0089c9 tylko jako element graficzny (3,6:1 na białym); obramowanie #c9d3dc jest dekoracją,
   a pola formularzy mają obrys #5f7385 (4,7:1). Fokus 3 px #00659a (6,4:1). */

:root {
  --bg: #ffffff; --surface: #f4f7fa; --text: #1b2733; --muted: #465766;
  --accent: #00659a; --accent-g: #0089c9; --border: #c9d3dc; --field: #5f7385;
  --focus: #00659a; --on-accent: #ffffff;
  --err: #a4161a; --err-bg: #fff3f1; --warn-bg: #fff6df; --warn: #7a4a00;
  --user-bg: #e4f2fa; --scale: 1;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #14181d; --surface: #1d242b; --text: #e8eef3; --muted: #b7c3cd; --accent: #7fcbf2; --accent-g: #4db8ec;
  --border: #46535f; --field: #8fa1af; --focus: #ffd24d; --on-accent: #0b1b2a; --err: #ff9d9d; --err-bg: #3a1c1c;
  --warn-bg: #3a3015; --warn: #ffd98a; --user-bg: #1f3446; color-scheme: dark;
}
:root[data-theme="contrast"] {
  --bg: #000; --surface: #000; --text: #ffff00; --muted: #ffff00; --accent: #ffff00; --accent-g: #ffff00;
  --border: #ffff00; --field: #ffff00; --focus: #00ffff; --on-accent: #000; --err: #ff9a9a; --err-bg: #000;
  --warn-bg: #000; --warn: #ffff00; --user-bg: #000; color-scheme: dark;
}

[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { font-size: calc(100% * var(--scale)); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); min-height: 100vh;
  font: 1rem/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  display: flex; flex-direction: column; overflow-wrap: anywhere;
}
button, input, textarea, select { font: inherit; color: inherit; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 1.25rem 0 1rem; }
h2 { font-size: 1.3rem; line-height: 1.3; margin: 0 0 .75rem; }
h3 { font-size: 1.1rem; margin: 0 0 .5rem; }
p { margin: 0 0 1rem; max-width: 70ch; }
a { color: var(--accent); text-underline-offset: .2em; }
a:hover { text-decoration-thickness: .15em; }
ul { margin: 0 0 1rem; padding-left: 1.25rem; }
.muted { color: var(--muted); }
.small-text { font-size: .9rem; margin-bottom: .5rem; }
.wrap { max-width: 52rem; margin: 0 auto; padding-inline: 1rem; }
main { flex: 1 0 auto; width: 100%; padding-bottom: 2rem; }
main:focus, section:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: .5rem; top: -5rem; z-index: 100; background: var(--accent); color: var(--on-accent); padding: .75rem 1rem; border-radius: .3rem; }
.skip-link:focus { top: .5rem; }

/* przyciski */
.btn {
  display: inline-flex; align-items: center; justify-content: center; text-align: center; gap: .4rem;
  min-height: 44px; min-width: 44px; padding: .45rem 1.1rem; border-radius: .35rem; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--on-accent); border: 2px solid var(--accent); font-weight: 600; line-height: 1.25;
}
.btn.secondary { background: var(--bg); color: var(--accent); border-color: var(--accent); }
.btn.danger { background: var(--bg); color: var(--err); border-color: var(--err); }
.btn.small { padding: .25rem .7rem; font-size: .95rem; background: var(--bg); color: var(--accent); border-color: var(--field); }
.btn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--surface); color: var(--muted); border: 2px dashed var(--muted); cursor: not-allowed; }
.btn:hover:not(:disabled) { filter: brightness(.92); }
.help-btn { background: var(--err-bg); color: var(--err); border-color: var(--err); font-weight: 700; }
.help-btn[aria-expanded="true"]::before { content: "▾ "; } .help-btn[aria-expanded="false"]::before { content: "▸ "; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: .5rem 0 1rem; }

/* nagłówek */
.site-header { border-bottom: 1px solid var(--border); background: var(--bg); }
.toolbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; padding-block: .5rem; }
.tools .group { display: inline-flex; gap: .25rem; }
.brandbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .25rem 1rem; padding-block: .6rem; }
.brand { margin: 0; font-weight: 700; font-size: 1.1rem; border-left: 6px solid var(--accent-g); padding-left: .6rem; }
.brand-link { padding-block: .6rem; }
.notice-ai { background: var(--user-bg); border-block: 3px solid var(--accent-g); }
.notice-ai p { margin: 0; padding-block: .6rem; max-width: none; }

/* pola, zgody */
.check { display: flex; align-items: flex-start; gap: .6rem; min-height: 44px; padding: .45rem 0; cursor: pointer; }
.check.inline { display: inline-flex; align-items: center; padding: .25rem 0; }
.check input { flex: none; width: 1.5rem; height: 1.5rem; margin: .1rem 0 0; accent-color: var(--accent); }
.check.inline input { margin: 0; }
.check.radio { border: 1px solid var(--border); border-radius: .35rem; padding: .5rem .75rem; margin-bottom: .5rem; background: var(--surface); }
fieldset { border: 1px solid var(--border); border-radius: .4rem; padding: .75rem 1rem; margin: 0 0 1rem; min-width: 0; }
legend { font-weight: 700; padding-inline: .4rem; }
.field { margin-bottom: 1rem; }
label { font-weight: 600; }
.check span, .check.inline span { font-weight: 400; }
.check.inline span { font-weight: 600; }
select, input[type="range"] { width: 100%; max-width: 30rem; min-height: 44px; }
select { padding: .4rem; background: var(--bg); border: 2px solid var(--field); border-radius: .35rem; display: block; }
textarea {
  display: block; width: 100%; min-height: 5.5rem; padding: .6rem .75rem; border: 2px solid var(--field); border-radius: .35rem;
  background: var(--bg); line-height: 1.5; resize: vertical; margin-top: .35rem;
}
.error { color: var(--err); font-weight: 600; margin: .25rem 0 .5rem; }
.error:empty { display: none; }
.error:not(:empty)::before { content: "Błąd: "; }
.warn { background: var(--warn-bg); color: var(--warn); border: 2px solid var(--warn); border-radius: .35rem; padding: .5rem .75rem; font-weight: 600; max-width: none; }
.warn::before { content: "Uwaga: "; }
.alert { background: var(--err-bg); color: var(--err); border: 2px solid var(--err); border-left-width: 8px; border-radius: .35rem; padding: .6rem .9rem; margin: .75rem 0; }
.alert p { margin: 0 0 .5rem; font-weight: 600; }
.alert p:last-child { margin-bottom: 0; }
.alert .btn { color: var(--on-accent); background: var(--err); border-color: var(--err); }
:root[data-theme="dark"] .alert .btn { color: #1d0b0b; }
:root[data-theme="contrast"] .alert .btn { color: #000; background: #ff9a9a; }

/* panele */
.panels { padding-top: .75rem; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: .5rem; padding: 1rem 1.1rem; margin-bottom: 1rem; }
.panel.help { background: var(--err-bg); border: 3px solid var(--err); border-left-width: 10px; }
.panel.help h2 { color: var(--err); }
.panel.help h2::before { content: "Ważne – pomoc: "; }
.numbers { list-style: none; padding: 0; }
.numbers li { margin-bottom: .6rem; font-size: 1.05rem; }
.num { display: inline-block; min-height: 44px; line-height: 44px; font-size: 1.4rem; font-weight: 800; color: var(--text); background: var(--bg); border: 2px solid var(--err); border-radius: .35rem; padding-inline: .75rem; margin-right: .4rem; text-decoration: none; }
.panel.done { border-left: 8px solid var(--accent-g); }
.tips { color: var(--muted); }

/* rozmowa */
.progress-box { margin-bottom: .75rem; }
.topic-label { margin: 0 0 .3rem; font-weight: 700; }
progress { width: 100%; max-width: 30rem; height: 1rem; accent-color: var(--accent-g); }
.log {
  border: 2px solid var(--border); border-radius: .5rem; background: var(--bg); padding: .75rem;
  max-height: max(20rem, 50vh); overflow-y: auto; display: flex; flex-direction: column; gap: .75rem; scroll-behavior: auto;
}
.msg { max-width: 85%; border-radius: .6rem; padding: .5rem .8rem; border: 1px solid var(--border); }
.msg .meta { display: flex; flex-wrap: wrap; gap: .1rem .6rem; font-size: .85rem; color: var(--muted); margin-bottom: .15rem; }
.msg .who { font-weight: 700; color: var(--text); }
.msg .body { margin: 0; white-space: pre-wrap; max-width: none; }
.msg-agent { align-self: flex-start; background: var(--surface); border-left: 5px solid var(--accent-g); }
.msg-user { align-self: flex-end; background: var(--user-bg); border-right: 5px solid var(--accent); }
.msg.streaming .body::after { content: " ▍"; color: var(--accent-g); }
.msg.incomplete { border-style: dashed; }
.msg-safety { border: 3px solid var(--err); }
.msg-safety .who::after { content: " – ważna wiadomość"; color: var(--err); }
.typing { min-height: 1.6rem; margin: .4rem 0 0; color: var(--muted); font-style: italic; }
.composer { margin-top: .75rem; }
.composer > label { display: block; }
.voice-opts { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; }
.mic-line { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .9rem; margin: .25rem 0 .75rem; }
.mic-status { margin: 0; min-height: 1.5rem; font-weight: 600; }
.meter { flex: none; width: 7rem; height: .9rem; border: 2px solid var(--field); border-radius: .5rem; overflow: hidden; background: var(--bg); }
.meter-fill { display: block; height: 100%; width: calc(var(--level, 0) * 100%); background: var(--accent-g); }
.end-actions { border-top: 1px solid var(--border); padding-top: .75rem; }
.keys { margin-top: 1rem; }
.keys summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; }
kbd { border: 1px solid var(--field); border-bottom-width: 2px; border-radius: .3rem; padding: 0 .35rem; background: var(--surface); font: inherit; font-size: .9em; }

.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding-block: .5rem; }
.flinks { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; padding: 0; margin: 0; }
.flinks a { display: inline-block; padding-block: .6rem; }

@media (max-width: 30rem) {
  .msg { max-width: 94%; }
  .actions .btn { flex: 1 1 100%; }
  .tools .btn.small { flex: none; }
}
@media (prefers-reduced-motion: no-preference) { .btn { transition: filter .15s; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media (forced-colors: active) {
  .btn, .msg, .panel, .alert, .warn { border: 2px solid CanvasText; }
  .btn[aria-pressed="true"] { forced-color-adjust: none; background: Highlight; color: HighlightText; }
  .meter-fill { forced-color-adjust: none; background: Highlight; }
  progress { forced-color-adjust: auto; }
}
