/* Czat z Bielikiem. Barwy marki 1flowstack (homepage/index.html). */
:root {
  --bg: #f6f6fa;
  --surface: #ffffff;
  --fg: #0b0f1f;
  --muted: #4b5169;
  --line: #e2e4ee;
  --accent: #5640ee;
  --accent-fg: #ffffff;
  --accent-soft: #ecebfd;
  --user-bg: #5640ee;
  --user-fg: #ffffff;
  --error: #c4302b;
  --error-soft: #fdeceb;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #090c1a;
    --surface: #111733;
    --fg: #eef0f8;
    --muted: #a6acc4;
    --line: #232a4a;
    --accent: #9a8cff;
    --accent-fg: #090c1a;
    --accent-soft: #1d2148;
    --user-bg: #3b2fb8;
    --user-fg: #ffffff;
    --error: #ff8a84;
    --error-soft: #3a1618;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }

.primary {
  border: 0;
  border-radius: 10px;
  padding: 10px 18px;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}
.ghost {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 12px;
  background: transparent;
  font-size: 14px;
}
.ghost:hover { background: var(--accent-soft); }
.ghost.small { padding: 4px 10px; font-size: 13px; }

.logo {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 700;
  font-size: 22px;
}
.logo.small { width: 26px; height: 26px; border-radius: 8px; font-size: 14px; }

/* --- logowanie --- */
.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
  display: grid;
  gap: 10px;
}
.login-card h1 { margin: 6px 0 0; font-size: 26px; }
.login-card p { margin: 0 0 6px; }
.login-card label { font-size: 14px; font-weight: 600; }
.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.login-card .primary { margin-top: 6px; }
.error {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--error-soft);
  color: var(--error);
  font-size: 14px;
}

/* --- czat --- */
.chat {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 820px;
  margin: 0 auto;
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.brand .muted { font-weight: 400; font-size: 14px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pill {
  font-size: 13px;
  color: var(--muted);
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.empty { margin: auto 0; text-align: center; padding: 0 8px; }
.empty h2 { margin: 0 0 8px; font-size: 22px; }
.empty p { margin: 4px auto; max-width: 460px; }

.msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.user {
  align-self: flex-end;
  background: var(--user-bg);
  color: var(--user-fg);
  border-bottom-right-radius: 4px;
}
.msg.assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.msg .text:empty::before { content: "…"; color: var(--muted); }
.msg code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--accent-soft);
}
.msg .meta {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: normal;
}
.msg.failed { border-color: var(--error); }
.note {
  align-self: center;
  font-size: 14px;
  color: var(--error);
  background: var(--error-soft);
  padding: 6px 12px;
  border-radius: 8px;
  text-align: center;
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 16px 8px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 15px;
}
.status #status-text { flex: 1; }
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }

.composer {
  display: flex;
  gap: 8px;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 200px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  line-height: 1.4;
}

@media (max-width: 520px) {
  .brand .muted { display: none; }
  .msg { max-width: 94%; }
}
