/* =====================================================================
   jerzykolosowski.pl — design system (v3, 2026-04-18)
   ---------------------------------------------------------------------
   AESTHETIC: personal engineering notebook / homelab terminal session.
   Not a portfolio. Not a SaaS landing. A snapshot of a tech-lead's
   workspace.

   Mono-dominant. Box-drawing borders. Warm amber accent on dark
   cool teal background. ASCII chrome. Paper-grain light mode.
   ===================================================================== */

:root {
  /* Font stack: IBM Plex Mono primary (technical, Unicode box-drawing OK).
     JetBrains Mono Variable as fallback. ui-monospace last. Ship without
     webfonts — user's installed variants provide the upgrade. */
  --font-mono:  "IBM Plex Mono", "JetBrains Mono Variable", "JetBrains Mono", ui-monospace, "Berkeley Mono", "SF Mono", Menlo, Monaco, Consolas, monospace;
  /* Serif only for long-form reading (blog body, CV body). Charter has
     a technical/engineer feel; Iowan as fallback. */
  --font-serif: "Charter", "Iowan Old Style", "Source Serif Pro", Georgia, Cambria, serif;
  /* Sans retained for one job: hero wordmark if ASCII fallback fails. */
  --font-sans:  ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --measure: 68ch;
  --pad-page: clamp(1rem, 3.5vw, 2rem);
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 6px;

  --transition: 150ms cubic-bezier(.32, .72, 0, 1);
  --transition-slow: 320ms cubic-bezier(.32, .72, 0, 1);

  /* Hue drivers — deliberate split:
     - bg/ink share a cool teal (215°)
     - accent is warm amber (80°) — screams across from bg for attention
     Sharp contrast, not uniform muted tokens. */
  --hue-bg: 215;
  --hue-accent: 80;
}

/* ---- DARK (default intent — this is a terminal, after all) -------- */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:           oklch(0.145 0.012 var(--hue-bg));
  --surface:      oklch(0.180 0.014 var(--hue-bg));
  --surface-alt:  oklch(0.215 0.016 var(--hue-bg));
  --surface-sunk: oklch(0.125 0.012 var(--hue-bg));
  --border:       oklch(0.32  0.020 var(--hue-bg));
  --border-soft:  oklch(0.24  0.016 var(--hue-bg));
  --ink:          oklch(0.93  0.018 var(--hue-accent));
  --ink-soft:     oklch(0.72  0.015 var(--hue-accent));
  --ink-faint:    oklch(0.55  0.012 var(--hue-accent));
  --accent:       oklch(0.80  0.17  var(--hue-accent));
  --accent-hover: oklch(0.88  0.18  var(--hue-accent));
  --accent-soft:  oklch(0.30  0.08  var(--hue-accent));
  --accent-ink:   oklch(0.90  0.15  var(--hue-accent));
  --positive:     oklch(0.78  0.16  150);
  --warn:         oklch(0.78  0.15  30);
  --danger:       oklch(0.70  0.20  25);
  --code-bg:      oklch(0.215 0.016 var(--hue-bg));
  --transcript-user: oklch(0.30 0.08 var(--hue-accent));
  --transcript-ai:   oklch(0.215 0.016 var(--hue-bg));
  --grain-opacity: 0.05;
}

/* ---- LIGHT (paper / notebook mode) -------------------------------- */
:root[data-theme="light"] {
  color-scheme: light;
  --bg:           oklch(0.975 0.008 85);    /* warm cream */
  --surface:      oklch(0.995 0.004 85);
  --surface-alt:  oklch(0.945 0.015 85);
  --surface-sunk: oklch(0.920 0.020 85);
  --border:       oklch(0.80  0.020 85);
  --border-soft:  oklch(0.88  0.015 85);
  --ink:          oklch(0.22  0.015 var(--hue-bg));
  --ink-soft:     oklch(0.42  0.020 var(--hue-bg));
  --ink-faint:    oklch(0.60  0.015 var(--hue-bg));
  --accent:       oklch(0.48  0.22  30);    /* rust ink stamp */
  --accent-hover: oklch(0.40  0.24  30);
  --accent-soft:  oklch(0.92  0.05  30);
  --accent-ink:   oklch(0.35  0.24  30);
  --positive:     oklch(0.52  0.15  150);
  --warn:         oklch(0.60  0.15  60);
  --danger:       oklch(0.55  0.22  25);
  --code-bg:      oklch(0.945 0.015 85);
  --transcript-user: oklch(0.92 0.05 30);
  --transcript-ai:   oklch(0.945 0.015 85);
  --grain-opacity: 0.06;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    color-scheme: light;
    --bg:           oklch(0.975 0.008 85);
    --surface:      oklch(0.995 0.004 85);
    --surface-alt:  oklch(0.945 0.015 85);
    --surface-sunk: oklch(0.920 0.020 85);
    --border:       oklch(0.80  0.020 85);
    --border-soft:  oklch(0.88  0.015 85);
    --ink:          oklch(0.22  0.015 var(--hue-bg));
    --ink-soft:     oklch(0.42  0.020 var(--hue-bg));
    --ink-faint:    oklch(0.60  0.015 var(--hue-bg));
    --accent:       oklch(0.48  0.22  30);
    --accent-hover: oklch(0.40  0.24  30);
    --accent-soft:  oklch(0.92  0.05  30);
    --accent-ink:   oklch(0.35  0.24  30);
    --positive:     oklch(0.52  0.15  150);
    --warn:         oklch(0.60  0.15  60);
    --danger:       oklch(0.55  0.22  25);
    --code-bg:      oklch(0.945 0.015 85);
    --transcript-user: oklch(0.92 0.05 30);
    --transcript-ai:   oklch(0.945 0.015 85);
    --grain-opacity: 0.06;
  }
}

/* ---- reset --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: clamp(14px, 13.5px + 0.2vw, 15.5px);
  line-height: 1.62;
  font-feature-settings: "ss01";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  position: relative;
}

/* Grain overlay — paper fibre (light) / screen grain (dark).
   Inline SVG, zero HTTP. Reduced motion preserves subtle grain. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.9'/></svg>");
  background-size: 180px 180px;
  mix-blend-mode: overlay;
}

img, svg, video { max-width: 100%; height: auto; display: block; }

time, kbd, code, pre, .tabular {
  font-variant-numeric: tabular-nums;
}

::selection { background: var(--accent); color: var(--bg); }

/* a11y utility — visually hidden but present in DOM for screen readers */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Reset Blazor FocusOnNavigate visible outline */
h1[tabindex="-1"]:focus,
h1:focus:not(:focus-visible),
[tabindex="-1"]:focus:not(:focus-visible) { outline: none; }

/* ---- links --------------------------------------------------------- */
a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, var(--accent) 35%, transparent);
  text-underline-offset: 0.22em;
  text-decoration-thickness: 1px;
  transition: color var(--transition), text-decoration-color var(--transition), background var(--transition);
}
a:hover {
  color: var(--accent-hover);
  text-decoration-color: var(--accent-hover);
  background: var(--accent-soft);
}
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---- typography ---------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-mono);
  letter-spacing: -0.005em;
  line-height: 1.15;
  color: var(--ink);
  text-wrap: balance;
}

/* ---- prose (CV, blog body) ---------------------------------------- */
.prose {
  font-family: var(--font-serif);
  font-size: clamp(1rem, 0.97rem + 0.15vw, 1.08rem);
  line-height: 1.72;
  max-width: var(--measure);
  color: var(--ink);
}
.prose > * + * { margin-top: 1.05em; }

.prose h1 {
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 1.3rem + 0.7vw, 1.85rem);
  line-height: 1.2;
  margin-top: 0;
}
.prose h1::before {
  content: "# ";
  color: var(--ink-faint);
}
.prose h2 {
  font-family: var(--font-mono);
  font-size: clamp(1.15rem, 1.05rem + 0.4vw, 1.35rem);
  line-height: 1.25;
  margin-top: 2.6em;
}
.prose h2::before {
  content: "## ";
  color: var(--ink-faint);
}
.prose h3 {
  font-family: var(--font-mono);
  font-size: clamp(1.02rem, 0.98rem + 0.2vw, 1.15rem);
  line-height: 1.3;
  margin-top: 1.9em;
}
.prose h3::before {
  content: "### ";
  color: var(--ink-faint);
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.prose pre {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  background: var(--code-bg);
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  line-height: 1.55;
  position: relative;
}
.prose pre::before {
  content: "$";
  position: absolute;
  top: 0.5rem;
  right: 0.7rem;
  color: var(--ink-faint);
  font-size: 0.75em;
}
.prose pre code { background: transparent; padding: 0; border: 0; border-radius: 0; }
.prose blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 1.1rem;
  color: var(--ink-soft);
  font-style: italic;
  position: relative;
}
.prose blockquote::before {
  content: ">";
  position: absolute;
  left: -1.2rem;
  top: 0;
  color: var(--accent);
  font-family: var(--font-mono);
  font-style: normal;
}
.prose hr {
  border: 0;
  height: 1px;
  background: var(--border);
  position: relative;
  margin: 2.8em 0;
}
.prose hr::before {
  content: "— ❦ —";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg);
  padding: 0 0.8em;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
}
.prose ul, .prose ol { padding-left: 1.4em; }
.prose ul li::marker { color: var(--ink-faint); content: "· "; }
.prose li + li { margin-top: 0.35em; }
.prose strong {
  color: var(--ink);
  font-weight: 600;
  background: color-mix(in oklab, var(--accent) 14%, transparent);
  padding: 0 0.15em;
}

/* ---- utilities ---------------------------------------------------- */
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.small { font-size: 0.88em; }

/* Box-drawing wrapper — wraps content in ASCII corners.
   Usage: <div class="box"><div class="box__label">label</div> ... </div> */
.box {
  position: relative;
  border: 1px solid var(--border);
  padding: 1.25rem 1.4rem;
  background: var(--surface);
}
.box::before,
.box::after,
.box > .box__label::before,
.box > .box__label::after {
  position: absolute;
  font-family: var(--font-mono);
  color: var(--border);
  line-height: 1;
  font-size: 1rem;
}
.box::before { content: "┌"; top: -1px; left: -1px; transform: translate(-50%, -50%); background: var(--bg); padding: 0 2px; }
.box::after  { content: "┐"; top: -1px; right: -1px; transform: translate(50%, -50%); background: var(--bg); padding: 0 2px; }
.box > .box__label {
  position: absolute;
  top: -0.6em;
  left: 1rem;
  background: var(--bg);
  padding: 0 0.5em;
  font-size: 0.75rem;
  color: var(--ink-faint);
  letter-spacing: 0.05em;
}

/* page head — top-of-page title for Blog/Chat-style pages */
.page-head {
    margin-bottom: 2.5rem;
    max-width: var(--measure);
}
.page-head h1 {
    font-family: var(--font-mono);
    font-size: clamp(1.4rem, 1.25rem + 0.6vw, 1.7rem);
    line-height: 1.2;
    letter-spacing: -0.005em;
    font-weight: 600;
    margin: 0 0 0.5rem;
    color: var(--ink);
}
.page-head h1::before {
    content: "$ ";
    color: var(--accent);
    font-weight: 400;
}
.page-head p {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    color: var(--ink-soft);
    line-height: 1.55;
}

/* kbd */
.kbd, kbd {
  font-family: var(--font-mono);
  font-size: 0.82em;
  padding: 0.08em 0.45em;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--ink-soft);
}

/* Prompt marker — use as decoration on input lines, prompt-style */
.prompt::before {
  content: "$ ";
  color: var(--accent);
  font-family: var(--font-mono);
}

/* Hairline divider with fade */
.hairline {
  border: 0;
  height: 1px;
  background: var(--border);
  mask-image: linear-gradient(90deg, transparent, black 15%, black 85%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, black 15%, black 85%, transparent);
}

/* ---- boot screen -------------------------------------------------- */
.boot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: 2rem;
  font-family: var(--font-mono);
  color: var(--ink-soft);
}
.boot__name {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.boot__name::before { content: "$ "; color: var(--accent); }
.boot__sub { margin: 0.6rem 0 0; font-size: 0.85rem; }

/* ---- error overlay ----------------------------------------------- */
#blazor-error-ui {
  background: var(--danger);
  color: oklch(0.98 0.005 80);
  bottom: 0;
  left: 0;
  display: none;
  position: fixed;
  width: 100%;
  padding: 0.6rem 1.2rem;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  z-index: 1000;
  border-top: 1px solid oklch(0.4 0.22 25);
}
#blazor-error-ui::before {
  content: "ERR: ";
  font-weight: 700;
  margin-right: 0.25em;
}
#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
}

/* ---- cursor blink ------------------------------------------------- */
.cursor-blink::after {
  content: "▍";
  display: inline-block;
  margin-left: 0.15em;
  color: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}
@media (prefers-reduced-motion: reduce) {
  .cursor-blink::after { animation: none; opacity: 0.65; }
}
@keyframes blink {
  0%, 50%   { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

/* ---- View Transitions API (Chromium) ---------------------------- */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 180ms;
    animation-timing-function: cubic-bezier(.32, .72, 0, 1);
  }
  ::view-transition-old(root) { animation-name: vt-out; }
  ::view-transition-new(root) { animation-name: vt-in; }

  @keyframes vt-out { to { opacity: 0; } }
  @keyframes vt-in  { from { opacity: 0; } }
}

/* ---- A11y: skip link ------------------------------------------------
   Ukryty wizualnie dopóki nie dostanie fokusu klawiaturowego (Tab z URL bar).
   Dla screen reader-ów skip-link to standardowy pierwszy element nawigacji
   żeby pominąć powtarzający się chrome (header, status bar, etc.). */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  padding: 0.5rem 1rem;
  background: var(--accent, #4ec9b0);
  color: var(--bg, #0e1116);
  text-decoration: none;
  font-weight: bold;
  z-index: 1000;
  border-radius: 0 0 4px 0;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: 0;
  outline: 2px solid var(--accent, #4ec9b0);
  outline-offset: 2px;
}

/* ---- A11y: visually-hidden helper dla screen-reader-only labels ----
   Standardowy WAI pattern, identyczny z Bootstrap visually-hidden. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Mobile: max-width 640px ----------------------------------------
   Terminal aesthetic na małych ekranach: drobniejsze fonty, ciasniejszy
   padding, scaledown banner. Boot animation skipped (per reduced-motion
   wzorzec — na mobile użytkownik chce treści, nie spektaklu). */
@media (max-width: 640px) {
  :root {
    font-size: 14px;
  }
  body {
    padding: 0;
  }
  /* Terminal layout — usuń marginy, full-width canvas. */
  .terminal-shell,
  .terminal-shell__container,
  .terminal-shell__transcript {
    padding-left: 0.6rem;
    padding-right: 0.6rem;
  }
  /* Boot screen: pomiń animację — pokaż od razu prompt. */
  .boot__name {
    font-size: 1.2rem;
  }
  .boot__sub {
    font-size: 0.9rem;
  }
  /* Header — schowaj subtitle na mobile, zostaw tylko brand + toggles. */
  .site-header__sub {
    display: none;
  }
  /* Status bar — kondensuj dwie kolumny w jedną. */
  .status-bar {
    flex-direction: column;
    gap: 0.25rem;
    align-items: flex-start;
    font-size: 0.78rem;
  }
  /* Reader body — mniejsze nagłówki, węższy line-height. */
  .reader-body h1 { font-size: 1.5rem; }
  .reader-body h2 { font-size: 1.25rem; }
  .reader-body h3 { font-size: 1.1rem; }
  .reader-body pre {
    font-size: 0.78rem;
    overflow-x: auto;
  }
  /* Chips — wrap, większy tap target. */
  .line__chips {
    gap: 0.4rem;
  }
  .line__chip {
    min-height: 36px;
    padding: 0.4rem 0.7rem;
  }
  /* SocialComments — kompaktowy layout. */
  .social-comments__item {
    padding: 0.4rem 0.5rem;
  }
}

/* ---- A11y: focus visible ring -------------------------------------- */
:focus-visible {
  outline: 2px solid var(--accent, #4ec9b0);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---- Search / Ask results — listy linków pod cytat-em LLM-a -------- */
.search-results {
  list-style: none;
  margin: 0.5rem 0;
  padding: 0;
  counter-reset: result;
}
.search-results li {
  margin: 0.5rem 0;
  padding-left: 0;
}
.search-results a {
  color: var(--accent, #4ec9b0);
  text-decoration: none;
  font-weight: bold;
}
.search-results a:hover,
.search-results a:focus {
  text-decoration: underline;
}
.search-results small {
  display: block;
  margin-top: 0.2rem;
  color: var(--terminal-dim, #888);
  line-height: 1.4;
}
.search-results em {
  color: var(--terminal-dim, #888);
  font-style: italic;
  font-weight: normal;
}

/* ---- Touch tap target — WCAG 2.5.5 Level AAA wymaga 44x44px ------- */
@media (pointer: coarse) {
  button,
  a {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  /* Linki w prose nie powinny mieć min-width — to są inline z tekstem. */
  .reader-body a,
  .social-comments__body a {
    min-width: 0;
    min-height: 0;
    display: inline;
  }
}

/* =========================================================
   Chat UI — Etap 2 skeleton (jerzykolosowski.pl redesign)
   Klasy .chat-* — nowy interfejs czatu zastępujący terminal.
   App.razor nadal montuje TerminalShell; swap w Etap 3.
   ========================================================= */

/* -- Layout shell ---------------------------------------- */
.chat-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.chat-shell__body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.chat-shell__main {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* -- Header ---------------------------------------------- */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.chat-header__identity {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85em;
  flex-wrap: wrap;
}

.chat-header__name {
  font-weight: 600;
  color: var(--ink);
}

.chat-header__sep { color: var(--border); }
.chat-header__role,
.chat-header__location { color: var(--ink-soft); }

.chat-header__actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
}

.chat-header__action {
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.8em;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--font-mono);
  transition: color var(--transition), background var(--transition);
  line-height: 1;
}

.chat-header__action:hover,
.chat-header__action:focus-visible {
  color: var(--accent);
  background: var(--surface-alt);
}

.chat-header__matrix { font-size: 1em; padding: 0.25rem 0.4rem; }

/* -- Snapshot aside (zero-klikowy snapshot) -------------- */
.chat-snapshot {
  width: 200px;
  flex-shrink: 0;
  padding: 1rem 0.875rem;
  border-right: 1px solid var(--border-soft);
  background: var(--surface);
  overflow-y: auto;
  display: none; /* mobile: ukryty */
}

@media (min-width: 768px) {
  .chat-snapshot { display: block; }
}

.chat-snapshot__name {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.9em;
  margin-bottom: 0.2rem;
}

.chat-snapshot__role {
  color: var(--accent);
  font-size: 0.8em;
  margin-bottom: 0.25rem;
}

.chat-snapshot__meta {
  color: var(--ink-soft);
  font-size: 0.78em;
  line-height: 1.4;
  margin-bottom: 0.15rem;
}

.chat-snapshot__actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.875rem;
}

.chat-snapshot__cta {
  display: block;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.78em;
  text-align: center;
  transition: color var(--transition), border-color var(--transition);
}

.chat-snapshot__cta:hover,
.chat-snapshot__cta:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
}

/* -- Chat timeline --------------------------------------- */
.chat-timeline {
  list-style: none;
  margin: 0;
  padding: 1rem;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

/* -- Individual message ---------------------------------- */
.chat-msg {
  display: flex;
  gap: 0.5rem;
  max-width: 80%;
}

.chat-msg--user      { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg--assistant { align-self: flex-start; }
.chat-msg--system    { align-self: center; max-width: 100%; }

.chat-msg__avatar {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  align-self: flex-start;
}

.chat-msg__body {
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-lg);
  line-height: 1.55;
  font-size: 0.9em;
  word-break: break-word;
}

.chat-msg--user .chat-msg__body {
  background: var(--transcript-user);
  color: var(--ink);
  border-bottom-right-radius: 0;
}

.chat-msg--assistant .chat-msg__body {
  background: var(--transcript-ai);
  border: 1px solid var(--border-soft);
  color: var(--ink);
  border-bottom-left-radius: 0;
}

.chat-msg--system .chat-msg__body {
  background: transparent;
  color: var(--ink-faint);
  font-size: 0.8em;
  text-align: center;
}

/* -- Chips (InputChipBar + in-message chips) ------------ */
.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.5rem 0 0;
}

.chat-chip {
  padding: 0.2rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.78em;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.chat-chip:hover,
.chat-chip:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--surface);
}

/* -- Input area ----------------------------------------- */
.chat-input-wrap {
  border-top: 1px solid var(--border-soft);
  padding: 0.65rem 1rem;
  background: var(--surface);
  flex-shrink: 0;
}

.chat-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  margin-top: 0.4rem;
}

.chat-input__textarea {
  flex: 1;
  resize: none;
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-sunk);
  color: var(--ink);
  line-height: 1.5;
  min-height: 2.6rem;
  max-height: 9.5rem; /* ~6 lines */
  overflow-y: auto;
  transition: border-color var(--transition);
}

.chat-input__textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.chat-input__textarea::placeholder { color: var(--ink-faint); }

.chat-input__send {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 1rem;
  cursor: pointer;
  min-height: 2.6rem;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.chat-input__send:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
}

.chat-input__send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* -- Logos firm w welcome message (Etap 3) -------------- */
.company-logos {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.75rem;
}

.company-logos img {
  height: 28px;
  width: auto;
  filter: grayscale(1);
  opacity: 0.55;
  transition: filter var(--transition), opacity var(--transition);
}

.company-logos img:hover {
  filter: none;
  opacity: 1;
}

/* -- Tooltip dla logotypów (pure CSS, zero JS) ---------- */
[data-tooltip] { position: relative; }

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.72em;
  padding: 0.2rem 0.5rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after { opacity: 1; }
