:root {
  --amm-chat-bg: #1a1714;
  --amm-chat-card: #2c2820;
  --amm-chat-cream: #f0ebe0;
  --amm-chat-muted: #a8a07a;
  --amm-chat-teal: #5bbfb5;
  --amm-chat-border: rgba(168, 160, 122, 0.24);
}

.amm-chat,
.amm-chat * {
  box-sizing: border-box;
}

.amm-chat {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1200;
  font-family: "Jost", Arial, sans-serif;
  color: var(--amm-chat-cream);
}

.amm-chat__toggle {
  width: 62px;
  height: 62px;
  margin-left: auto;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--amm-chat-teal);
  color: var(--amm-chat-bg);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.34);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.amm-chat__toggle:hover,
.amm-chat__toggle:focus-visible {
  background: #74cbc2;
  transform: translateY(-2px);
}

.amm-chat__toggle:focus-visible,
.amm-chat button:focus-visible,
.amm-chat input:focus-visible,
.amm-chat a:focus-visible {
  outline: 2px solid var(--amm-chat-cream);
  outline-offset: 3px;
}

.amm-chat__toggle svg {
  width: 27px;
  height: 27px;
}

.amm-chat__panel {
  position: absolute;
  right: 0;
  bottom: 78px;
  width: min(380px, calc(100vw - 28px));
  height: min(620px, calc(100vh - 120px));
  min-height: 460px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--amm-chat-border);
  border-radius: 18px;
  background: var(--amm-chat-bg);
  box-shadow: 0 24px 65px rgba(0, 0, 0, 0.45);
  transform-origin: bottom right;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}

.amm-chat__panel[hidden] {
  display: flex;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px) scale(0.97);
}

.amm-chat__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 17px 18px;
  border-bottom: 1px solid var(--amm-chat-border);
  background: var(--amm-chat-card);
}

.amm-chat__mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--amm-chat-teal);
  color: var(--amm-chat-bg);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.15rem;
  font-weight: 600;
}

.amm-chat__heading {
  min-width: 0;
  flex: 1;
}

.amm-chat__title {
  margin: 0;
  color: var(--amm-chat-cream);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.3rem;
  font-weight: 400;
  line-height: 1.1;
}

.amm-chat__status {
  margin: 3px 0 0;
  color: var(--amm-chat-muted);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.amm-chat__close {
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--amm-chat-cream);
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
}

.amm-chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 12px;
  scrollbar-color: var(--amm-chat-muted) transparent;
}

.amm-chat__message {
  width: fit-content;
  max-width: 88%;
  margin: 0 0 12px;
  padding: 11px 13px;
  border-radius: 14px 14px 14px 4px;
  background: var(--amm-chat-card);
  color: var(--amm-chat-cream);
  font-size: 0.87rem;
  font-weight: 300;
  line-height: 1.55;
  white-space: pre-wrap;
}

.amm-chat__message--user {
  margin-left: auto;
  border-radius: 14px 14px 4px 14px;
  background: var(--amm-chat-teal);
  color: var(--amm-chat-bg);
  font-weight: 400;
}

.amm-chat__message a {
  color: #8bd8d0;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.amm-chat__message--user a {
  color: var(--amm-chat-bg);
}

.amm-chat__typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  min-width: 52px;
}

.amm-chat__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amm-chat-muted);
  animation: amm-chat-pulse 1s infinite ease-in-out;
}

.amm-chat__typing span:nth-child(2) { animation-delay: 0.12s; }
.amm-chat__typing span:nth-child(3) { animation-delay: 0.24s; }

@keyframes amm-chat-pulse {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.amm-chat__quick-actions {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 0 16px 12px;
  scrollbar-width: none;
}

.amm-chat__quick-actions::-webkit-scrollbar { display: none; }

.amm-chat__quick-action {
  flex: 0 0 auto;
  border: 1px solid var(--amm-chat-border);
  border-radius: 999px;
  padding: 8px 11px;
  background: transparent;
  color: var(--amm-chat-cream);
  font: inherit;
  font-size: 0.73rem;
  cursor: pointer;
}

.amm-chat__quick-action:hover {
  border-color: var(--amm-chat-teal);
  color: var(--amm-chat-teal);
}

.amm-chat__form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--amm-chat-border);
  background: var(--amm-chat-card);
}

.amm-chat__input {
  min-width: 0;
  flex: 1;
  border: 1px solid var(--amm-chat-border);
  border-radius: 999px;
  padding: 11px 14px;
  background: #211e19;
  color: var(--amm-chat-cream);
  font: inherit;
  font-size: 0.85rem;
}

.amm-chat__input::placeholder { color: #827969; }

.amm-chat__send {
  width: 43px;
  height: 43px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: var(--amm-chat-teal);
  color: var(--amm-chat-bg);
  cursor: pointer;
}

.amm-chat__send:disabled {
  cursor: wait;
  opacity: 0.55;
}

.amm-chat__notice {
  margin: 0;
  padding: 0 14px 11px;
  background: var(--amm-chat-card);
  color: #8d8474;
  font-size: 0.64rem;
  line-height: 1.4;
  text-align: center;
}

@media (max-width: 768px) {
  .amm-chat {
    right: 14px;
    bottom: 70px;
  }

  .amm-chat__panel {
    position: fixed;
    right: 10px;
    bottom: 138px;
    width: calc(100vw - 20px);
    height: min(620px, calc(100vh - 154px));
    min-height: 390px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .amm-chat__panel,
  .amm-chat__toggle,
  .amm-chat__typing span {
    transition: none;
    animation: none;
  }
}
