/* HLMG SMS Chat — floating widget (bottom-left to avoid page dock on the right) */
.hlmg-sms-chat-root {
  --hlmg-chat-ink: #2a2118;
  --hlmg-chat-paper: #f7f1e8;
  --hlmg-chat-panel: #fffdf9;
  --hlmg-chat-accent: #6b4f2a;
  --hlmg-chat-accent-deep: #4a3518;
  --hlmg-chat-line: rgba(42, 33, 24, 0.14);
  --hlmg-chat-visitor: #e8dcc8;
  --hlmg-chat-owner: #dfe8d8;
  --hlmg-chat-shadow: 0 12px 40px rgba(42, 33, 24, 0.22);
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 99990;
  font-family: "Source Sans 3", "Source Sans Pro", system-ui, sans-serif;
  color: var(--hlmg-chat-ink);
}

.hlmg-sms-chat-root[hidden] {
  display: none !important;
}

.hlmg-sms-chat-fab {
  appearance: none;
  border: 0;
  border-radius: 999px;
  width: 56px;
  height: 56px;
  background: linear-gradient(145deg, var(--hlmg-chat-accent), var(--hlmg-chat-accent-deep));
  color: #f8f2e9;
  box-shadow: var(--hlmg-chat-shadow);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hlmg-sms-chat-fab:hover,
.hlmg-sms-chat-fab:focus-visible {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 16px 44px rgba(42, 33, 24, 0.28);
  outline: none;
}

.hlmg-sms-chat-fab svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

.hlmg-sms-chat-panel {
  position: absolute;
  left: 0;
  bottom: 68px;
  width: min(360px, calc(100vw - 32px));
  height: min(480px, calc(100vh - 120px));
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(107, 79, 42, 0.08), transparent 55%),
    linear-gradient(180deg, var(--hlmg-chat-panel), var(--hlmg-chat-paper));
  border: 1px solid var(--hlmg-chat-line);
  border-radius: 16px;
  box-shadow: var(--hlmg-chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.hlmg-sms-chat-root.is-open .hlmg-sms-chat-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.hlmg-sms-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--hlmg-chat-line);
}

.hlmg-sms-chat-header h2 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.hlmg-sms-chat-close {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--hlmg-chat-ink);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}

.hlmg-sms-chat-close:hover,
.hlmg-sms-chat-close:focus-visible {
  background: rgba(42, 33, 24, 0.06);
  outline: none;
}

.hlmg-sms-chat-intro,
.hlmg-sms-chat-status {
  margin: 0;
  padding: 10px 14px 0;
  font-size: 0.9rem;
  line-height: 1.4;
  opacity: 0.85;
}

.hlmg-sms-chat-status.is-error {
  color: #8a2f1f;
  opacity: 1;
}

.hlmg-sms-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hlmg-sms-chat-bubble {
  max-width: 85%;
  padding: 8px 11px;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  animation: hlmg-chat-in 0.22s ease;
}

.hlmg-sms-chat-bubble--visitor {
  align-self: flex-end;
  background: var(--hlmg-chat-visitor);
  border-bottom-right-radius: 4px;
}

.hlmg-sms-chat-bubble--owner {
  align-self: flex-start;
  background: var(--hlmg-chat-owner);
  border-bottom-left-radius: 4px;
}

.hlmg-sms-chat-bubble--system {
  align-self: center;
  background: transparent;
  color: rgba(42, 33, 24, 0.7);
  font-size: 0.82rem;
  text-align: center;
}

@keyframes hlmg-chat-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hlmg-sms-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--hlmg-chat-line);
  background: rgba(255, 253, 249, 0.85);
}

.hlmg-sms-chat-form textarea {
  resize: none;
  min-height: 44px;
  max-height: 96px;
  border: 1px solid var(--hlmg-chat-line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
  color: var(--hlmg-chat-ink);
}

.hlmg-sms-chat-form textarea:focus {
  outline: 2px solid rgba(107, 79, 42, 0.35);
  outline-offset: 1px;
}

.hlmg-sms-chat-form button[type="submit"] {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 0 16px;
  background: var(--hlmg-chat-accent);
  color: #f8f2e9;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.hlmg-sms-chat-form button[type="submit"]:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.hlmg-sms-chat-hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
}

.hlmg-sms-chat-root.is-unavailable .hlmg-sms-chat-form {
  display: none;
}

@media (max-width: 480px) {
  .hlmg-sms-chat-root {
    left: 12px;
    bottom: 12px;
  }

  .hlmg-sms-chat-panel {
    width: min(100vw - 24px, 360px);
    height: min(70vh, 480px);
  }
}
