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

:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --line: #d7dbe1;
  --text: #1f2937;
  --muted: #667085;
  --brand-violet: #342b8c;
  --brand-blue: #0c78bf;
  --radius: 12px;
  --font-ui: "Manrope", "Segoe UI", sans-serif;
  --mono: "SF Mono", "Fira Code", Consolas, monospace;
}

html,
body {
  height: 100%;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

.portal-header {
  height: 78px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 184px;
  height: 54px;
  object-fit: contain;
  object-position: left center;
  flex-shrink: 0;
}

.brand-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.workspace {
  flex: 1;
  width: 100%;
  min-height: 0;
  padding: 12px 14px 6px;
}

#main {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 78px - 132px);
  min-height: 0;
  max-width: none;
  width: 100%;
  margin: 0;
}

#chat-messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.welcome-screen {
  width: min(760px, 100%);
  margin: auto;
  text-align: center;
}

.welcome-screen h2 {
  font-size: 34px;
  letter-spacing: -0.02em;
}

.welcome-screen p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.35;
}

.suggested-questions {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.suggestion {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
}

.suggestion:hover {
  border-color: #a2b5d0;
  background: #f8fbff;
}

.suggestion-kicker {
  display: none;
}

.msg-row {
  display: flex;
  gap: 9px;
  max-width: min(860px, 92%);
}

.msg-row.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 3px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-violet), var(--brand-blue));
}

.msg-row.user .msg-avatar {
  background: #4b5563;
}

.msg-bubble {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
  line-height: 1.5;
  color: var(--text);
}

.msg-row.user .msg-bubble {
  background: linear-gradient(135deg, var(--brand-violet), var(--brand-blue));
  border-color: transparent;
  color: #fff;
}

.msg-bubble p {
  margin: 0 0 0.4em;
}

.msg-bubble p:last-child {
  margin-bottom: 0;
}

.msg-bubble ul,
.msg-bubble ol {
  padding-left: 1.35em;
  margin: 0.25em 0;
}

.msg-bubble li {
  margin: 0.12em 0;
}

.msg-bubble code {
  font-family: var(--mono);
  background: rgba(31, 41, 55, 0.08);
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 0.88em;
}

.msg-row.user .msg-bubble code {
  background: rgba(255, 255, 255, 0.2);
}

.msg-bubble pre {
  margin: 0.45em 0;
  border-radius: 8px;
  padding: 8px;
  background: #f6f8fb;
  overflow: auto;
}

.msg-bubble pre code {
  background: transparent;
  padding: 0;
}

.typing-indicator {
  display: inline-flex;
  gap: 4px;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #7e8a99;
  animation: blink 0.95s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.3s;
}

#input-area {
  border-top: 1px solid var(--line);
  background: #fafbfc;
  padding: 10px 12px 8px;
}

#input-wrapper {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px;
}

#input-wrapper:focus-within {
  border-color: #9cb1cf;
}

#user-input {
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  flex: 1;
  max-height: 160px;
  padding: 4px 6px;
}

#send-btn {
  border: none;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--brand-violet), var(--brand-blue));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.input-hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.site-footer {
  margin-top: 0;
  border-top: 1px solid var(--line);
  background: #eef0f3;
  padding: 10px 14px 8px;
  text-align: center;
}

.footer-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}

.funding-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 620px;
  margin: 0 auto;
  align-items: center;
}

.funding-logo {
  width: auto;
  height: 34px;
  max-width: 185px;
  object-fit: contain;
  display: block;
}

.footer-copy {
  margin-top: 10px;
  font-size: 12px;
  color: #6c7685;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.librairy-logo {
  height: 14px;
  width: auto;
  vertical-align: middle;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #c8ced8;
}

::-webkit-scrollbar-thumb:hover {
  background: #b3bbc8;
}

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

@media (max-width: 920px) {
  .portal-header {
    height: auto;
    padding: 10px 12px;
  }

  .brand-logo {
    width: 136px;
    height: 40px;
  }

  .brand-title {
    font-size: 18px;
  }

  .brand-subtitle {
    font-size: 12px;
  }

  .workspace {
    padding: 10px;
  }

  #main {
    height: calc(100vh - 84px - 150px);
  }

  .welcome-screen h2 {
    font-size: 28px;
  }

  .welcome-screen p {
    font-size: 15px;
  }

  .funding-grid {
    max-width: 320px;
    gap: 8px;
  }

  .funding-logo {
    height: 28px;
    max-width: 160px;
  }

  .footer-copy {
    flex-wrap: wrap;
  }

  .funding-logo {
    max-height: 64px;
  }
}
