.nm-chat-root {
  position: fixed;
  bottom: 20px;
  right: 16px;
  z-index: 9999;
  font-family: var(--font-body);
}

.nm-chat-fab {
  position: relative;
  z-index: 3;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: #fff;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(13, 26, 18, 0.28);
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nm-chat-fab-wrap {
  position: relative;
  z-index: 3;
  width: 64px;
  height: 64px;
}

.nm-chat-fab-notify {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 22px;
  text-align: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.45);
  pointer-events: none;
  z-index: 4;
}

.nm-chat-fab-notify[hidden] {
  display: none;
}

.nm-chat-fab-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 22%;
  display: block;
  transform: scale(1.12);
}

.nm-chat-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  background: rgba(10, 8, 16, 0.35);
  cursor: pointer;
}

.nm-chat-backdrop.is-open {
  display: block;
}

.nm-chat-panel {
  display: none;
  position: absolute;
  bottom: 72px;
  right: 0;
  z-index: 2;
  width: min(94vw, 420px);
  max-height: min(85vh, 680px);
  height: min(85vh, 680px);
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(92, 45, 110, 0.2);
  box-shadow: 0 20px 50px rgba(26, 15, 32, 0.22);
  flex-direction: column;
  overflow: hidden;
}

.nm-chat-panel.is-open {
  display: flex;
}

.nm-chat-head {
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--plum) 0%, var(--plum-deep) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.nm-chat-head-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.nm-chat-head-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 22%;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.35);
  transform: scale(1.08);
}

.nm-chat-head strong {
  display: block;
  font-size: 0.95rem;
}

.nm-chat-head span {
  display: block;
  font-size: 0.75rem;
  opacity: 0.88;
  margin-top: 2px;
}

.nm-chat-close {
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.nm-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  min-height: 200px;
}

.nm-chat-bubble {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
}

.nm-chat-bubble--user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--plum), #7b4a94);
  color: #fff;
  white-space: pre-wrap;
}

.nm-chat-bubble--assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid rgba(92, 45, 110, 0.15);
}

.nm-chat-bubble--rich {
  white-space: normal;
}

.chat-md > *:first-child {
  margin-top: 0;
}

.chat-md > *:last-child {
  margin-bottom: 0;
}

.chat-md-p {
  margin: 0 0 0.5rem;
}

.chat-md-h2,
.chat-md-h3,
.chat-md-h4 {
  margin: 0.65rem 0 0.35rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--plum-deep, #4a2458);
}

.chat-md-h2 {
  font-size: 1rem;
}

.chat-md-h3 {
  font-size: 0.95rem;
}

.chat-md-h4 {
  font-size: 0.9rem;
}

.chat-md-list {
  margin: 0.35rem 0 0.6rem;
  padding-left: 1.25rem;
}

.chat-md-list li {
  margin: 0.2rem 0;
}

.chat-md-list li::marker {
  color: var(--plum, #5c2d6e);
}

.chat-md strong {
  font-weight: 700;
  color: var(--plum-deep, #4a2458);
}

.chat-md em {
  font-style: italic;
}

.chat-md a {
  color: var(--plum, #5c2d6e);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-md-code {
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.82em;
  background: rgba(92, 45, 110, 0.08);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.chat-md-pre {
  margin: 0.5rem 0;
  padding: 8px 10px;
  background: #f8f4fb;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.8rem;
}

.chat-md-pre code {
  font-family: inherit;
  white-space: pre-wrap;
  word-break: break-word;
}

.nm-chat-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(92, 45, 110, 0.12);
}

.nm-chat-input {
  flex: 1;
  border: 1px solid rgba(92, 45, 110, 0.25);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.nm-chat-send {
  border: none;
  border-radius: 10px;
  padding: 0 14px;
  background: linear-gradient(135deg, var(--gold), var(--accent-dark, #c9921a));
  color: #1a1408;
  font-weight: 700;
  cursor: pointer;
}

.nm-chat-mic {
  flex-shrink: 0;
  border: 1px solid rgba(92, 45, 110, 0.25);
  border-radius: 10px;
  padding: 0 12px;
  background: #fff;
  color: var(--plum, #5c2d6e);
  cursor: pointer;
  min-height: 42px;
  font-size: 1.1rem;
}

.nm-chat-mic.is-listening {
  background: #fef2f2;
  border-color: #ef4444;
  color: #dc2626;
}

@media (max-width: 768px) {
  .nm-chat-root .nm-chat-panel.is-open {
    position: fixed;
    inset: 0;
    bottom: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .nm-chat-root .nm-chat-panel.is-open ~ .nm-chat-fab-wrap {
    display: none;
  }

  .nm-chat-messages {
    min-height: 0;
    flex: 1;
  }
}
