.comuna-assistant,
.comuna-assistant * {
  box-sizing: border-box;
}

.comuna-assistant {
  --assistant-accent: #e11d48;
  --assistant-accent-dark: #be123c;
  --assistant-panel: #18181b;
  --assistant-surface: #27272a;
  --assistant-line: #3f3f46;
  --assistant-text: #fafafa;
  --assistant-soft: #d4d4d8;
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 2500;
  color: var(--assistant-text);
  font-family: inherit;
}

.assistant-launcher {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--assistant-accent);
  color: #fff;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 850;
  transition: transform 180ms ease, background 180ms ease;
}

.assistant-launcher:hover {
  background: var(--assistant-accent-dark);
  transform: translateY(-2px);
}

.assistant-launcher:focus-visible,
.assistant-close:focus-visible,
.assistant-quick-reply:focus-visible,
.assistant-send:focus-visible,
.assistant-input:focus-visible {
  outline: 3px solid rgba(251, 113, 133, 0.55);
  outline-offset: 3px;
}

.assistant-launcher-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.assistant-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  display: grid;
  grid-template-rows: auto minmax(180px, 1fr) auto auto;
  width: min(390px, calc(100vw - 28px));
  height: min(630px, calc(100vh - 116px));
  overflow: hidden;
  border: 1px solid var(--assistant-line);
  border-radius: 24px;
  background: var(--assistant-panel);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.58);
  transform-origin: bottom right;
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
}

.assistant-panel[hidden] {
  display: grid;
  visibility: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
}

.assistant-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 17px 18px;
  border-bottom: 1px solid var(--assistant-line);
  background: #111113;
}

.assistant-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 6px;
  overflow: hidden;
  place-items: center;
  border-radius: 14px;
  background: var(--assistant-accent);
  color: #fff;
  font-weight: 950;
}

.assistant-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.assistant-title strong,
.assistant-title small {
  display: block;
}

.assistant-title strong {
  font-size: 0.92rem;
}

.assistant-title small {
  margin-top: 3px;
  color: var(--assistant-soft);
  font-size: 0.73rem;
}

.assistant-close {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 1.35rem;
}

.assistant-close:hover {
  background: var(--assistant-surface);
}

.assistant-messages {
  overflow-y: auto;
  padding: 18px;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.assistant-message {
  width: fit-content;
  max-width: 88%;
  margin: 0 0 12px;
  padding: 11px 13px;
  border-radius: 16px 16px 16px 5px;
  background: var(--assistant-surface);
  color: var(--assistant-text);
  font-size: 0.86rem;
  line-height: 1.55;
  white-space: pre-line;
}

.assistant-message-user {
  margin-left: auto;
  border-radius: 16px 16px 5px 16px;
  background: var(--assistant-accent);
  color: #fff;
}

.assistant-message a {
  color: #fda4af;
  font-weight: 800;
}

.assistant-message-user a {
  color: #fff;
}

.assistant-quick-replies {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 16px 12px;
  scrollbar-width: thin;
}

.assistant-quick-reply {
  flex: 0 0 auto;
  padding: 9px 12px;
  border: 1px solid var(--assistant-line);
  border-radius: 999px;
  background: transparent;
  color: var(--assistant-text);
  cursor: pointer;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 750;
}

.assistant-quick-reply:hover {
  border-color: var(--assistant-accent);
  background: rgba(225, 29, 72, 0.12);
}

.assistant-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
  padding: 13px;
  border-top: 1px solid var(--assistant-line);
  background: #111113;
}

.assistant-input {
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--assistant-line);
  border-radius: 14px;
  background: var(--assistant-surface);
  color: var(--assistant-text);
  font: inherit;
  font-size: 0.86rem;
}

.assistant-input::placeholder {
  color: #a1a1aa;
}

.assistant-send {
  min-width: 76px;
  height: 46px;
  padding: 0 14px;
  border: 0;
  border-radius: 14px;
  background: var(--assistant-accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 850;
}

.assistant-send:disabled {
  cursor: wait;
  opacity: 0.65;
}

.assistant-disclaimer {
  margin: 0;
  padding: 0 16px 12px;
  background: #111113;
  color: #a1a1aa;
  font-size: 0.66rem;
  line-height: 1.4;
  text-align: center;
}

[data-theme="light"] .comuna-assistant {
  --assistant-panel: #fff;
  --assistant-surface: #f4f4f5;
  --assistant-line: #e4e4e7;
  --assistant-text: #18181b;
  --assistant-soft: #52525b;
}

[data-theme="light"] .assistant-header,
[data-theme="light"] .assistant-form,
[data-theme="light"] .assistant-disclaimer {
  background: #fafafa;
}

[data-theme="light"] .assistant-close {
  color: #18181b;
}

@media (max-width: 640px) {
  .comuna-assistant {
    right: 14px;
    bottom: 14px;
  }

  .assistant-launcher-label {
    display: none;
  }

  .assistant-launcher {
    width: 58px;
    padding: 0;
  }

  .assistant-panel {
    position: fixed;
    inset: 12px;
    width: auto;
    height: auto;
    border-radius: 22px;
    transform-origin: bottom center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .assistant-panel,
  .assistant-launcher,
  .assistant-messages {
    transition: none;
    scroll-behavior: auto;
  }
}
