.im-assistant-root {
  position: fixed;
  z-index: 500;
  right: 1rem;
  bottom: 1rem;
  pointer-events: none;
}

.im-assistant-root.hidden {
  display: none;
}

.im-assistant-root * {
  pointer-events: auto;
}

.im-assistant-fab {
  width: 4.1rem;
  height: 4.1rem;
  border-radius: 50%;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 10px 22px rgba(90, 61, 138, 0.45));
}

.im-assistant-agent-wrap {
  position: relative;
  width: 4rem;
  height: 4rem;
}

.im-assistant-bubble {
  position: absolute;
  top: -0.15rem;
  right: -0.1rem;
  width: 1.35rem;
  height: 1.1rem;
  background: #fff;
  border: 2px solid #5a3d8a;
  border-radius: 0.65rem 0.65rem 0.65rem 0.15rem;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(26, 39, 68, 0.18);
}

.im-assistant-bubble::after {
  content: "";
  position: absolute;
  left: 0.15rem;
  top: 0.28rem;
  width: 0.55rem;
  height: 0.35rem;
  border-radius: 999px;
  background: #5a3d8a;
  opacity: 0.25;
}

.im-assistant-avatar {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #fff;
  box-shadow: 0 0 0 3px rgba(184, 149, 106, 0.55);
}

.im-assistant-avatar svg {
  width: 100%;
  height: 100%;
  display: block;
}

.im-assistant-panel {
  position: absolute;
  right: 0;
  bottom: calc(4.1rem + 0.65rem);
  width: min(360px, calc(100vw - 2rem));
  max-height: min(420px, 58vh);
  background: var(--white);
  border-radius: var(--radius, 12px);
  box-shadow: 0 16px 48px rgba(26, 39, 68, 0.22);
  border: 1px solid rgba(184, 149, 106, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.im-assistant-panel.hidden {
  display: none;
}

.im-assistant-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
}

.im-assistant-close {
  border: none;
  background: transparent;
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}

.im-assistant-persona {
  padding: 1.1rem 1rem 1.25rem;
  text-align: center;
  background: var(--cream, #f5f0e8);
}

.im-assistant-persona.hidden {
  display: none;
}

.im-assistant-persona-q {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.45;
}

.im-assistant-persona-btns {
  display: flex;
  gap: 0.65rem;
  justify-content: center;
  flex-wrap: wrap;
}

.im-assistant-persona-btn {
  border: 2px solid var(--gold);
  background: var(--white);
  color: var(--navy);
  border-radius: 999px;
  padding: 0.55rem 1.35rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.im-assistant-persona-btn:active {
  background: rgba(184, 149, 106, 0.2);
}

.im-assistant-persona-hint {
  margin: 0.85rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted, #6b7280);
}

.im-assistant-log {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--cream, #f5f0e8);
  min-height: 6rem;
}

.im-assistant-log.hidden {
  display: none;
}

.im-assistant-msg {
  max-width: 92%;
  padding: 0.5rem 0.65rem;
  border-radius: 12px;
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.im-assistant-msg-bot {
  align-self: flex-start;
  background: var(--white);
  border: 1px solid var(--cream-dark, #e8dfd0);
  color: var(--navy);
}

.im-assistant-msg-user {
  align-self: flex-end;
  background: var(--navy);
  color: #fff;
}

.im-assistant-msg-thinking {
  opacity: 0.75;
  font-style: italic;
}

.im-assistant-form {
  display: flex;
  gap: 0.35rem;
  width: 100%;
  margin-top: 0.35rem;
}

.im-assistant-form input {
  flex: 1;
  border: 1px solid var(--cream-dark, #e8dfd0);
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
}

.im-assistant-form .btn-primary {
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  font-size: 0.78rem;
  white-space: nowrap;
}

.im-assistant-voice-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  padding: 0.85rem 0.75rem 1rem;
  border-top: 1px solid var(--cream-dark, #e8dfd0);
  background: var(--white);
}

.im-assistant-voice-bar.hidden {
  display: none;
}

.im-assistant-mic {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, #ff7a2e 0%, #ff4d4d 100%);
  color: #fff;
  font-size: 1.65rem;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 77, 77, 0.45);
}

.im-assistant-mic-active {
  box-shadow:
    0 0 0 4px rgba(255, 77, 77, 0.35),
    0 8px 24px rgba(255, 77, 77, 0.5);
  animation: im-assistant-mic-beat 0.9s ease-in-out infinite;
}

@keyframes im-assistant-mic-beat {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

.im-assistant-voice-hint {
  font-size: 0.78rem;
  color: var(--text-muted, #6b7280);
  text-align: center;
}

.is-mobile .im-assistant-root,
.is-pwa .im-assistant-root {
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  right: max(0.75rem, env(safe-area-inset-right, 0px));
}
