.nibblefy-assistant {
  --assistant-primary: #412e8f;
  --assistant-primary-strong: #4526b1;
  --assistant-primary-soft: #f1edff;
  --assistant-accent: #3ebfb7;
  --assistant-surface: #ffffff;
  --assistant-surface-muted: #f2f5fb;
  --assistant-text: #1c1c1c;
  --assistant-text-muted: #626270;
  --assistant-border: #e1e4ec;
  --assistant-focus: #176c67;
  --assistant-shadow: 0 24px 70px rgba(36, 23, 84, 0.24);
  --assistant-font: "Roboto", Arial, sans-serif;
  position: fixed;
  z-index: 9998;
  right: 24px;
  bottom: 24px;
  font-family: var(--assistant-font);
  color: var(--assistant-text);
  line-height: 1.5;
}

/* Privacy choices remain the first interaction when the consent banner is open. */
.consent-banner:not([hidden]) ~ .nibblefy-assistant {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.nibblefy-assistant *,
.nibblefy-assistant *::before,
.nibblefy-assistant *::after {
  box-sizing: border-box;
}

.assistant-launcher {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 0 10px auto;
  padding: 0;
  border: 0;
  border-radius: 22px 22px 6px 22px;
  color: #fff;
  background: linear-gradient(145deg, var(--assistant-primary), var(--assistant-primary-strong));
  box-shadow: 0 12px 32px rgba(69, 38, 177, 0.34);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.assistant-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 38px rgba(69, 38, 177, 0.4);
}

.assistant-launcher[aria-expanded="true"] {
  opacity: 0;
  pointer-events: none;
}

.assistant-launcher__icon {
  width: 30px;
  height: 24px;
  border: 2px solid currentColor;
  border-radius: 10px 10px 3px 10px;
}

.assistant-launcher__icon::before {
  content: "";
  display: block;
  width: 5px;
  height: 5px;
  margin: 8px auto 0;
  border-radius: 50%;
  background: currentColor;
  box-shadow: -8px 0 currentColor, 8px 0 currentColor;
}

.assistant-launcher__status {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--assistant-accent);
}

.assistant-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(400px, calc(100vw - 32px));
  height: min(650px, calc(100vh - 48px));
  overflow: hidden;
  border: 1px solid rgba(69, 38, 177, 0.12);
  border-radius: 26px 26px 8px 26px;
  background: var(--assistant-surface);
  box-shadow: var(--assistant-shadow);
  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(14px) scale(0.97);
  pointer-events: none;
}

.assistant-header {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 78px;
  padding: 15px 16px 15px 18px;
  color: #fff;
  background:
    radial-gradient(circle at 88% 15%, rgba(62, 191, 183, 0.45), transparent 29%),
    linear-gradient(135deg, #412e8f 0%, #5435be 100%);
}

.assistant-header__mark {
  display: grid;
  place-items: center;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  margin-right: 12px;
  border: 0;
  border-radius: 0;
  overflow: visible;
  background: transparent;
  font: 700 17px/1 "Jost", sans-serif;
}

.assistant-header__avatar {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 5px 8px rgba(16, 9, 45, 0.28));
}

.assistant-header__identity {
  min-width: 0;
  flex: 1;
}

.assistant-header__title {
  display: block;
  overflow: hidden;
  margin: 0;
  color: #fff;
  font: 600 17px/1.25 "Jost", sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-header__status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
}

.assistant-header__status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #68e0d7;
  box-shadow: 0 0 0 3px rgba(104, 224, 215, 0.16);
}

.assistant-header__actions {
  display: flex;
  gap: 3px;
  margin-left: 8px;
}

.assistant-icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: transparent;
  cursor: pointer;
}

.assistant-icon-button:hover {
  background: rgba(255, 255, 255, 0.13);
}

.assistant-icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.assistant-conversation {
  overflow-x: hidden;
  overflow-y: auto;
  padding: 22px 18px 18px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.96)),
    radial-gradient(circle at 0 0, #dfd7fd, transparent 34%),
    radial-gradient(circle at 100% 100%, #d8f6f3, transparent 30%);
  overscroll-behavior: contain;
  scrollbar-color: #cacdd3 transparent;
  scrollbar-width: thin;
}

.assistant-message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 0 0 16px;
}

.assistant-message--user {
  align-items: flex-end;
}

.assistant-message__bubble {
  max-width: 84%;
  padding: 11px 14px;
  border: 1px solid var(--assistant-border);
  border-radius: 5px 17px 17px 17px;
  color: var(--assistant-text);
  background: var(--assistant-surface-muted);
  box-shadow: 0 5px 14px rgba(28, 28, 28, 0.045);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.assistant-message--user .assistant-message__bubble {
  border-color: transparent;
  border-radius: 17px 5px 17px 17px;
  color: #fff;
  background: linear-gradient(145deg, #5435be, #412e8f);
}

.assistant-message__time {
  margin-top: 5px;
  padding: 0 4px;
  color: var(--assistant-text-muted);
  font-size: 11px;
}

.assistant-message__actions,
.assistant-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 94%;
  margin-top: 9px;
}

.assistant-quick-actions {
  margin-bottom: 18px;
}

.assistant-action {
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid rgba(69, 38, 177, 0.22);
  border-radius: 999px;
  color: var(--assistant-primary);
  background: #fff;
  font: 600 12px/1.2 var(--assistant-font);
  cursor: pointer;
}

.assistant-action:hover {
  border-color: var(--assistant-primary);
  background: var(--assistant-primary-soft);
}

.assistant-action--primary {
  border-color: var(--assistant-primary);
  color: #fff;
  background: var(--assistant-primary);
}

.assistant-action--primary:hover {
  color: #fff;
  background: var(--assistant-primary-strong);
}

.assistant-thinking {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 62px;
  min-height: 42px;
}

.assistant-thinking__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8d8e99;
  animation: assistant-dot 1.15s ease-in-out infinite;
}

.assistant-thinking__dot:nth-child(2) { animation-delay: 130ms; }
.assistant-thinking__dot:nth-child(3) { animation-delay: 260ms; }

@keyframes assistant-dot {
  0%, 60%, 100% { opacity: 0.45; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-5px); }
}

.assistant-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 9px;
  padding: 12px;
  border-top: 1px solid var(--assistant-border);
  background: rgba(255, 255, 255, 0.98);
}

.assistant-composer__input {
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid #cacdd3;
  border-radius: 13px;
  color: var(--assistant-text);
  background: #fff;
  font: 400 14px/1.4 var(--assistant-font);
}

.assistant-composer__input::placeholder {
  color: #6f6f7c;
}

.assistant-send {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 14px 14px 4px 14px;
  color: #fff;
  background: linear-gradient(145deg, var(--assistant-primary), var(--assistant-primary-strong));
  cursor: pointer;
}

.assistant-send:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.assistant-send svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.assistant-launcher:focus-visible,
.assistant-icon-button:focus-visible,
.assistant-action:focus-visible,
.assistant-composer__input:focus-visible,
.assistant-send:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px var(--assistant-focus);
}

/* Keep the existing back-to-top control in the same right-side column. */
.scroll-top.show.show-active {
  right: 34px;
  bottom: 112px;
}

.assistant-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 575px) {
  .nibblefy-assistant {
    right: 12px;
    bottom: 12px;
  }

  .assistant-launcher {
    width: 58px;
    height: 58px;
    margin-bottom: 8px;
  }

  .scroll-top.show.show-active {
    right: 21px;
    bottom: 90px;
  }

  .assistant-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    transform-origin: bottom center;
  }

  .assistant-header {
    min-height: 72px;
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .assistant-conversation {
    padding: 20px 14px 16px;
  }

  .assistant-message__bubble {
    max-width: 86%;
  }

  .assistant-composer {
    padding: 10px max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }
}

@media (prefers-reduced-motion: reduce) {
  .assistant-launcher,
  .assistant-panel,
  .assistant-thinking__dot {
    transition: none;
    animation: none;
  }

  .assistant-thinking__dot:nth-child(2) { opacity: 0.68; }
  .assistant-thinking__dot:nth-child(3) { opacity: 0.92; }
}
