/**
 * LP AI chat widget — scoped styles (does not restyle the host page).
 */
#ngtAiChatRoot {
  --ngt-ai-ink: #1c1914;
  --ngt-ai-muted: #5c564c;
  --ngt-ai-line: #cfc6b6;
  --ngt-ai-accent: #0f5c4c;
  --ngt-ai-accent-ink: #f7f3ea;
  --ngt-ai-panel: #fffdf8;
  --ngt-ai-bot: #ebe4d6;
  --ngt-ai-user: #1c1914;
  --ngt-ai-warn: #8a4b12;
  --ngt-ai-launcher-bottom: 1.25rem;
  --ngt-ai-launcher-height: 2.85rem;
  --ngt-ai-panel-gap: 0.45rem;
  --ngt-ai-panel-bottom: calc(
    var(--ngt-ai-launcher-bottom) + var(--ngt-ai-launcher-height) + var(--ngt-ai-panel-gap)
  );
  --ngt-ai-viewport-pad: 1rem;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ngt-ai-ink);
}

#ngtAiChatRoot .ngt-ai-launcher {
  position: fixed;
  right: 1.1rem;
  bottom: calc(var(--ngt-ai-launcher-bottom) + env(safe-area-inset-bottom, 0px));
  z-index: 1040;
  border: none;
  border-radius: 999px;
  background: var(--ngt-ai-accent);
  color: var(--ngt-ai-accent-ink);
  font: inherit;
  font-weight: 600;
  padding: 0.85rem 1.25rem;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(15, 92, 76, 0.28);
}

#ngtAiChatRoot .ngt-ai-launcher:hover {
  filter: brightness(1.05);
}

#ngtAiChatRoot .ngt-ai-panel {
  position: fixed;
  right: 1.1rem;
  bottom: calc(var(--ngt-ai-panel-bottom) + env(safe-area-inset-bottom, 0px));
  width: min(380px, calc(100vw - 1.4rem));
  height: min(
    520px,
    calc(100vh - var(--ngt-ai-panel-bottom) - var(--ngt-ai-viewport-pad) - env(safe-area-inset-bottom, 0px))
  );
  z-index: 1050;
  display: flex;
  flex-direction: column;
  background: var(--ngt-ai-panel);
  border: 1px solid var(--ngt-ai-line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(28, 25, 20, 0.18);
}

#ngtAiChatRoot .ngt-ai-panel[hidden] {
  display: none !important;
}

#ngtAiChatRoot .ngt-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--ngt-ai-line);
  background: #f7f2e8;
}

#ngtAiChatRoot .ngt-ai-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

#ngtAiChatRoot .ngt-ai-sub {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.72rem;
  color: var(--ngt-ai-muted);
  font-weight: 400;
}

#ngtAiChatRoot .ngt-ai-close {
  border: none;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ngt-ai-muted);
}

#ngtAiChatRoot .ngt-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: linear-gradient(180deg, #fffdf8 0%, #f6f1e7 100%);
}

#ngtAiChatRoot .ngt-ai-msg {
  max-width: 92%;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  font-size: 0.9rem;
  white-space: pre-wrap;
}

#ngtAiChatRoot .ngt-ai-msg-bot {
  align-self: flex-start;
  background: var(--ngt-ai-bot);
}

#ngtAiChatRoot .ngt-ai-msg-user {
  align-self: flex-end;
  background: var(--ngt-ai-user);
  color: #f7f3ea;
}

#ngtAiChatRoot .ngt-ai-msg-actions {
  margin-top: 0.55rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

#ngtAiChatRoot .ngt-ai-msg-actions button {
  font: inherit;
  font-size: 0.78rem;
  border-radius: 999px;
  border: 1px solid var(--ngt-ai-accent);
  background: #fff;
  color: var(--ngt-ai-accent);
  padding: 0.3rem 0.65rem;
  cursor: pointer;
}

#ngtAiChatRoot .ngt-ai-fallback {
  margin: 0;
  padding: 0.5rem 0.85rem;
  font-size: 0.74rem;
  color: var(--ngt-ai-warn);
  background: #fff6eb;
  border-top: 1px solid #e8c9a0;
}

#ngtAiChatRoot .ngt-ai-compose {
  display: flex;
  gap: 0.4rem;
  padding: 0.7rem;
  border-top: 1px solid var(--ngt-ai-line);
  background: var(--ngt-ai-panel);
}

#ngtAiChatRoot .ngt-ai-compose input {
  flex: 1;
  border: 1px solid var(--ngt-ai-line);
  border-radius: 999px;
  padding: 0.55rem 0.85rem;
  font: inherit;
  min-width: 0;
}

#ngtAiChatRoot .ngt-ai-send {
  background: var(--ngt-ai-accent);
  color: var(--ngt-ai-accent-ink);
  border: none;
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

#ngtAiChatRoot .ngt-ai-privacy {
  margin: 0;
  padding: 0.5rem 0.85rem 0.7rem;
  font-size: 0.7rem;
  line-height: 1.4;
  color: var(--ngt-ai-muted);
  border-top: 1px dashed var(--ngt-ai-line);
  background: var(--ngt-ai-panel);
}

#ngtAiChatRoot .ngt-ai-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 640px) {
  #ngtAiChatRoot {
    /* JS may raise --ngt-ai-launcher-bottom above footer / goTop on mobile */
    --ngt-ai-launcher-bottom: 1rem;
    --ngt-ai-viewport-pad: 0.75rem;
  }

  #ngtAiChatRoot .ngt-ai-launcher {
    right: 0.75rem;
  }

  #ngtAiChatRoot .ngt-ai-panel {
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
    height: min(
      460px,
      calc(100vh - var(--ngt-ai-panel-bottom) - var(--ngt-ai-viewport-pad) - env(safe-area-inset-bottom, 0px))
    );
  }
}
