:root {
  --mmm-chat-bg: #0F0E0C;
  --mmm-chat-card: #1A1816;
  --mmm-chat-card2: #23211E;
  --mmm-chat-border: #302E2A;
  --mmm-chat-text: #E8E4DE;
  --mmm-chat-muted: #8A8680;
  --mmm-chat-green: #38B474;
}

.mmm-chat-bubble {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--mmm-chat-border);
  background: var(--mmm-chat-card2);
  color: var(--mmm-chat-text);
  font: 700 24px/1 system-ui, -apple-system, Segoe UI, sans-serif;
  cursor: pointer;
  box-shadow: 0 18px 48px rgba(0,0,0,.35);
}

.mmm-chat-panel {
  position: fixed;
  right: 22px;
  bottom: 90px;
  z-index: 9999;
  width: min(390px, calc(100vw - 28px));
  height: min(590px, calc(100vh - 120px));
  display: none;
  grid-template-rows: auto 1fr auto auto;
  background: var(--mmm-chat-bg);
  border: 1px solid var(--mmm-chat-border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0,0,0,.48);
  color: var(--mmm-chat-text);
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
}

.mmm-chat-panel.open { display: grid; }

.mmm-chat-panel header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  background: var(--mmm-chat-card);
  border-bottom: 1px solid var(--mmm-chat-border);
}

.mmm-chat-panel header strong {
  display: block;
  font-size: 14px;
}

.mmm-chat-panel header span {
  display: block;
  color: var(--mmm-chat-muted);
  font-size: 12px;
  margin-top: 2px;
}

.mmm-chat-close {
  border: 0;
  background: transparent;
  color: var(--mmm-chat-muted);
  font-size: 24px;
  cursor: pointer;
}

.mmm-chat-messages {
  padding: 16px;
  overflow-y: auto;
  min-height: 0;
  background: linear-gradient(180deg, var(--mmm-chat-bg), #12100e);
}

.mmm-msg {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 13px;
  margin-bottom: 10px;
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.45;
}

.mmm-bot {
  background: var(--mmm-chat-card);
  border: 1px solid var(--mmm-chat-border);
  color: var(--mmm-chat-text);
}

.mmm-user {
  margin-left: auto;
  background: rgba(56,180,116,.14);
  border: 1px solid rgba(56,180,116,.35);
  color: var(--mmm-chat-text);
}

.mmm-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--mmm-chat-border);
  background: var(--mmm-chat-card);
}

.mmm-chat-form input {
  min-width: 0;
  border: 1px solid var(--mmm-chat-border);
  border-radius: 12px;
  padding: 11px 12px;
  background: var(--mmm-chat-card2);
  color: var(--mmm-chat-text);
  outline: none;
}

.mmm-chat-form button {
  border: 1px solid rgba(56,180,116,.38);
  border-radius: 12px;
  padding: 10px 13px;
  background: rgba(56,180,116,.18);
  color: var(--mmm-chat-text);
  cursor: pointer;
  font-weight: 700;
}

.mmm-chat-panel footer {
  padding: 9px 12px;
  border-top: 1px solid var(--mmm-chat-border);
  color: var(--mmm-chat-muted);
  background: var(--mmm-chat-card);
  font-size: 11px;
}

.mmm-quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 14px;
}

.mmm-quick-prompts button {
  border: 1px solid var(--mmm-chat-border);
  border-radius: 999px;
  background: rgba(232,228,222,.04);
  color: var(--mmm-chat-muted);
  padding: 6px 9px;
  font-size: 11px;
  cursor: pointer;
}

.mmm-quick-prompts button:hover {
  color: var(--mmm-chat-text);
  border-color: rgba(232,228,222,.20);
}

/* Clear the Macro Market Model mobile purchase bar (.mobile-buy, shown <=980px). */
@media (max-width: 980px) {
  .mmm-chat-bubble { bottom: 84px; }

  .mmm-chat-panel {
    /* Near full width with sensible side margins, kept clear of the floating
       button and the mobile purchase bar. */
    right: 12px;
    left: 12px;
    bottom: 150px;
    width: auto;
    height: auto;
    /* Responsive height: shrinks with the dynamic viewport (e.g. when the
       on-screen keyboard opens) so the input bar stays reachable. */
    max-height: calc(100dvh - 168px);
  }

  /* >=16px stops mobile browsers from auto-zooming when the input is focused. */
  .mmm-chat-form input { font-size: 16px; }
}
