.crii-max-chat-widget {
  position: fixed;
  right: clamp(1rem, 2vw, 1.5rem);
  bottom: clamp(1rem, 2vw, 1.5rem);
  z-index: 1200;
}

.crii-max-chat-launcher {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  border: 1px solid rgba(17, 121, 250, 0.45);
  border-radius: 999px;
  padding: 0.9rem 1.1rem;
  background: linear-gradient(135deg, #63cfe0 0%, #1179fa 100%);
  color: #06121f;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 20px 50px rgba(6, 18, 31, 0.22);
}

.crii-max-chat-launcher__icon {
  width: 0.9rem;
  height: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #06121f;
}

.crii-max-chat-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 1rem);
  width: min(26rem, calc(100vw - 2rem));
  max-height: min(80vh, 46rem);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 1rem;
  padding: 1.2rem;
  border: 1px solid rgba(12, 29, 49, 0.08);
  border-radius: 1.5rem;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 28px 60px rgba(6, 18, 31, 0.22);
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.75rem);
  pointer-events: none;
}

.crii-max-chat-widget.is-open .crii-max-chat-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.crii-max-chat__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.crii-max-chat__eyebrow,
.crii-max-chat__contact-eyebrow {
  margin: 0 0 0.35rem;
  color: #1179fa;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
}

.crii-max-chat__title {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.05;
}

.crii-max-chat__subtitle {
  margin: 0.45rem 0 0;
  color: rgba(6, 18, 31, 0.72);
  font-size: 0.95rem;
  line-height: 1.55;
}

.crii-max-chat__close,
.crii-max-chat__contact-close {
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 999px;
  background: rgba(6, 18, 31, 0.06);
  color: #06121f;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.crii-max-chat__messages {
  min-height: 16rem;
  max-height: 24rem;
  overflow-y: auto;
  display: grid;
  gap: 0.8rem;
  padding-right: 0.2rem;
  align-content: start;
}

.crii-max-chat__empty {
  padding: 1rem 1.1rem;
  border-radius: 1.1rem;
  background: rgba(17, 121, 250, 0.08);
  color: rgba(6, 18, 31, 0.72);
  line-height: 1.6;
}

.crii-max-chat__message {
  width: fit-content;
  max-width: min(76%, 15rem);
  padding: 0.8rem 0.95rem 0.7rem;
  border-radius: 1rem;
  line-height: 1.45;
  word-break: break-word;
  white-space: normal;
  align-self: start;
  box-shadow: 0 10px 26px rgba(6, 18, 31, 0.08);
  border: 1px solid rgba(6, 18, 31, 0.06);
}

.crii-max-chat__message--user {
  margin-left: 0;
  justify-self: end;
  background: linear-gradient(135deg, #63cfe0 0%, #8be1ef 100%);
  color: #06121f;
  border-color: rgba(17, 121, 250, 0.12);
}

.crii-max-chat__message--operator {
  margin-right: 0;
  justify-self: start;
  background: rgba(6, 18, 31, 0.06);
  color: #06121f;
}

.crii-max-chat__message--system {
  margin-right: 0;
  justify-self: start;
  background: rgba(17, 121, 250, 0.08);
  color: rgba(6, 18, 31, 0.76);
}

.crii-max-chat__message-time {
  display: block;
  margin-top: 0.38rem;
  color: rgba(6, 18, 31, 0.5);
  font-size: 0.72rem;
}

.crii-max-chat__composer {
  display: grid;
  gap: 0.75rem;
}

.crii-max-chat__composer textarea,
.crii-max-chat__contact-form input {
  width: 100%;
  border: 1px solid rgba(12, 29, 49, 0.14);
  border-radius: 1rem;
  padding: 0.9rem 1rem;
  background: #fff;
  color: #06121f;
  font: inherit;
}

.crii-max-chat__composer textarea {
  resize: vertical;
  min-height: 6rem;
}

.crii-max-chat__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.crii-max-chat__hint,
.crii-max-chat__contact-note,
.crii-max-chat__status {
  margin: 0;
  color: rgba(6, 18, 31, 0.64);
  font-size: 0.82rem;
  line-height: 1.55;
}

.crii-max-chat__status {
  padding: 0.75rem 0.9rem;
  border-radius: 1rem;
  background: rgba(17, 121, 250, 0.08);
}

.crii-max-chat__contact-prompt {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  border-radius: 1.5rem;
  background: rgba(6, 18, 31, 0.26);
  backdrop-filter: blur(4px);
}

.crii-max-chat__contact-prompt[hidden],
.crii-max-chat__status[hidden] {
  display: none !important;
}

.crii-max-chat__contact-card {
  width: 100%;
  padding: 1.1rem;
  border-radius: 1.35rem;
  background: #fff;
  box-shadow: 0 24px 50px rgba(6, 18, 31, 0.18);
}

.crii-max-chat__contact-card h3 {
  margin: 0.2rem 0 0.5rem;
  font-size: 1.25rem;
  line-height: 1.15;
}

.crii-max-chat__contact-card p {
  margin: 0 0 0.85rem;
  color: rgba(6, 18, 31, 0.76);
  line-height: 1.6;
}

.crii-max-chat__contact-form {
  display: grid;
  gap: 0.7rem;
}

.crii-max-chat__contact-note a {
  color: #0d5ec4;
  text-decoration: underline;
}

@media (max-width: 720px) {
  .crii-max-chat-widget {
    right: 0.85rem;
    left: 0.85rem;
    bottom: 0.85rem;
  }

  .crii-max-chat-launcher {
    width: 100%;
    justify-content: center;
  }

  .crii-max-chat-panel {
    width: 100%;
    right: 0;
    left: 0;
    bottom: calc(100% + 0.75rem);
    max-height: 78vh;
  }

  .crii-max-chat__actions {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Compact launcher: keeps the chat available without covering page content. */
.crii-max-chat-launcher {
  min-height: 48px;
  padding: 0.72rem 0.9rem;
  gap: 0.5rem;
  font-size: 0.9rem;
  box-shadow: 0 12px 32px rgba(6, 18, 31, 0.2);
}

@media (max-width: 1280px) {
  .crii-max-chat-widget {
    right: 1rem;
    left: auto;
    bottom: 1rem;
  }

  .crii-max-chat-launcher {
    width: 48px;
    height: 48px;
    padding: 0;
    justify-content: center;
  }

  .crii-max-chat-launcher__label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .crii-max-chat-launcher__icon {
    width: 1rem;
    height: 1rem;
  }
}

@media (max-width: 720px) {
  .crii-max-chat-widget {
    right: 0.75rem;
    left: auto;
    bottom: 0.75rem;
  }

  .crii-max-chat-panel {
    right: 0;
    left: auto;
    width: min(26rem, calc(100vw - 1.5rem));
  }
}
