.omj-ai-chat {
  --omj-ai-navy: #08111d;
  --omj-ai-navy-soft: #132236;
  --omj-ai-gold: #d4a64f;
  --omj-ai-ivory: #fffaf0;
  --omj-ai-border: #d8dde6;
  --omj-ai-muted: #5f6f85;
  --omj-ai-danger: #b42318;
  position: fixed;
  right: max(18px, env(safe-area-inset-right, 0px));
  bottom: max(18px, env(safe-area-inset-bottom, 0px));
  z-index: 10001;
  font-family: inherit;
}

.omj-ai-chat * {
  box-sizing: border-box;
}

.omj-ai-chat__launcher {
  min-height: 48px;
  max-width: calc(100vw - 32px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  border: 1px solid rgba(212, 166, 79, 0.72);
  border-radius: 999px;
  padding: 0 1rem;
  background: var(--omj-ai-navy);
  color: #ffffff;
  box-shadow: 0 18px 42px rgba(8, 17, 29, 0.28);
  cursor: pointer;
  font-weight: 800;
  font-size: 0.92rem;
}

.omj-ai-chat__launcher-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--omj-ai-gold);
  color: var(--omj-ai-navy);
  font-size: 0.75rem;
  letter-spacing: 0;
}

.omj-ai-chat__launcher:focus-visible,
.omj-ai-chat button:focus-visible,
.omj-ai-chat textarea:focus-visible,
.omj-ai-chat input:focus-visible {
  outline: 3px solid rgba(212, 166, 79, 0.88);
  outline-offset: 3px;
}

.omj-ai-chat__panel {
  position: absolute;
  right: 0;
  bottom: 64px;
  width: min(390px, calc(100vw - 32px));
  height: min(660px, calc(100vh - 110px));
  min-height: 520px;
  display: none;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid rgba(8, 17, 29, 0.16);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 22px 70px rgba(8, 17, 29, 0.25);
}

.omj-ai-chat.is-open .omj-ai-chat__panel {
  display: grid;
}

.omj-ai-chat.is-open .omj-ai-chat__launcher {
  display: none;
}

.omj-ai-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0.9rem;
  background: linear-gradient(135deg, var(--omj-ai-navy), var(--omj-ai-navy-soft));
  color: #ffffff;
}

.omj-ai-chat__identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.omj-ai-chat__brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(212, 166, 79, 0.78);
  border-radius: 8px;
  color: var(--omj-ai-gold);
  font-size: 0.78rem;
  font-weight: 900;
}

.omj-ai-chat__title {
  display: block;
  overflow: hidden;
  color: #ffffff;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.98rem;
  font-weight: 900;
}

.omj-ai-chat__subtitle {
  display: block;
  margin-top: 0.12rem;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.78rem;
}

.omj-ai-chat__actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.omj-ai-chat__icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

.omj-ai-chat__body {
  min-height: 0;
  overflow-y: auto;
  padding: 0.9rem;
  background:
    linear-gradient(180deg, rgba(255, 250, 240, 0.74), rgba(255, 255, 255, 0.92)),
    #ffffff;
}

.omj-ai-chat__notice {
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.7rem;
  border: 1px solid rgba(212, 166, 79, 0.42);
  border-radius: 8px;
  background: #fff8e7;
  color: #574116;
  font-size: 0.78rem;
  line-height: 1.45;
}

.omj-ai-chat__notice a {
  color: #5f3f0d;
  font-weight: 800;
}

.omj-ai-chat__messages {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.omj-ai-chat__message {
  display: flex;
  max-width: 86%;
}

.omj-ai-chat__message--assistant {
  max-width: 94%;
}

.omj-ai-chat__message--assistant .omj-ai-chat__bubble {
  width: 100%;
  min-width: 0;
  word-break: break-word;
}

.omj-ai-chat__message--user {
  align-self: flex-end;
  justify-content: flex-end;
}

.omj-ai-chat__bubble {
  padding: 0.7rem 0.78rem;
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  border: 1px solid var(--omj-ai-border);
  box-shadow: 0 8px 22px rgba(8, 17, 29, 0.06);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
  line-height: 1.48;
}

.omj-ai-chat__message--user .omj-ai-chat__bubble {
  background: var(--omj-ai-navy);
  border-color: var(--omj-ai-navy);
  color: #ffffff;
}

.omj-ai-chat__message--error .omj-ai-chat__bubble {
  border-color: rgba(180, 35, 24, 0.28);
  background: #fff4f2;
  color: var(--omj-ai-danger);
}

.omj-ai-chat__bubble a {
  color: #8a5d14;
  font-weight: 800;
}

.omj-ai-chat__quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.8rem;
}

.omj-ai-chat__quick-reply,
.omj-ai-chat__secondary-button {
  border: 1px solid rgba(8, 17, 29, 0.15);
  border-radius: 999px;
  background: #ffffff;
  color: var(--omj-ai-navy);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.25;
  padding: 0.48rem 0.65rem;
}

.omj-ai-chat__quick-reply:hover,
.omj-ai-chat__secondary-button:hover {
  border-color: var(--omj-ai-gold);
  background: var(--omj-ai-ivory);
}

.omj-ai-chat__typing {
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
}

.omj-ai-chat__typing span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--omj-ai-gold);
  animation: omjAiTyping 0.95s infinite ease-in-out;
}

.omj-ai-chat__typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.omj-ai-chat__typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes omjAiTyping {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.omj-ai-chat__composer {
  border-top: 1px solid var(--omj-ai-border);
  padding: 0.75rem;
  background: #ffffff;
}

.omj-ai-chat__composer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: end;
}

.omj-ai-chat__input {
  min-height: 44px;
  max-height: 112px;
  resize: none;
  width: 100%;
  border: 1px solid var(--omj-ai-border);
  border-radius: 8px;
  padding: 0.68rem 0.7rem;
  color: #172033;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.4;
}

.omj-ai-chat__send {
  min-width: 72px;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--omj-ai-gold);
  color: var(--omj-ai-navy);
  cursor: pointer;
  font-weight: 900;
}

.omj-ai-chat__send:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.omj-ai-chat__footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.omj-ai-chat__lead-form {
  margin-top: 0.8rem;
  padding: 0.75rem;
  border: 1px solid var(--omj-ai-border);
  border-radius: 8px;
  background: #ffffff;
}

.omj-ai-chat__lead-form[hidden] {
  display: none;
}

.omj-ai-chat__lead-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.omj-ai-chat__lead-form label {
  display: grid;
  gap: 0.28rem;
  color: var(--omj-ai-muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.omj-ai-chat__lead-form input,
.omj-ai-chat__lead-form textarea {
  width: 100%;
  border: 1px solid var(--omj-ai-border);
  border-radius: 8px;
  padding: 0.55rem 0.6rem;
  color: #172033;
  font: inherit;
  font-size: 0.86rem;
}

.omj-ai-chat__lead-form textarea {
  min-height: 76px;
  resize: vertical;
}

.omj-ai-chat__consent {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: flex-start;
  gap: 0.45rem !important;
  margin: 0.55rem 0;
  font-weight: 700 !important;
  line-height: 1.35;
}

.omj-ai-chat__consent input {
  width: auto;
  margin-top: 0.15rem;
}

.omj-ai-chat__lead-submit {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: var(--omj-ai-navy);
  color: #ffffff;
  cursor: pointer;
  font-weight: 900;
}

@media (max-width: 760px) {
  .omj-ai-chat {
    right: 12px;
    bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  }

  .omj-ai-chat__panel {
    right: -4px;
    width: calc(100vw - 16px);
    height: min(640px, calc(100vh - 108px));
    min-height: 0;
  }

  .omj-ai-chat__message {
    max-width: 92%;
  }

  .omj-ai-chat__lead-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .omj-ai-chat__launcher > span:not(.omj-ai-chat__launcher-mark) {
    display: none;
  }

  .omj-ai-chat__launcher {
    min-width: 48px;
    padding: 0 0.65rem;
  }
}
