#somlock-chat {
  --sc-blue: #0595d5;
  --sc-blue-hover: #0480b8;
  --sc-navy: #0f627f;
  --sc-navy-dark: #0b4a61;
  --sc-ink: #1e293b;
  --sc-muted: #64748b;
  --sc-border: #e2e8f0;
  --sc-bg: #f1f5f9;
  --sc-surface: #ffffff;
  --sc-green: #10b981;
  --sc-shadow: 0 12px 40px rgba(15, 23, 42, 0.18), 0 2px 8px rgba(15, 23, 42, 0.08);
  color: var(--sc-ink);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#somlock-chat *,
#somlock-chat *::before,
#somlock-chat *::after {
  box-sizing: border-box;
}

#somlock-chat [hidden] {
  display: none !important;
}

#somlock-chat .somlock-chat__toggle,
#somlock-chat .somlock-chat__panel {
  position: fixed;
  z-index: 1090;
}

/* 1. Toggle Button */
#somlock-chat .somlock-chat__toggle {
  right: max(1.25rem, env(safe-area-inset-right));
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sc-blue), var(--sc-navy));
  color: #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15), 0 2px 4px rgba(15, 23, 42, 0.08);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#somlock-chat .somlock-chat__toggle:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.2), 0 2px 6px rgba(15, 23, 42, 0.1);
}

#somlock-chat .somlock-chat__toggle:active {
  transform: scale(0.95);
}

#somlock-chat .somlock-chat__toggle svg {
  width: 1.5rem;
  height: 1.5rem;
  stroke: currentColor;
}

/* 2. Chat Panel */
#somlock-chat .somlock-chat__panel {
  right: max(1.25rem, env(safe-area-inset-right));
  bottom: calc(max(1.25rem, env(safe-area-inset-bottom)) + 4.5rem);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  align-content: stretch;
  gap: 0;
  width: min(24rem, calc(100vw - 2.5rem));
  height: min(36rem, calc(100vh - 7rem));
  height: min(36rem, calc(100dvh - 7rem));
  min-height: min(20rem, calc(100dvh - 7rem));
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 1.125rem;
  background-color: var(--sc-surface);
  box-shadow: var(--sc-shadow);
  transform-origin: bottom right;
  animation: somlock-chat-in 0.22s ease-out;
}

@keyframes somlock-chat-in {
  from {
    opacity: 0;
    transform: translateY(0.75rem) scale(0.97);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* Panel children: no stray margins from the host site, stretch full width */
#somlock-chat .somlock-chat__panel>* {
  width: 100%;
  margin-top: 0;
  margin-bottom: 0;
}

/* 3. Header */
#somlock-chat .somlock-chat__header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  background: linear-gradient(135deg, var(--sc-navy), var(--sc-navy-dark));
  color: #fff;
}

#somlock-chat .somlock-chat__header-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#somlock-chat .somlock-chat__title {
  margin: 0;
  overflow: hidden;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  color: #fff;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#somlock-chat .somlock-chat__subtitle-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.2rem;
}

#somlock-chat .somlock-chat__status-dot {
  position: relative;
  width: 0.5rem;
  height: 0.5rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background-color: var(--sc-green);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
  animation: somlock-chat-pulse 2s ease-out infinite;
}

@keyframes somlock-chat-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55);
  }

  70% {
    box-shadow: 0 0 0 0.4rem rgba(16, 185, 129, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

#somlock-chat .somlock-chat__subtitle {
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  line-height: 1.3;
}

#somlock-chat .somlock-chat__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

#somlock-chat .somlock-chat__close:hover {
  background-color: rgba(255, 255, 255, 0.28);
}

#somlock-chat .somlock-chat__close svg {
  width: 1rem;
  height: 1rem;
}

/* 4. Messages */
#somlock-chat .somlock-chat__messages {
  display: flex;
  min-height: 0;
  flex: 1 1 0;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 0.75rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem;
  background-color: var(--sc-bg);
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

#somlock-chat .somlock-chat__messages::-webkit-scrollbar {
  width: 6px;
}

#somlock-chat .somlock-chat__messages::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background-color: #cbd5e1;
}

/* Bot bubbles: white with a border so they stand out from the background */
#somlock-chat .somlock-chat__welcome,
#somlock-chat .somlock-chat__message {
  align-self: flex-start;
  max-width: 86%;
  margin: 0;
  padding: 0.75rem 0.95rem;
  border: 1px solid var(--sc-border);
  border-radius: 1rem 1rem 1rem 0.3rem;
  background-color: var(--sc-surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  color: var(--sc-ink);
  font-size: 15px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  animation: somlock-chat-msg 0.18s ease-out;
}

@keyframes somlock-chat-msg {
  from {
    opacity: 0;
    transform: translateY(0.4rem);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

#somlock-chat .somlock-chat__message--user {
  align-self: flex-end;
  border-color: transparent;
  border-radius: 1rem 1rem 0.3rem 1rem;
  background: linear-gradient(135deg, var(--sc-blue), var(--sc-navy));
  color: #fff;
}

#somlock-chat .somlock-chat__message--error {
  border: 1px solid #fecaca;
  background-color: #fef2f2;
  color: #991b1b;
}

#somlock-chat .somlock-chat__speaker {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--sc-navy);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#somlock-chat .somlock-chat__message--user .somlock-chat__speaker {
  color: rgba(255, 255, 255, 0.85);
}

#somlock-chat .somlock-chat__message--error .somlock-chat__speaker {
  color: #991b1b;
}

#somlock-chat .somlock-chat__text {
  margin: 0;
  white-space: pre-wrap;
}

#somlock-chat .somlock-chat__text a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

#somlock-chat .somlock-chat__message:not(.somlock-chat__message--user) .somlock-chat__text a {
  color: var(--sc-blue-hover);
}

/* 5. Status / Waiting */
#somlock-chat .somlock-chat__status {
  flex: 0 0 auto;
  min-height: 1.5rem;
  padding: 0.25rem 1rem;
  background-color: var(--sc-bg);
  color: var(--sc-muted);
  font-size: 13px;
  font-style: italic;
}

#somlock-chat .somlock-chat__status:empty {
  min-height: 0;
  padding: 0;
}

/* 6. Composer Form */
#somlock-chat .somlock-chat__form {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.75rem;
  border-top: 1px solid var(--sc-border);
  background-color: var(--sc-surface);
}

#somlock-chat .somlock-chat__composer {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.35rem 0.4rem 0.35rem 0.9rem;
  border: 1px solid var(--sc-border);
  border-radius: 1.5rem;
  background-color: var(--sc-bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

#somlock-chat .somlock-chat__composer:focus-within {
  border-color: var(--sc-blue);
  background-color: var(--sc-surface);
  box-shadow: 0 0 0 3px rgba(5, 149, 213, 0.15);
}

#somlock-chat .somlock-chat__input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 1.5rem;
  max-height: 6rem;
  margin: 0;
  padding: 0.35rem 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--sc-ink);
  font: inherit;
  font-size: 16px !important;
  line-height: 1.45;
  resize: none;
}

#somlock-chat .somlock-chat__input::placeholder {
  color: var(--sc-muted);
  opacity: 1;
}

#somlock-chat .somlock-chat__send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background-color: #cbd5e1;
  color: #fff;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

#somlock-chat .somlock-chat__send svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: currentColor;
}

#somlock-chat .somlock-chat__composer--has-text .somlock-chat__send {
  background-color: var(--sc-blue);
}

#somlock-chat .somlock-chat__composer--has-text .somlock-chat__send:hover:not(:disabled) {
  background-color: var(--sc-blue-hover);
  transform: scale(1.06);
}

#somlock-chat .somlock-chat__send:disabled {
  opacity: 0.5;
  cursor: wait;
}

#somlock-chat .somlock-chat__retry {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.3rem 0.7rem;
  border: 0;
  border-radius: 0.4rem;
  background-color: var(--sc-navy);
  color: #fff;
  font-size: 0.775rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

#somlock-chat .somlock-chat__retry:hover {
  background-color: var(--sc-navy-dark);
}

#somlock-chat :focus-visible {
  outline: 2px solid var(--sc-blue);
  outline-offset: 2px;
}

#somlock-chat .somlock-chat__input:focus-visible {
  outline: none;
}

#somlock-chat .somlock-chat__visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* 7. Responsive */
@media (max-width: 36rem) {
  body.somlock-chat-scroll-lock {
    overflow: hidden;
  }

  #somlock-chat.somlock-chat--open .somlock-chat__toggle {
    display: none;
  }

  #somlock-chat .somlock-chat__toggle {
    right: max(1rem, env(safe-area-inset-right));
    bottom: max(1rem, env(safe-area-inset-bottom));
    width: 3.875rem;
    height: 3.875rem;
  }

  #somlock-chat .somlock-chat__toggle svg {
    width: 1.85rem;
    height: 1.85rem;
  }

  #somlock-chat .somlock-chat__panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    width: 100vw;
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    border: none;
    border-radius: 0;
    margin: 0;
    z-index: 1095;
    animation: somlock-chat-in-mobile 0.2s ease-out;
  }

  @keyframes somlock-chat-in-mobile {
    from {
      opacity: 0;
      transform: translateY(1rem);
    }

    to {
      opacity: 1;
      transform: none;
    }
  }

  #somlock-chat .somlock-chat__header {
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-left: max(1.1rem, env(safe-area-inset-left));
    padding-right: max(1.1rem, env(safe-area-inset-right));
    padding-bottom: 0.95rem;
    border-radius: 0;
  }

  #somlock-chat .somlock-chat__title {
    font-size: 17px;
  }

  #somlock-chat .somlock-chat__subtitle {
    font-size: 13.5px;
  }

  #somlock-chat .somlock-chat__messages {
    padding: 1rem 1.1rem;
    gap: 0.85rem;
  }

  #somlock-chat .somlock-chat__welcome,
  #somlock-chat .somlock-chat__message {
    max-width: 90%;
    padding: 0.85rem 1.05rem;
    font-size: 15.5px;
    line-height: 1.55;
    border-radius: 1.1rem 1.1rem 1.1rem 0.35rem;
  }

  #somlock-chat .somlock-chat__message--user {
    border-radius: 1.1rem 1.1rem 0.35rem 1.1rem;
  }

  #somlock-chat .somlock-chat__speaker {
    font-size: 12px;
    margin-bottom: 0.3rem;
  }

  #somlock-chat .somlock-chat__status {
    font-size: 13.5px;
  }

  #somlock-chat .somlock-chat__form {
    padding-top: 0.75rem;
    padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
    padding-left: max(0.85rem, env(safe-area-inset-left));
    padding-right: max(0.85rem, env(safe-area-inset-right));
  }

  #somlock-chat .somlock-chat__composer {
    padding: 0.4rem 0.5rem 0.4rem 1rem;
  }

  #somlock-chat .somlock-chat__input {
    font-size: 16px !important;
    line-height: 1.45;
  }

  #somlock-chat .somlock-chat__send {
    width: 2.5rem;
    height: 2.5rem;
  }

  #somlock-chat .somlock-chat__send svg {
    width: 1.25rem;
    height: 1.25rem;
  }
}

@media (max-height: 28rem) {
  #somlock-chat .somlock-chat__panel {
    height: calc(100vh - 4.5rem);
    height: calc(100dvh - 4.5rem);
    min-height: 0;
  }
}

@media (prefers-reduced-motion: reduce) {

  #somlock-chat *,
  #somlock-chat *::before,
  #somlock-chat *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* 8. Scroll-to-top Stacking */
.scroll-top-arrow {
  position: fixed !important;
  right: calc(max(1.25rem, env(safe-area-inset-right)) + 11px) !important;
  bottom: calc(max(1.25rem, env(safe-area-inset-bottom)) + 4.25rem) !important;
  z-index: 1089 !important;
}

@media (max-width: 36rem) {
  .scroll-top-arrow {
    right: calc(max(1rem, env(safe-area-inset-right)) + 9px) !important;
    bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 4.5rem) !important;
  }
}

/* 9. Mobile Scroll Lock */
body.somlock-chat-scroll-lock {
  overflow: hidden !important;
  touch-action: none;
}