.chat-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #dbdbdb;
  z-index: 30;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
}

.chat-overlay {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  top: 3.25rem;
  height: calc(100dvh - 3.25rem);
  background: #fff;
  z-index: 40;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-overlay.is-hidden {
  display: none;
}

.chat-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #dbdbdb;
}

.chat-overlay-messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  background-color: #ededed; /* Bulma $white-ter (#f5f5f5) darkened */
}

.chat-overlay-input {
  border-top: 1px solid #dbdbdb;
  padding: 0.75rem 0 calc(0.75rem + env(safe-area-inset-bottom, 0px));
  width: 100%;
  overflow: hidden;
}

.chat-message {
  padding: 0.5rem 0.75rem;
  max-width: 75%;
  word-wrap: break-word;
  font-size: 0.9rem;
  line-height: 1.45;
  position: relative;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chat-message--user {
  background-color: #00d1b2;
  color: #fff;
  align-self: flex-end;
  border-radius: 1.125rem 1.125rem 0.25rem 1.125rem;
}

.chat-message--assistant {
  background-color: #fff;
  color: #363636;
  align-self: flex-start;
  border-radius: 1.125rem 1.125rem 1.125rem 0.25rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.chat-message--assistant a {
  color: #00d1b2;
  text-decoration: underline;
}

.chat-message--assistant a:hover {
  color: #00c4a7;
}

.chat-link-icon {
  font-size: 0.75em;
  margin-left: 0.25em;
  opacity: 0.6;
  vertical-align: baseline;
}

.chat-message--assistant p {
  margin: 0 0 0.4rem 0;
}

.chat-message--assistant p:last-child {
  margin-bottom: 0;
}

.chat-message--assistant ul,
.chat-message--assistant ol {
  margin: 0.25rem 0;
  padding-left: 1.25rem;
}

.chat-message--assistant strong {
  font-weight: 600;
}

.chat-message--assistant code {
  background-color: #f0f0f0;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.85em;
}

.chat-overlay-input input.input {
  font-size: 16px; /* prevents iOS zoom on focus */
}

.chat-bar-field {
  margin-bottom: 0;
}

.chat-bar-placeholder {
  color: #b5b5b5;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
}

.chat-bar-placeholder:focus,
.chat-bar-placeholder:active {
  border-color: #dbdbdb;
  box-shadow: none;
}

.chat-typing-indicator {
  display: flex;
  gap: 4px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  background-color: #f5f5f5;
  border-radius: 0.75rem;
  width: fit-content;
}

.chat-typing-indicator span {
  width: 8px;
  height: 8px;
  background-color: #b5b5b5;
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

.chat-typing-indicator span:nth-child(1) { animation-delay: 0s; }
.chat-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

body.has-chat-bar {
  padding-bottom: 4rem;
}

.chat-tool-results {
  margin-top: 0.4rem;
  padding-top: 0.35rem;
  border-top: 1px solid #eee;
  font-size: 0.75rem;
  color: #888;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chat-tool-result {
  display: inline-flex;
  align-items: center;
  font-size: 0.85rem;
}

.chat-tool-result.is-success {
  color: #48c774;
}

.chat-tool-result.is-failure {
  color: #f14668;
}

.chat-tool-count {
  margin-left: 0.15rem;
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.8;
}
