.nana-conversation__bubble-stage[data-bubble-state="idle"] {
  min-height: 0;
  padding-bottom: 0;
}

.nana-conversation__bubble-stage[data-bubble-state]:not([data-bubble-state="idle"]) {
  overflow: visible;
}

.nana-bubble {
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.36s ease-out,
    transform 0.36s ease-out;
  width: fit-content;
  max-width: var(--stage-bubble-width, min(29rem, calc(100% - 4.75rem)));
  min-width: min(8.5rem, 100%);
  margin: 0;
  flex-shrink: 1;
}

.nana-bubble--visible {
  opacity: 1;
  transform: translateY(0);
}

.nana-bubble--reading {
  transform: translateY(0);
}

.nana-bubble__shell {
  position: relative;
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  overflow: visible;
}

.nana-bubble__body {
  position: relative;
  display: block;
  padding: 1rem 1.3rem;
  padding-right: 1.5rem;
  padding-bottom: 1.05rem;
  border-radius: 2em;
  border-bottom-right-radius: 1.35em;
  background: rgba(108, 99, 255, 0.11);
  border: 1px solid rgba(129, 140, 248, 0.2);
  color: #e8edf7;
  font-size: 0.9375rem;
  line-height: 1.65;
  word-break: break-word;
  max-height: min(72vh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 0 2px 18px rgba(108, 99, 255, 0.06);
}

/* Tail — soft stem from lower-right toward NANA's head */
.nana-bubble__tail {
  position: absolute;
  right: -1px;
  bottom: 4px;
  width: 30px;
  height: 26px;
  pointer-events: none;
  overflow: visible;
}

.nana-bubble__tail::before {
  content: "";
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 18px;
  height: 11px;
  background: rgba(108, 99, 255, 0.11);
  border: 1px solid rgba(129, 140, 248, 0.2);
  border-radius: 0 0 100% 55%;
  border-top: none;
  border-left: none;
  transform: rotate(46deg);
  transform-origin: top left;
}

.nana-bubble__tail::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 9px;
  height: 9px;
  background: rgba(108, 99, 255, 0.11);
  border: 1px solid rgba(129, 140, 248, 0.2);
  border-radius: 50%;
  border-top-color: transparent;
  border-left-color: transparent;
  transform: rotate(18deg);
  opacity: 0.88;
}

.nana-bubble__body strong {
  color: #f1f5f9;
  font-weight: 600;
}

.nana-bubble__body--typing::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: rgba(196, 181, 253, 0.85);
  animation: nanaBubbleCaret 1s ease-in-out infinite;
}

@keyframes nanaBubbleCaret {
  0%,
  45% {
    opacity: 1;
  }

  46%,
  100% {
    opacity: 0.2;
  }
}

@media (max-width: 640px) {
  .nana-bubble {
    max-width: var(--stage-bubble-width, min(26rem, calc(100% - 4.5rem)));
    min-width: min(7.5rem, 100%);
  }

  .nana-bubble__body {
    padding: 0.9rem 1.15rem;
    padding-right: 1.3rem;
    font-size: 0.9rem;
    max-height: min(68vh, 480px);
  }

  .nana-bubble__tail {
    width: 26px;
    height: 22px;
    bottom: 3px;
  }

  .nana-bubble__tail::before {
    width: 15px;
    height: 9px;
    right: 5px;
    bottom: 5px;
    transform: rotate(44deg);
  }

  .nana-bubble__tail::after {
    width: 8px;
    height: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nana-bubble {
    transition: opacity 0.01ms linear;
    transform: none;
  }

  .nana-bubble__body--typing::after {
    animation: none;
    opacity: 0.7;
  }
}
