* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #212121;
  --bg-side: #171717;
  --bg-input: #2f2f2f;
  --bg-user: #2f2f2f;
  --text: #ececec;
  --text-dim: #9b9b9b;
  --accent: #10a37f;
  --border: #3a3a3a;
  --code-bg: #111;
}

body.light {
  --bg: #ffffff;
  --bg-side: #f4f4f4;
  --bg-input: #ececec;
  --bg-user: #e8e8e8;
  --text: #1c1c1c;
  --text-dim: #6b6b6b;
  --border: #d6d6d6;
  --code-bg: #f0f0f0;
}

body {
  display: flex;
  height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  transition: background 0.25s, color 0.25s;
}
#sidebar, #composer-inner, .msg.user .bubble, #login-card {
  transition: background 0.25s, border-color 0.25s;
}

/* ---------- sidebar ---------- */
#sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-side);
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 12px;
}
/* ---------- logo / branding ---------- */
#brand {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 6px 4px;
}
#brand img { width: 138px; }
#brand span,
.welcome-caption {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 3.5px;
  color: var(--text-dim);
}
.welcome-logo { width: 230px; max-width: 70%; }
.welcome-caption { font-size: 12px; margin: 6px 0 14px; }
.login-logo { width: 180px; margin: 0 auto; }
#login-card .welcome-caption { text-align: center; margin: 2px 0 6px; }
/* granatowe logo -> białe na ciemnym motywie */
body:not(.light) #brand img,
body:not(.light) .welcome-logo,
body:not(.light) .login-logo { filter: brightness(0) invert(1); }

#new-chat {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
}
#new-chat:hover { background: var(--bg-input); }
.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 6px 6px 0;
}
.side-head button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 2px 7px;
}
.side-head button:hover { color: var(--text); }
#agents { display: flex; flex-direction: column; gap: 2px; max-height: 30%; overflow-y: auto; }
#agents .conv-item button.edit {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; padding: 0 8px; visibility: hidden;
}
#agents .conv-item:hover button.edit { visibility: visible; }
#conversations { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.conv-item {
  display: flex;
  align-items: center;
  border-radius: 8px;
  color: var(--text);
}
.conv-item.active, .conv-item:hover { background: var(--bg-input); }
.conv-item button.title {
  flex: 1;
  background: none;
  border: none;
  color: inherit;
  padding: 9px 10px;
  text-align: left;
  cursor: pointer;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-item button.del {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0 10px;
  visibility: hidden;
}
.conv-item:hover button.del { visibility: visible; }
.conv-item button.del:hover { color: #e66; }
#sidebar footer { font-size: 11.5px; color: var(--text-dim); padding: 4px; }

/* ---------- main ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0 12px;
}
.msg { max-width: 760px; margin: 0 auto 18px; padding: 0 20px; display: flex; }
.msg .bubble { line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble {
  background: var(--bg-user);
  border-radius: 18px;
  padding: 10px 16px;
  max-width: 80%;
}
.msg.assistant .bubble { padding: 2px 0; max-width: 100%; }
.msg .bubble a { color: var(--accent); word-break: break-all; }
.msg .bubble code {
  background: var(--code-bg);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: Consolas, monospace;
  font-size: 13px;
}
.msg .bubble pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
}
.msg .bubble pre code { background: none; padding: 0; }
.msg .bubble .md-h { font-weight: 600; margin: 14px 0 4px; }
.msg .bubble .md-h:first-child { margin-top: 0; }
.msg .bubble ul, .msg .bubble ol { margin: 4px 0 10px; padding-left: 22px; }
.msg .bubble li { margin: 2px 0; }
.cursor { display: inline-block; width: 8px; height: 16px; background: var(--text); vertical-align: text-bottom; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- welcome ---------- */
#welcome { max-width: 760px; margin: 14vh auto 0; text-align: center; padding: 0 20px; }
#welcome h1 { font-size: 30px; margin-bottom: 8px; }
#welcome p { color: var(--text-dim); margin-bottom: 28px; }
.suggestions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.suggestion {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13.5px;
}
.suggestion:hover { border-color: var(--text-dim); }

#welcome .hint { color: var(--text-dim); font-size: 12.5px; margin-top: 22px; }

/* ---------- załączniki ---------- */
#attachments {
  max-width: 760px;
  margin: 0 auto 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
#attachments:empty { display: none; }
.att-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 12.5px;
  max-width: 220px;
}
.att-chip img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; }
.att-chip .att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-chip .att-x {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 13px;
}
.att-chip .att-x:hover { color: #e66; }
.att-chip.processing { opacity: 0.55; }

/* załączniki w wiadomościach */
.msg-atts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.msg-atts img { max-width: 220px; max-height: 160px; border-radius: 10px; display: block; }
.msg-atts .file-tag {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12.5px;
}

/* ---------- dropzone ---------- */
#dropzone {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(16, 163, 127, 0.12);
  border: 3px dashed var(--accent);
  z-index: 10;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--accent);
  pointer-events: none;
}
body.dragging #dropzone { display: flex; }

/* przycisk „na dół" (widoczny gdy odjedziesz w górę) */
#scroll-bottom {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  z-index: 5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
#scroll-bottom:hover { border-color: var(--text-dim); }

/* ---------- composer ---------- */
#main { position: relative; }
#composer { padding: 8px 20px 18px; }
#attach {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 19px;
  cursor: pointer;
  padding: 4px 10px 4px 0;
}
#attach:hover { color: var(--text); }
#mic {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 10px 4px 0;
  white-space: nowrap;
}
#mic:hover { color: var(--text); }
#mic.recording {
  color: #d9534f;
  font-size: 13.5px;
  font-weight: 600;
  animation: rec-pulse 1.2s infinite;
}
@keyframes rec-pulse { 50% { opacity: 0.55; } }

/* ---------- stopka sidebara: konto i motyw ---------- */
#sidebar footer { display: flex; flex-direction: column; gap: 8px; }
#user-row { display: flex; align-items: center; gap: 6px; }
#user-email { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#admin-link {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
}
#admin-link:hover { color: var(--text); border-color: var(--text-dim); }
#theme-toggle, #logout {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
}
#theme-toggle:hover, #logout:hover { color: var(--text); border-color: var(--text-dim); }

/* Numer wersji: informacja serwisowa, nie element interfejsu — ma dac sie
   odczytac, gdy ktos go szuka, i nie rzucac sie w oczy przez reszte czasu. */
#wersja-app {
  font-size: 10.5px;
  color: var(--text-dim);
  opacity: 0.55;
  letter-spacing: 0.2px;
  cursor: default;
  user-select: text; /* do przepisania w zgloszeniu bledu */
}
#wersja-app:hover { opacity: 1; }
.ag-head #wersja-app { margin-left: auto; }

/* ---------- strona logowania ---------- */
body.login-page { align-items: center; justify-content: center; }
#login-card {
  background: var(--bg-side);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 40px;
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#login-card h1 { font-size: 26px; text-align: center; }
#login-card .sub { color: var(--text-dim); text-align: center; font-size: 13px; margin-bottom: 10px; }
#login-card label { font-size: 13px; color: var(--text-dim); display: flex; flex-direction: column; gap: 6px; }
#login-card input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14.5px;
  padding: 10px 12px;
  outline: none;
}
#login-card input:focus { border-color: var(--accent); }
#login-btn {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 15px;
  padding: 11px;
  margin-top: 6px;
}
#login-btn:hover { filter: brightness(1.1); }
#login-error { color: #e66; font-size: 13px; min-height: 16px; text-align: center; }
#login-info { color: var(--accent); font-size: 13px; text-align: center; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; margin-top: 4px; }
.auth-links a { color: var(--text-dim); font-size: 12.5px; text-decoration: none; }
.auth-links a:hover { color: var(--text); }

/* harmonogram agenta */
#agent-sched {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#agent-sched legend { font-size: 12.5px; color: var(--text-dim); padding: 0 6px; }
.sched-row { flex-direction: row !important; align-items: center; gap: 6px; color: var(--text) !important; }
.sched-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.sched-grid label { flex: 1; min-width: 120px; }
#agent-sched select, #agent-sched input[type="time"] {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13.5px;
  padding: 8px 10px;
}
.sched-hint { color: var(--text-dim); font-size: 11.5px; }
#composer-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  background: var(--bg-input);
  border-radius: 24px;
  padding: 10px 10px 10px 20px;
}
#input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  resize: none;
  max-height: 200px;
  line-height: 1.5;
}
#send {
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  margin-left: 10px;
  cursor: pointer;
  font-size: 15px;
}
#send:disabled { opacity: 0.3; cursor: default; }
#send.stop { background: #d9534f; color: #fff; }
.loop-note { margin-top: 8px; font-size: 12.5px; color: #c99a2e; }
#composer-tools {
  max-width: 760px;
  margin: 8px auto 0;
  display: flex;
  gap: 8px;
}
#thinking-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12.5px;
  padding: 5px 12px;
  transition: all 0.15s;
}
#thinking-btn:hover { color: var(--text); border-color: var(--text-dim); }
#thinking-btn.active {
  background: rgba(16, 163, 127, 0.14);
  border-color: var(--accent);
  color: var(--accent);
}
#research-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12.5px;
  padding: 5px 12px;
  transition: all 0.15s;
}
#research-btn:hover { color: var(--text); border-color: var(--text-dim); }
#research-btn.active {
  background: rgba(66, 133, 244, 0.14);
  border-color: #4285f4;
  color: #4285f4;
}
#active-agent { color: var(--text-dim); font-size: 12px; align-self: center; }

/* status deep research w dymku */
.rsx-status {
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
  margin-bottom: 8px;
}

/* modal agenta */
#agent-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}
/* display:flex nadpisywałoby atrybut hidden — przywracamy jego działanie */
#agent-modal[hidden] { display: none; }
#agent-card {
  background: var(--bg-side);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 28px;
  width: 480px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#agent-card h2 { font-size: 19px; }
#agent-card label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-dim); }
#agent-card input[type="text"], #agent-card input:not([type]), #agent-card textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 9px 11px;
  outline: none;
}
#agent-card input:focus, #agent-card textarea:focus { border-color: var(--accent); }
#agent-card textarea { resize: vertical; }
.agent-row { display: flex; gap: 10px; }
.agent-icon-l { width: 74px; }
.agent-icon-l input { text-align: center; font-size: 19px; }
.agent-name-l { flex: 1; }
.agent-tools { display: flex; gap: 18px; font-size: 13px; }
.agent-tools label { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
.agent-actions { display: flex; gap: 10px; margin-top: 4px; }
.agent-actions button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  padding: 9px 16px;
}
.agent-actions .primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.agent-actions .danger { color: #d9534f; border-color: #d9534f; }

/* blok rozumowania w odpowiedzi */
details.thinking {
  background: var(--bg-input);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  margin-bottom: 10px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-dim);
}
details.thinking summary {
  cursor: pointer;
  user-select: none;
  font-size: 12.5px;
  /* sedno w jednej linii — pełny tok dopiero po rozwinięciu */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
details.thinking .think-gist { color: var(--text-dim); font-style: italic; }
details[open].thinking summary { white-space: normal; }
details.thinking > div { margin-top: 8px; white-space: pre-wrap; }

/* chipy narzędzi (function calling) */
.tool-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.tool-chip {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-family: Consolas, monospace;
  font-size: 11.5px;
  padding: 3px 10px;
}

/* panel walidacji domenowej */
.validation {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 10px;
  padding: 10px 14px;
  font-size: 13px;
}
.validation .v-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.v-row { padding: 2px 0; }
.v-row.ok { color: #18a06c; }
.v-row.warn { color: #c99a2e; }
.v-row.bad { color: #d9534f; }

/* ocena odpowiedzi */
.rate-wrap { margin-top: 8px; }
.rate-row { display: flex; gap: 4px; }
.rate-comment {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  max-width: 480px;
}
.rate-comment input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
}
.rate-comment input:focus { border-color: var(--accent); }
.rate-counter { color: var(--text-dim); font-size: 11px; white-space: nowrap; }
.rate-comment button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12.5px;
  padding: 6px 12px;
}
.rate-comment button:hover { color: var(--text); border-color: var(--text-dim); }
.rate-row button {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  padding: 3px 7px;
  opacity: 0.45;
  transition: all 0.15s;
}
.rate-row button:hover { opacity: 1; border-color: var(--border); }
.rate-row button.active {
  opacity: 1;
  background: rgba(16, 163, 127, 0.14);
  border-color: var(--accent);
}

/* ---------- kanwa dokumentów (panel boczny, plik canvas.js) ---------- */
#cnv-launcher {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 40;
  background: var(--bg-side);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12.5px;
  padding: 7px 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
#cnv-launcher:hover { color: var(--text); border-color: var(--text-dim); }
#cnv-launcher.cnv-active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(16, 163, 127, 0.14);
}

#cnv-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 440px;
  max-width: 96vw;
  height: 100vh;
  z-index: 39;
  background: var(--bg-side);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 18px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  gap: 12px;
}
#cnv-panel[hidden] { display: none; }
.cnv-head { display: flex; align-items: center; justify-content: space-between; }
.cnv-title { font-size: 15px; font-weight: 600; }
.cnv-x {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 15px; padding: 4px 8px;
}
.cnv-x:hover { color: #e66; }

.cnv-new { display: flex; gap: 8px; }
#cnv-kind {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13.5px;
  padding: 8px 10px;
}
.cnv-primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 13.5px;
  padding: 8px 14px;
}
.cnv-primary:hover { filter: brightness(1.08); }

.cnv-list {
  max-height: 26%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.cnv-empty { color: var(--text-dim); font-size: 12.5px; padding: 8px 4px; }
.cnv-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  padding: 8px 10px;
}
.cnv-item:hover { background: var(--bg-input); }
.cnv-item.cnv-sel { border-color: var(--accent); background: rgba(16, 163, 127, 0.10); }
.cnv-item-title { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cnv-item-sub { color: var(--text-dim); font-size: 11px; }

.cnv-editor { flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.cnv-doc-title {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14.5px;
  font-weight: 600;
  padding: 9px 11px;
  outline: none;
}
.cnv-doc-title:focus { border-color: var(--accent); }
.cnv-meta { color: var(--text-dim); font-size: 11.5px; }
.cnv-doc-content {
  flex: 1;
  min-height: 160px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: Consolas, "Segoe UI", monospace;
  font-size: 13.5px;
  line-height: 1.5;
  padding: 11px;
  resize: none;
  outline: none;
}
.cnv-doc-content:focus { border-color: var(--accent); }

.cnv-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cnv-actions button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 12.5px;
  padding: 7px 11px;
}
.cnv-actions button:hover { border-color: var(--text-dim); }
.cnv-actions .cnv-primary { color: #fff; border-color: var(--accent); }
.cnv-status { color: var(--accent); font-size: 12px; margin-left: auto; }

.cnv-versions { border-top: 1px solid var(--border); padding-top: 8px; }
.cnv-versions-head {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.cnv-versions-list { max-height: 130px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.cnv-ver {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  cursor: pointer;
  font-size: 12.5px;
  padding: 6px 10px;
  text-align: left;
}
.cnv-ver:hover { border-color: var(--accent); background: var(--bg-input); }

/* ==========================================================================
   RESPONSYWNOŚĆ
   Aplikacja powstała na desktop (sidebar 260 px + reszta). Na telefonie i
   tablecie panel boczny zjada ekran, więc poniżej 900 px staje się szufladą
   wysuwaną przyciskiem ☰ (obsługa w mobile.js).
   ========================================================================== */

/* 100vh na telefonie liczy się razem z paskiem przeglądarki i ucina composer;
   dvh mierzy realnie widoczną wysokość. Fallback zostaje dla starszych. */
/* przycisk otwierania szuflady — na desktopie niewidoczny */
#sidebar-toggle {
  display: none;
  position: fixed;
  top: 10px; left: 10px;
  z-index: 45;
  align-items: center; justify-content: center;
  width: 38px; height: 38px;
  background: var(--bg-side);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}
#sidebar-toggle:hover { border-color: var(--accent); }
body.sidebar-open #sidebar-toggle { left: auto; right: 10px; }

@supports (height: 100dvh) {
  body { height: 100dvh; }
}

@media (max-width: 900px) {
  /* sidebar jako szuflada nad treścią */
  /* Szuflada sterowana `left` (nie `transform`) — prostsza do zdiagnozowania,
     gdy cos pojdzie nie tak: pozycje widac wprost w inspektorze. */
  #sidebar {
    position: fixed;
    top: 0; bottom: 0;
    left: -280px;
    z-index: 40;
    transition: left 0.22s ease;
    box-shadow: 2px 0 18px rgba(0, 0, 0, 0.28);
  }
  body.sidebar-open #sidebar { left: 0; }

  /* przygaszenie treści, gdy szuflada otwarta — i klikalne zamknięcie */
  body.sidebar-open::after {
    content: "";
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 35;
  }

  #main { width: 100%; }
  #messages { padding: 16px 0 8px; }
  .msg { padding: 0 14px; margin-bottom: 14px; }
  .msg.user .bubble { max-width: 88%; }

  /* miejsce na przycisk ☰ */
  #messages, #composer { padding-top: 0; }
  #sidebar-toggle { display: flex; }

  #composer { padding: 0 10px 10px; }
  #composer-tools { flex-wrap: wrap; gap: 6px; }

  /* modale i panele modułów: pełna szerokość zamiast stałej */
  #agent-card, #memory-card, #pass-card, #canvas-card, #skills-card,
  #consilium-card, #scribe-card {
    width: 94vw !important;
    max-width: 94vw !important;
    max-height: 88dvh;
    padding: 18px 16px;
  }

  #hints-box, #lek-choices { margin: 0 10px 10px; }
  .lek-row { flex-direction: column; }
  .lek-opt { width: 100%; }
}

@media (max-width: 560px) {
  body { font-size: 14.5px; }
  #messages { padding: 10px 0 6px; }
  .msg { padding: 0 10px; }
  .msg.user .bubble { max-width: 94%; }
  #composer-inner { padding: 6px 8px; }
  #composer-tools button { font-size: 12px; padding: 5px 8px; }
  /* stopka sidebara: e-mail potrafi wypchnąć przyciski poza ekran */
  #user-row { flex-wrap: wrap; gap: 6px; }
  #user-email { flex-basis: 100%; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
}
