:root {
  --bg: #0b1020;
  --bg-soft: #11172e;
  --panel: #151c34;
  --panel-2: #1b2340;
  --border: #273156;
  --text: #e8ecf8;
  --muted: #9aa6c9;
  --accent: #6d8bff;
  --accent-2: #9b6dff;
  --user: #2a3566;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(155, 109, 255, 0.18), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(109, 139, 255, 0.18), transparent 55%),
    var(--bg);
  display: flex;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 860px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 16px;
}

.app__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 8px 16px;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand__logo {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-size: 20px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px rgba(109, 139, 255, 0.4);
}

.brand__text h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.2px; }
.brand__text p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

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

.header__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gitlab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: #fff;
  background: #fc6d26;
  border: 1px solid #e24329;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.gitlab-btn:hover {
  background: #e24329;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(252, 109, 38, 0.35);
}
.gitlab-btn.connected {
  background: rgba(69, 209, 143, 0.15);
  border-color: rgba(69, 209, 143, 0.45);
  color: #7ee8b8;
}
.gitlab-btn.connected:hover {
  background: rgba(69, 209, 143, 0.22);
  box-shadow: none;
  transform: none;
}
.gitlab-btn__icon { flex-shrink: 0; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}

.welcome {
  margin: auto;
  text-align: center;
  max-width: 560px;
  padding: 24px;
}
.welcome__icon {
  font-size: 34px;
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(109,139,255,0.25), rgba(155,109,255,0.25));
  border: 1px solid var(--border);
}
.welcome h2 { margin: 0 0 8px; font-size: 24px; letter-spacing: -0.3px; }
.welcome p { margin: 0 0 22px; color: var(--muted); line-height: 1.6; }

.suggestions { display: flex; flex-direction: column; gap: 10px; }
.chip {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip:hover { border-color: var(--accent); transform: translateY(-1px); }

.msg { display: flex; gap: 12px; align-items: flex-start; animation: rise 0.25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.msg__avatar {
  flex: 0 0 32px;
  width: 32px; height: 32px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700;
}
.msg--user { flex-direction: row-reverse; }
.msg--user .msg__avatar { background: var(--user); color: #cfd8ff; }
.msg--bot .msg__avatar { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }

.bubble {
  max-width: 80%;
  padding: 13px 16px;
  border-radius: 14px;
  line-height: 1.65;
  font-size: 15px;
  border: 1px solid var(--border);
}
.msg--user .bubble { background: var(--user); border-color: #354079; border-bottom-right-radius: 4px; }
.msg--bot .bubble { background: var(--panel); border-bottom-left-radius: 4px; }

.bubble p:first-child { margin-top: 0; }
.bubble p:last-child { margin-bottom: 0; }
.bubble pre {
  background: #0c1226;
  border: 1px solid var(--border);
  padding: 12px; border-radius: 10px; overflow-x: auto; font-size: 13px;
}
.bubble code { background: rgba(255,255,255,0.07); padding: 2px 6px; border-radius: 6px; font-size: 0.9em; }
.bubble pre code { background: none; padding: 0; }
.bubble a { color: var(--accent); }
.bubble ul, .bubble ol { padding-left: 20px; }
.bubble h1, .bubble h2, .bubble h3 { margin: 14px 0 6px; line-height: 1.3; }

.tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.tool-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 6px 11px; border-radius: 999px;
}
.tool-chip .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(109,139,255,0.6);
  animation: pulse 1.3s infinite;
}
.tool-chip.done .dot { background: #45d18f; animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(109,139,255,0.55); }
  70% { box-shadow: 0 0 0 7px rgba(109,139,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(109,139,255,0); }
}

.typing { display: inline-flex; gap: 5px; padding: 4px 2px; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: blink 1.2s infinite both;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.error-text { color: #ff8b8b; }

.composer { padding: 8px 8px 18px; }
.composer__form {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 10px 10px 16px;
  box-shadow: var(--shadow);
}
.composer__form:focus-within { border-color: var(--accent); }
#input {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
  max-height: 180px;
  padding: 6px 0;
}
#input::placeholder { color: var(--muted); }

.send-btn {
  flex: 0 0 40px;
  width: 40px; height: 40px;
  border: none; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; cursor: pointer;
  display: grid; place-items: center;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.send-btn:hover { transform: translateY(-1px); }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.composer__hint { text-align: center; color: var(--muted); font-size: 12px; margin: 10px 0 0; }

@media (max-width: 600px) {
  .bubble { max-width: 88%; }
  .brand__text p { display: none; }
  #gitlab-login-label { display: none; }
  .gitlab-btn { padding: 8px 10px; }
}
