:root {
  --ciw-brand: #29abe2;
}

/* Keep the chat narrow and readable */

#chat-form {
  max-width: 820px;
  margin: 0 auto;
}

/* Scrollable chat area */

#Chat {
  padding: 8px 0;
  max-height: 60vh;
  overflow-y: auto;
  background: #fff;
}

/* Message bubbles */

#Chat .ciw-msg {
  border-radius: 16px;
  padding: 14px 16px;
  margin: 12px 0;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

#Chat .ciw-msg.user {
  background: #f6f7f9;
}

#Chat .ciw-msg.ai {
  background: #ffffff;
  border: 1px solid #e8edf2;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

/* Typography inside messages */

#Chat .ciw-msg h1, #Chat .ciw-msg h2, #Chat .ciw-msg h3 {
  margin: 1.2em 0 .6em;
  line-height: 1.25;
}

#Chat .ciw-msg h1 {
  font-size: 1.4rem;
}

#Chat .ciw-msg h2 {
  font-size: 1.2rem;
}

#Chat .ciw-msg h3 {
  font-size: 1.05rem;
}

#Chat .ciw-msg p {
  margin: .6em 0;
}

#Chat .ciw-msg ul, #Chat .ciw-msg ol {
  padding-left: 1.2em;
  margin: .6em 0;
}

#Chat .ciw-msg li + li {
  margin-top: .25em;
}

/* Code & tables */

#Chat .ciw-msg code {
  background: #f5f7fa;
  padding: .15em .35em;
  border-radius: 6px;
  font-family: ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
}

#Chat .ciw-msg pre {
  background: #0b1220;
  color: #f0f3f8;
  padding: 14px;
  border-radius: 12px;
  overflow: auto;
}

#Chat .ciw-msg pre code {
  background: transparent;
  padding: 0;
}

#Chat .ciw-msg table {
  width: 100%;
  border-collapse: collapse;
  margin: .8em 0;
}

#Chat .ciw-msg th, #Chat .ciw-msg td {
  border: 1px solid #e6ebf0;
  padding: 8px 10px;
}

#Chat .ciw-msg th {
  background: #f8fafc;
  text-align: left;
}

/* Optional callouts */

#Chat .ciw-callout {
  border-left: 4px solid var(--ciw-brand);
  background: #f3fbff;
  padding: 12px 14px;
  border-radius: 8px;
}

/* Brand links */

#Chat .ciw-msg a {
  color: var(--ciw-brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* container & scrolling */

#chat-form {
  max-width: 820px;
  margin: 0 auto;
}

#Chat {
  padding: 8px 0;
  max-height: 60vh;
  overflow-y: auto;
  background: #fff;
}

/* bubbles */

#Chat .ciw-msg {
  border-radius: 16px;
  padding: 14px 16px;
  margin: 12px 0;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

#Chat .ciw-msg.user {
  background: #f6f7f9;
}

#Chat .ciw-msg.ai {
  background: #fff;
  border: 1px solid #e8edf2;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

/* rich text */

#Chat .ciw-msg h1, #Chat .ciw-msg h2, #Chat .ciw-msg h3 {
  margin: 1.2em 0 .6em;
  line-height: 1.25;
}

#Chat .ciw-msg h1 {
  font-size: 1.4rem;
}

#Chat .ciw-msg h2 {
  font-size: 1.2rem;
}

#Chat .ciw-msg h3 {
  font-size: 1.05rem;
}

#Chat .ciw-msg p {
  margin: .6em 0;
}

#Chat .ciw-msg ul, #Chat .ciw-msg ol {
  padding-left: 1.2em;
  margin: .6em 0;
}

#Chat .ciw-msg li + li {
  margin-top: .25em;
}

#Chat .ciw-msg code {
  background: #f5f7fa;
  padding: .15em .35em;
  border-radius: 6px;
  font-family: ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
}

#Chat .ciw-msg pre {
  background: #0b1220;
  color: #f0f3f8;
  padding: 14px;
  border-radius: 12px;
  overflow: auto;
}

#Chat .ciw-msg pre code {
  background: transparent;
  padding: 0;
}

#Chat .ciw-msg table {
  width: 100%;
  border-collapse: collapse;
  margin: .8em 0;
}

#Chat .ciw-msg th, #Chat .ciw-msg td {
  border: 1px solid #e6ebf0;
  padding: 8px 10px;
}

#Chat .ciw-msg th {
  background: #f8fafc;
  text-align: left;
}

/* Typing indicator bubble */

#Chat .ciw-msg.ai.typing {
  display: flex;
  align-items: center;
  gap: 10px;
}

#Chat .typing .dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#Chat .typing .dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9aa6b2;
  opacity: .7;
  display: inline-block;
  animation: ciw-bounce 1.2s infinite ease-in-out both;
}

#Chat .typing .dots span:nth-child(2) {
  animation-delay: .15s;
}

#Chat .typing .dots span:nth-child(3) {
  animation-delay: .30s;
}

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

