:root {
  --bg: #0f1117;
  --bg-elevated: #171a23;
  --bg-input: #1e212b;
  --border: #2a2e3a;
  --text: #e8e9ed;
  --text-dim: #8b8fa3;
  --accent: #7c5cff;
  --accent-hover: #8f72ff;
  --user-bubble: #7c5cff;
  --assistant-bubble: #1e212b;
  --danger: #ff5c7a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.screen { height: 100vh; }
.hidden { display: none !important; }

/* ---------- Logowanie ---------- */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #1a1d2a 0%, #0f1117 60%);
}

.login-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.login-box h1 { margin: 0 0 8px; font-size: 24px; }
.subtitle { color: var(--text-dim); margin: 0 0 24px; font-size: 14px; }

#login-form { display: flex; flex-direction: column; gap: 12px; }

#password-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 15px;
  outline: none;
}
#password-input:focus { border-color: var(--accent); }

#login-form button {
  background: var(--accent);
  border: none;
  border-radius: 10px;
  padding: 14px;
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
#login-form button:hover { background: var(--accent-hover); }

.error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 16px; }

/* ---------- Panel czatu ---------- */
#chat-screen {
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.brand { font-weight: 700; font-size: 16px; }
.actions { display: flex; gap: 10px; }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--text); }

.ai-toggle {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.ai-toggle.off {
  background: var(--accent);
  color: white;
}
.ai-toggle.off:hover { background: var(--accent-hover); }
.ai-toggle.on {
  background: #23321f;
  color: #7be08a;
  border: 1px solid #3a5a34;
}
.ai-toggle.on:hover { background: #2b3d26; }
.ai-toggle.loading {
  background: var(--bg-input);
  color: var(--text-dim);
  cursor: wait;
}
.ai-toggle:disabled { opacity: 0.6; cursor: not-allowed; }

.ai-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.ai-toggle.on .ai-status-dot { background: #7be08a; box-shadow: 0 0 6px #7be08a; }
.ai-toggle.off .ai-status-dot { background: #ffffffaa; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.msg {
  display: flex;
  gap: 10px;
  max-width: 80%;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.assistant { align-self: flex-start; }

.bubble {
  padding: 12px 16px;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 14.5px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg.user .bubble {
  background: var(--user-bubble);
  color: white;
  border-bottom-right-radius: 4px;
}

.msg.assistant .bubble {
  background: var(--assistant-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg.assistant .bubble code {
  background: #00000055;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Cascadia Code', Consolas, monospace;
  font-size: 13px;
}

.chat-input-bar {
  display: flex;
  gap: 10px;
  padding: 16px 24px 24px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

#chat-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 14.5px;
  font-family: inherit;
  resize: none;
  max-height: 160px;
  outline: none;
}
#chat-input:focus { border-color: var(--accent); }

#send-btn {
  background: var(--accent);
  border: none;
  border-radius: 12px;
  padding: 0 24px;
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
#send-btn:hover { background: var(--accent-hover); }
#send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* scrollbar */
.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
