@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,700&family=DM+Mono:wght@400;500&display=swap');

/* ── Reset & root ── */
#contextus-widget *,
#contextus-widget *::before,
#contextus-widget *::after {
  box-sizing: border-box;
}

/* ── Expanded state: full-height chain (activated by JS on first message) ── */
html.ctx-expanded body {
  overflow: hidden;
}

html.ctx-expanded #contextus-root {
  height: 100%;
}

html.ctx-expanded #contextus-widget {
  height: 100%;
}

html.ctx-expanded .ctx-messages-wrap {
  display: block;
  flex: 1;
  min-height: 0;
}

html.ctx-expanded .ctx-input-area {
  padding-top: 10px;
  border-top: 0.5px solid #e0e0e0;
}

#contextus-widget {
  color-scheme: light;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  line-height: 1.7;
  color: #222222;
  background: #ffffff;
  -webkit-font-smoothing: antialiased;
  width: 100%;
  max-width: 600px;
  border: 0.5px solid #e0e0e0;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.ctx-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 0.5px solid #e0e0e0;
  background: #ffffff;
  flex-shrink: 0;
}

.ctx-header-name {
  font-size: 13px;
  font-weight: 500;
  color: #000000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.ctx-header-powered {
  margin-left: auto;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: #bbbbbb;
}

/* ── Message area wrapper ── */
.ctx-messages-wrap {
  display: none;
  /* hidden in idle phase — shown via html.ctx-expanded */
  position: relative;
}

/* ── Message area ── */
.ctx-messages {
  height: 100%;
  padding: 14px;
  background: #ffffff;
  overflow-y: auto;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #dddddd transparent;
}

/* ── Scroll-to-bottom FAB ── */
.ctx-scroll-fab {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #000000;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.ctx-messages::-webkit-scrollbar {
  width: 3px;
}

.ctx-messages::-webkit-scrollbar-thumb {
  background: #dddddd;
  border-radius: 3px;
}

.ctx-messages::-webkit-scrollbar-track {
  background: transparent;
}

/* ── Message rows ── */
.ctx-msg {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.ctx-msg.ctx-msg-visitor {
  justify-content: flex-end;
}

.ctx-avatar {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: block;
}

.ctx-bubble {
  max-width: 80%;
  font-size: 13px;
  line-height: 1.55;
  color: #222222;
}

.ctx-bubble-agent {
  padding: 2px 0;
}

.ctx-bubble-visitor {
  background: #111111;
  color: #ffffff;
  padding: 8px 13px;
  border-radius: 12px;
  border-bottom-right-radius: 3px;
}

/* ── Typing dots ── */
.ctx-dots {
  display: flex;
  gap: 3px;
  padding: 6px 0;
}

.ctx-dots span {
  width: 5px;
  height: 5px;
  background: #bbbbbb;
  border-radius: 50%;
  animation: ctx-dot-pulse 1.2s infinite;
}

.ctx-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.ctx-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes ctx-dot-pulse {

  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: scale(0.85);
  }

  30% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ── System banners ── */
.ctx-banner-error {
  font-size: 12px;
  color: #a32d2d;
  background: #fcebeb;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
}

.ctx-banner-boundary {
  font-size: 12px;
  color: #854f0b;
  background: #faeeda;
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 6px;
  margin-bottom: 10px;
}

.ctx-banner-complete {
  text-align: center;
  font-size: 12px;
  color: #888888;
  background: #fafafa;
  border-radius: 8px;
  padding: 10px;
  margin-top: 12px;
  margin-bottom: 10px;
}

.ctx-banner-complete span {
  color: #0f6e56;
  font-weight: 500;
}

/* ── Idle nudge ── */
.ctx-nudge {
  font-size: 12px;
  color: #888888;
  font-style: italic;
  margin-top: 8px;
  margin-bottom: 10px;
}

/* ── Returning visitor label ── */
.ctx-returning-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #888888;
  padding: 8px 14px;
  background: #fafafa;
  border-top: 0.5px solid #e0e0e0;
  border-bottom: 0.5px solid #e0e0e0;
  margin-bottom: 10px;
}

.ctx-returning-history {
  opacity: 0.55;
}

/* ── Input area ── */
.ctx-input-area {
  padding: 14px;
  background: #ffffff;
  flex-shrink: 0;
}

.ctx-input-area.ctx-input-area-padtop {
  padding-top: 10px;
  border-top: 0.5px solid #e0e0e0;
}

.ctx-input-wrapper {
  background: #f0f0f0;
  border: 0.5px solid #e0e0e0;
  border-radius: 16px;
  padding: 12px 12px 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ctx-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 15px;
  font-family: 'DM Sans', sans-serif;
  color: #000000;
  outline: none;
  min-width: 0;
}

.ctx-input::placeholder {
  color: #bbbbbb;
}

.ctx-input:disabled::placeholder {
  color: #cccccc;
}

/* ── Pills ── */
.ctx-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.ctx-pill {
  font-size: 11px;
  color: #666666;
  padding: 5px 11px;
  border: 0.5px solid #e0e0e0;
  border-radius: 14px;
  background: #ffffff;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.12s, color 0.12s;
  text-align: left;
}

.ctx-pill:hover {
  background: #f0f0f0;
  color: #000000;
}

/* ── Send button ── */
.ctx-send {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s;
}

.ctx-send svg {
  width: 16px;
  height: 16px;
  display: block;
}

/* EMPTY state */
.ctx-send.ctx-send-empty {
  background: #e0e0e0;
  cursor: default;
}

.ctx-send.ctx-send-empty svg {
  fill: #999999;
}

/* ACTIVE state */
.ctx-send.ctx-send-active {
  background: #000000;
  cursor: pointer;
}

.ctx-send.ctx-send-active svg {
  fill: #ffffff;
}

/* DISABLED state */
.ctx-send.ctx-send-disabled {
  background: #e0e0e0;
  cursor: not-allowed;
}

.ctx-send.ctx-send-disabled svg {
  fill: #bbbbbb;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .ctx-input {
    font-size: 16px;
    /* prevents iOS auto-zoom */
  }

  #contextus-widget {
    border-radius: 0;
    max-width: 100%;
  }
}

/* ── Markdown rendering in agent bubbles ── */
.ctx-bubble-agent p {
  margin: 0 0 0.5em 0;
}

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

.ctx-bubble-agent ol,
.ctx-bubble-agent ul {
  margin: 0.25em 0 0.5em 0;
  padding-left: 1.25em;
}

.ctx-bubble-agent ol:last-child,
.ctx-bubble-agent ul:last-child {
  margin-bottom: 0;
}

.ctx-bubble-agent li {
  margin-bottom: 0.25em;
  line-height: 1.45;
}

.ctx-bubble-agent li:last-child {
  margin-bottom: 0;
}

.ctx-bubble-agent strong {
  font-weight: 600;
}

.ctx-bubble-agent em {
  font-style: italic;
}