/* Embeddable chatbot — cb- prefix. Glassmorphic, restrained “luxury” default. */
@import url("../brand-tokens.css");

.cb-root {
  --cb-chrome: #0f172a;
  --cb-chrome-soft: rgba(15, 23, 42, 0.88);
  --cb-accent: var(--brand-accent, #3b4dff);
  --cb-accent-2: #93a4ff;
  --cb-accent-soft: var(--brand-accent-muted, rgba(59, 77, 255, 0.14));
  --cb-accent-ring: rgba(59, 77, 255, 0.45);
  --cb-glass: rgba(255, 255, 255, 0.68);
  --cb-glass-strong: rgba(255, 255, 255, 0.82);
  --cb-glass-subtle: rgba(255, 255, 255, 0.45);
  --cb-glass-border: rgba(255, 255, 255, 0.72);
  --cb-glass-border-outer: rgba(15, 23, 42, 0.08);
  --cb-header-bg: rgba(255, 255, 255, 0.38);
  --cb-header-text: #0f172a;
  --cb-launcher-bg: rgba(255, 255, 255, 0.72);
  /* Launcher visible on any page background (light + dark) */
  --cb-launcher-ring-light: rgba(255, 255, 255, 0.98);
  --cb-launcher-ring-dark: rgba(15, 23, 42, 0.5);
  --cb-launcher-shadow-elev: 0 12px 32px rgba(15, 23, 42, 0.28), 0 4px 12px rgba(0, 0, 0, 0.14);
  --cb-launcher-shadow-ring: 0 0 0 2px var(--cb-launcher-ring-light), 0 0 0 5px var(--cb-launcher-ring-dark);
  --cb-surface: rgba(255, 255, 255, 0.78);
  --cb-surface-elevated: rgba(255, 255, 255, 0.9);
  --cb-surface-chat: rgba(241, 245, 249, 0.72);
  --cb-border: rgba(15, 23, 42, 0.06);
  --cb-border-strong: rgba(15, 23, 42, 0.1);
  --cb-text: #0f172a;
  --cb-text-muted: #64748b;
  --cb-user-bubble: rgba(15, 23, 42, 0.9);
  --cb-shadow-lg: 0 32px 64px -20px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.5) inset;
  --cb-shadow-md: 0 16px 40px -12px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(255, 255, 255, 0.55) inset;
  --cb-radius-panel-tl: 1.375rem;
  --cb-radius-panel-tr: 1.375rem;
  --cb-radius-panel-br: 1.375rem;
  --cb-radius-panel-bl: 0.5rem;
  --cb-radius-bubble: 1rem;
  --cb-font: var(--brand-font-sans, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);
  --cb-blur-panel: blur(22px) saturate(160%);
  --cb-blur-header: blur(18px) saturate(140%);
  --cb-blur-tile: blur(14px) saturate(150%);

  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 99999;
  font-family: var(--cb-font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--cb-text);
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

.cb-root *,
.cb-root *::before,
.cb-root *::after {
  box-sizing: border-box;
}

@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
  .cb-root {
    --cb-glass: rgba(252, 252, 253, 0.97);
    --cb-glass-strong: #ffffff;
    --cb-glass-subtle: rgba(248, 250, 252, 0.92);
    --cb-header-bg: #f8fafc;
    --cb-launcher-bg: #ffffff;
    --cb-surface-chat: #f1f5f9;
  }

  .cb-panel,
  .cb-header,
  .cb-messages,
  .cb-msg--bot .cb-bubble,
  .cb-option,
  .cb-launcher,
  .cb-launcher--with-mascot {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}

/* Launcher — perfect circle (text or mascot); double ring reads on light + dark UIs */
.cb-launcher {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  min-width: 3.5rem;
  min-height: 3.5rem;
  padding: 0;
  border-radius: 50%;
  background: var(--cb-launcher-bg);
  color: var(--cb-header-text);
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.03em;
  font-size: 0.75rem;
  text-transform: uppercase;
  cursor: pointer;
  border: none;
  box-shadow: var(--cb-launcher-shadow-elev), var(--cb-shadow-md), var(--cb-launcher-shadow-ring);
  backdrop-filter: var(--cb-blur-tile);
  -webkit-backdrop-filter: var(--cb-blur-tile);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.cb-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.32), 0 6px 16px rgba(0, 0, 0, 0.16), var(--cb-shadow-md), 0 0 0 2px var(--cb-launcher-ring-light), 0 0 0 6px var(--cb-launcher-ring-dark);
}

.cb-launcher:focus-visible {
  outline: 2px solid var(--cb-accent-ring);
  outline-offset: 5px;
}

.cb-launcher--with-mascot {
  padding: 0;
  text-transform: none;
  font-size: inherit;
  letter-spacing: normal;
  background: #ffffff;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: var(--cb-launcher-shadow-elev), var(--cb-launcher-shadow-ring), inset 0 0 0 1px rgba(15, 23, 42, 0.06);
}

.cb-launcher--with-mascot:hover {
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.32), 0 6px 16px rgba(0, 0, 0, 0.16), 0 0 0 2px var(--cb-launcher-ring-light), 0 0 0 6px var(--cb-launcher-ring-dark), inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.cb-launcher__mascot {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.cb-launcher__label {
  padding: 0.75rem 1rem;
}

.cb-launcher--with-mascot .cb-launcher__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Peek launcher — Clippy-style assistant at bottom-right */
.cb-launcher--peek {
  position: relative;
  width: clamp(5rem, 17vw, 6.25rem);
  height: clamp(6.25rem, 22vw, 7.75rem);
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  overflow: visible;
  transition: none;
}

/* Puppet layer — character + grounded shadow (Office-assistant feel) */
.cb-launcher--peek .cb-launcher__puppet {
  position: absolute;
  right: -0.12rem;
  bottom: 0;
  width: clamp(5.25rem, 18vw, 6.75rem);
  height: clamp(6.5rem, 24vw, 8.25rem);
  pointer-events: none;
  z-index: 1;
}

.cb-launcher--peek .cb-launcher__shadow {
  position: absolute;
  left: 14%;
  right: 8%;
  bottom: 0.05rem;
  height: 0.5rem;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(15, 23, 42, 0.28) 0%, rgba(15, 23, 42, 0) 72%);
  transform-origin: center center;
  opacity: 0;
  z-index: 0;
  will-change: transform, opacity;
}

.cb-launcher--peek .cb-launcher__character {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
  object-position: 100% 100%;
  display: block;
  border-radius: 0;
  z-index: 1;
  transform-origin: 92% 92%;
  filter: drop-shadow(0 10px 22px rgba(15, 23, 42, 0.2));
  opacity: 0;
  will-change: transform, opacity;
  transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1), filter 0.35s ease;
}

.cb-launcher--peek .cb-launcher__character--entering {
  animation: mascotPeekEnter 0.95s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.cb-launcher--peek .cb-launcher__puppet:has(.cb-launcher__character--entering) .cb-launcher__shadow {
  animation: mascotPeekShadowEnter 0.95s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.cb-launcher--peek .cb-launcher__character--idle {
  opacity: 1;
  animation: mascotPeekLife 11s ease-in-out infinite;
}

.cb-launcher--peek .cb-launcher__puppet:has(.cb-launcher__character--idle) .cb-launcher__shadow {
  opacity: 1;
  animation: mascotPeekShadowLife 11s ease-in-out infinite;
}

.cb-launcher--peek .cb-launcher__character--entering.cb-launcher__character--idle {
  animation: mascotPeekEnter 0.95s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Clippy-style speech balloon replaced by .cb-peek-hint card */
.cb-peek-hint {
  position: absolute;
  right: calc(100% - 0.2rem);
  bottom: clamp(5.5rem, 18vw, 7.1rem);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.28rem;
  width: min(15.5rem, calc(100vw - 5.5rem));
  max-width: 15.5rem;
  margin: 0;
  padding: 0.7rem 0.85rem 0.65rem;
  border: 1px solid color-mix(in srgb, var(--cb-accent, #106e3c) 22%, transparent);
  border-radius: 1rem 1rem 0.2rem 1rem;
  background:
    linear-gradient(180deg, #ffffff 0%, #f7fbf8 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 14px 36px rgba(15, 23, 42, 0.16),
    0 0 0 1px rgba(15, 23, 42, 0.04);
  color: #12301f;
  text-align: left;
  cursor: pointer;
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
  opacity: 0;
  transform: translate(12px, 8px) scale(0.92);
  pointer-events: none;
  transition:
    opacity 0.28s ease,
    transform 0.32s cubic-bezier(0.22, 1.15, 0.36, 1),
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}

.cb-peek-hint::after {
  content: "";
  position: absolute;
  right: -0.42rem;
  bottom: 0.72rem;
  width: 0.72rem;
  height: 0.72rem;
  background: #f7fbf8;
  border-right: 1px solid color-mix(in srgb, var(--cb-accent, #106e3c) 22%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--cb-accent, #106e3c) 22%, transparent);
  transform: rotate(-45deg);
  pointer-events: none;
}

.cb-peek-hint.is-visible {
  opacity: 1;
  transform: translate(0, 0) scale(1);
  pointer-events: auto;
  animation: mascotHintPop 0.5s cubic-bezier(0.22, 1.15, 0.36, 1) both;
}

.cb-peek-hint:hover,
.cb-peek-hint:focus-visible {
  border-color: color-mix(in srgb, var(--cb-accent-2, #e9850b) 55%, transparent);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 16px 40px rgba(15, 23, 42, 0.18),
    0 0 0 1px color-mix(in srgb, var(--cb-accent-2, #e9850b) 25%, transparent);
}

.cb-peek-hint:focus-visible {
  outline: 2px solid var(--cb-accent-ring, #e9850b);
  outline-offset: 3px;
}

.cb-peek-hint__eyebrow {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cb-accent, #106e3c);
  line-height: 1.2;
}

.cb-peek-hint__msg {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.015em;
  color: #163225;
}

.cb-peek-hint__cta {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--cb-accent-2, #e9850b);
}

.cb-peek-hint__cta::after {
  content: "→";
  font-size: 0.8em;
  transition: transform 0.2s ease;
}

.cb-peek-hint:hover .cb-peek-hint__cta::after,
.cb-peek-hint:focus-visible .cb-peek-hint__cta::after {
  transform: translateX(2px);
}

.cb-launcher--peek.cb-launcher--nudge .cb-launcher__puppet {
  animation: mascotLauncherNudge 0.72s cubic-bezier(0.33, 1, 0.48, 1);
}

.cb-launcher__character--wave {
  animation: mascotPeekWaveOnce 2.05s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

.cb-launcher__character--attention {
  animation: mascotPeekAttentionOnce 1.85s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

.cb-launcher__character--talk {
  animation: mascotPeekTalkOnce 1.15s cubic-bezier(0.33, 1, 0.48, 1) !important;
}

.cb-launcher--peek .cb-launcher__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.cb-launcher--peek:hover,
.cb-launcher--peek:focus-visible {
  transform: none;
  box-shadow: none;
}

.cb-launcher--peek:focus-visible {
  outline: 2px solid var(--cb-accent-ring, #3b4dff);
  outline-offset: 4px;
  border-radius: 0.5rem;
}

.cb-launcher--peek:hover .cb-launcher__character--idle,
.cb-launcher--peek:focus-visible .cb-launcher__character--idle {
  animation: none;
  transform: translate(-7px, -10px) rotate(-3.5deg) scale(1.035);
  filter: drop-shadow(0 14px 26px rgba(15, 23, 42, 0.24));
}

.cb-launcher--peek:hover .cb-launcher__puppet:has(.cb-launcher__character--idle) .cb-launcher__shadow,
.cb-launcher--peek:focus-visible .cb-launcher__puppet:has(.cb-launcher__character--idle) .cb-launcher__shadow {
  animation: none;
  transform: scaleX(0.88) scaleY(0.92);
  opacity: 0.55;
}

/* Open chat — assistant stays visible, frozen while panel is open */
.cb-root.cb-root--open .cb-launcher--peek {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  cursor: pointer;
}

.cb-root.cb-root--open .cb-launcher--peek .cb-launcher__character,
.cb-root.cb-root--open .cb-launcher--peek .cb-launcher__shadow,
.cb-root.cb-root--open .cb-launcher--peek .cb-launcher__puppet {
  animation: none !important;
}

.cb-root.cb-root--open .cb-launcher--peek .cb-launcher__character {
  transform: none;
  opacity: 1;
  will-change: auto;
  filter: drop-shadow(0 8px 18px rgba(15, 23, 42, 0.18));
}

.cb-root.cb-root--open .cb-launcher--peek .cb-launcher__shadow {
  opacity: 0.45;
  transform: none;
}

.cb-root.cb-root--open .cb-launcher--peek:hover .cb-launcher__character,
.cb-root.cb-root--open .cb-launcher--peek:focus-visible .cb-launcher__character {
  transform: none;
  filter: drop-shadow(0 8px 18px rgba(15, 23, 42, 0.18));
}

.cb-root.cb-root--open .cb-launcher--peek.cb-launcher--hint::before,
.cb-root.cb-root--open .cb-launcher--peek.cb-launcher--hint::after,
.cb-root.cb-root--open .cb-peek-hint {
  display: none !important;
}

.cb-launcher--peek ~ .cb-panel {
  bottom: calc(clamp(6.25rem, 22vw, 7.75rem) + 1rem);
}

/* Rise into view — slide up from desk edge (Clippy entrance) */
@keyframes mascotPeekEnter {
  0% {
    opacity: 0;
    transform: translate(12px, 52px) rotate(5deg) scale(0.78);
    filter: drop-shadow(0 2px 8px rgba(15, 23, 42, 0.06));
  }
  55% {
    opacity: 1;
    transform: translate(-5px, -8px) rotate(-2.5deg) scale(1.03);
    filter: drop-shadow(0 16px 28px rgba(15, 23, 42, 0.22));
  }
  78% {
    transform: translate(1px, 2px) rotate(0.6deg) scale(0.99);
  }
  100% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
    filter: drop-shadow(0 10px 22px rgba(15, 23, 42, 0.2));
  }
}

@keyframes mascotPeekShadowEnter {
  0% {
    opacity: 0;
    transform: scaleX(0.35) scaleY(0.5);
  }
  55% {
    opacity: 0.75;
    transform: scaleX(1.08) scaleY(1.05);
  }
  100% {
    opacity: 0.5;
    transform: scaleX(1) scaleY(1);
  }
}

/* Idle — breathe, then glance toward the user (classic assistant loop) */
@keyframes mascotPeekLife {
  0%,
  42%,
  100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  14% {
    transform: translateY(-2px) rotate(-0.6deg) scale(1.006);
  }
  28% {
    transform: translateY(-3px) rotate(-1deg) scale(1.01);
  }
  58% {
    transform: translate(-5px, -6px) rotate(-2.8deg) scale(1.02);
  }
  66% {
    transform: translate(-6px, -7px) rotate(-3deg) scale(1.022);
  }
  74% {
    transform: translate(-3px, -4px) rotate(-1.2deg) scale(1.008);
  }
  86% {
    transform: translateY(-2px) rotate(0.5deg) scale(1.004);
  }
}

@keyframes mascotPeekShadowLife {
  0%,
  42%,
  100% {
    transform: scaleX(1) scaleY(1);
    opacity: 0.5;
  }
  28% {
    transform: scaleX(0.92) scaleY(0.88);
    opacity: 0.42;
  }
  58%,
  66% {
    transform: scaleX(0.82) scaleY(0.75);
    opacity: 0.38;
  }
  86% {
    transform: scaleX(0.94) scaleY(0.9);
    opacity: 0.46;
  }
}

@keyframes mascotPeekWaveOnce {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  12% {
    transform: translate(-4px, -12px) rotate(-8deg) scale(1.04);
  }
  28% {
    transform: translate(-6px, -14px) rotate(7deg) scale(1.05);
  }
  44% {
    transform: translate(-4px, -11px) rotate(-6deg) scale(1.04);
  }
  60% {
    transform: translate(-5px, -13px) rotate(5deg) scale(1.045);
  }
  78% {
    transform: translate(-2px, -5px) rotate(-1.5deg) scale(1.015);
  }
  100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
}

@keyframes mascotPeekAttentionOnce {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  18% {
    transform: translate(-11px, -13px) rotate(-4.5deg) scale(1.045);
  }
  32%,
  62% {
    transform: translate(-12px, -14px) rotate(-5deg) scale(1.05);
  }
  48% {
    transform: translate(-11px, -12px) rotate(-4deg) scale(1.048);
  }
  82% {
    transform: translate(-4px, -5px) rotate(-1.5deg) scale(1.015);
  }
  100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
}

@keyframes mascotPeekTalkOnce {
  0%,
  100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  15% {
    transform: translate(-3px, -6px) rotate(-2.5deg) scale(1.02);
  }
  32% {
    transform: translate(-1px, -3px) rotate(2deg) scale(1.012);
  }
  48% {
    transform: translate(-3px, -7px) rotate(-2deg) scale(1.025);
  }
  64% {
    transform: translate(-1px, -2px) rotate(1.5deg) scale(1.01);
  }
  80% {
    transform: translate(-2px, -5px) rotate(-1deg) scale(1.018);
  }
}

@keyframes mascotHintPop {
  0% {
    opacity: 0;
    transform: translate(14px, 10px) scale(0.78);
  }
  50% {
    opacity: 1;
    transform: translate(-3px, -3px) scale(1.03);
  }
  72% {
    transform: translate(0, 0) scale(1.01);
  }
  100% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
}

@keyframes mascotHintTailPop {
  0% {
    opacity: 0;
    transform: translate(6px, 4px) scale(0.6);
  }
  55% {
    opacity: 1;
    transform: translate(0, 0) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
}

@keyframes mascotLauncherNudge {
  0%,
  100% {
    transform: translate(0, 0);
  }
  22% {
    transform: translate(-3px, -4px);
  }
  48% {
    transform: translate(2px, -1px);
  }
  72% {
    transform: translate(-2px, -3px);
  }
}

/* Panel — reads clearly on busy host pages */
.cb-panel {
  position: absolute;
  right: 0;
  bottom: calc(3.5rem + 1rem);
  width: min(24rem, calc(100vw - 2.5rem));
  /* Explicit height so the message column stays bounded and scrolls internally
     (max-height alone lets the panel grow with content until the cap). */
  height: min(40rem, 88vh);
  max-height: min(40rem, 88vh);
  display: flex;
  flex-direction: column;
  background: var(--cb-glass);
  border-radius: var(--cb-radius-panel-tl) var(--cb-radius-panel-tr) var(--cb-radius-panel-br) var(--cb-radius-panel-bl);
  border: 1px solid var(--cb-glass-border);
  box-shadow: var(--cb-shadow-lg), 0 0 0 1px var(--cb-glass-border-outer), 0 0 0 3px rgba(255, 255, 255, 0.55), 0 0 0 4px rgba(15, 23, 42, 0.1), 0 28px 56px -18px rgba(15, 23, 42, 0.22);
  backdrop-filter: var(--cb-blur-panel);
  -webkit-backdrop-filter: var(--cb-blur-panel);
  overflow: hidden;
}

.cb-panel[hidden] {
  display: none !important;
}

.cb-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.95rem 1.05rem 1rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72) 0%, var(--cb-header-bg) 100%);
  border-bottom: 1px solid rgba(15, 23, 42, 0.07);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.55) inset;
  backdrop-filter: var(--cb-blur-header);
  -webkit-backdrop-filter: var(--cb-blur-header);
}

.cb-header__brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  flex: 1;
}

/* Mascot in header — round crop for simple icons; peek uses full character below */
.cb-mascot {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: none;
  box-shadow: 0 0 0 2px var(--cb-launcher-ring-light), 0 0 0 4px var(--cb-launcher-ring-dark), 0 10px 24px rgba(15, 23, 42, 0.14);
  transform-origin: center bottom;
  will-change: transform;
}

/* Full-body mascot in chat panel — larger, not circle-cropped */
.cb-root--peek-mascot .cb-header {
  padding: 0.65rem 1rem 0.7rem;
}

.cb-root--peek-mascot .cb-header__brand {
  gap: 0.65rem;
}

.cb-root--peek-mascot .cb-mascot {
  width: 3.15rem;
  height: 3.85rem;
  border-radius: 0.55rem;
  object-fit: contain;
  object-position: center 100%;
  background: linear-gradient(165deg, rgba(230, 233, 37, 0.12) 0%, rgba(255, 255, 255, 0.72) 55%, rgba(244, 246, 255, 0.9) 100%);
  box-shadow:
    0 0 0 2px var(--cb-launcher-ring-light),
    0 0 0 3px var(--cb-launcher-ring-dark),
    0 6px 14px rgba(15, 23, 42, 0.1);
}

.cb-root--peek-mascot .cb-msg__avatar {
  width: 3.85rem;
  height: 4.65rem;
  border-radius: 0.6rem;
  object-fit: contain;
  object-position: center 100%;
  background: linear-gradient(165deg, rgba(230, 233, 37, 0.1) 0%, rgba(255, 255, 255, 0.8) 100%);
  box-shadow:
    0 0 0 1.5px var(--cb-launcher-ring-light),
    0 0 0 3px var(--cb-launcher-ring-dark),
    0 6px 16px rgba(15, 23, 42, 0.1);
}

.cb-root--peek-mascot .cb-msg--bot {
  align-items: flex-end;
  gap: 0.7rem;
}

.cb-root--peek-mascot .cb-msg--bot.cb-msg--has-mascot .cb-msg__body {
  max-width: calc(100% - 5rem);
}

.cb-root--open .cb-mascot {
  animation: mascotMascotIdle 7s ease-in-out infinite;
}

.cb-mascot--hello,
.cb-mascot--talk {
  animation-duration: 0.92s !important;
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1) !important;
  animation-iteration-count: 1 !important;
}

.cb-mascot--hello {
  animation-name: mascotMascotHello !important;
}

.cb-mascot--talk {
  animation-name: mascotMascotTalk !important;
}

@keyframes mascotMascotIdle {
  0%,
  100% {
    transform: translateY(0) rotate(0deg) scale(1);
  }
  40% {
    transform: translateY(-2px) rotate(-1deg) scale(1.012);
  }
  70% {
    transform: translateY(-3px) rotate(0.8deg) scale(1.016);
  }
}

@keyframes mascotMascotHello {
  0% {
    transform: scale(0.9) rotate(-5deg) translateY(4px);
    opacity: 0.88;
  }
  40% {
    transform: scale(1.06) rotate(2deg) translateY(-3px);
    opacity: 1;
  }
  65% {
    transform: scale(0.98) rotate(-0.5deg) translateY(0);
  }
  100% {
    transform: scale(1) rotate(0deg) translateY(0);
    opacity: 1;
  }
}

@keyframes mascotMascotTalk {
  0%,
  100% {
    transform: translateY(0) rotate(0deg) scale(1);
  }
  20% {
    transform: translateY(-2px) rotate(-3deg) scale(1.04);
  }
  45% {
    transform: translateY(-1px) rotate(2.5deg) scale(1.03);
  }
  70% {
    transform: translateY(-2px) rotate(-2deg) scale(1.035);
  }
}

.cb-title {
  font-weight: 650;
  font-size: 0.96875rem;
  letter-spacing: -0.03em;
  line-height: 1.25;
  color: var(--cb-header-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cb-close {
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.55);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: rgba(15, 23, 42, 0.42);
  padding: 0.4rem 0.5rem;
  min-width: 2.25rem;
  min-height: 2.25rem;
  border-radius: 0.55rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.cb-close:hover {
  color: var(--cb-header-text);
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(255, 255, 255, 0.75);
}

.cb-close:focus-visible {
  outline: 2px solid var(--cb-accent-ring);
  outline-offset: 1px;
}

.cb-messages {
  flex: 1 1 auto;
  min-height: 11rem;
  overflow-y: auto;
  padding: 1.15rem 1.05rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  background: var(--cb-surface-chat);
  border-top: 1px solid rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px) saturate(130%);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
  scroll-padding-bottom: 0.5rem;
}

.cb-msg {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  max-width: 100%;
}

.cb-msg--bot {
  justify-content: flex-start;
}

.cb-msg--user {
  justify-content: flex-end;
}

.cb-msg__avatar {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: none;
  box-shadow: 0 0 0 1.5px var(--cb-launcher-ring-light), 0 0 0 3px var(--cb-launcher-ring-dark), 0 6px 14px rgba(15, 23, 42, 0.12);
  align-self: flex-end;
  margin-bottom: 0.12rem;
  transform-origin: center bottom;
}

.cb-msg__avatar--pop {
  animation: mascotAvatarPop 0.62s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes mascotAvatarPop {
  0% {
    transform: scale(0.72) translateY(6px);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.05) translateY(-2px);
    opacity: 1;
  }
  75% {
    transform: scale(0.98) translateY(1px);
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.cb-msg--user .cb-msg__avatar {
  display: none;
}

.cb-msg__body {
  display: flex;
  flex-direction: column;
  max-width: 90%;
}

.cb-msg--bot.cb-msg--has-mascot .cb-msg__body {
  max-width: calc(100% - 2.85rem);
}

.cb-msg--user .cb-msg__body {
  align-items: flex-end;
}

.cb-bubble {
  max-width: 100%;
  padding: 0.75rem 1.05rem;
  border-radius: var(--cb-radius-bubble);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9375rem;
  line-height: 1.55;
}

.cb-bubble strong {
  font-weight: 650;
}

.cb-msg--bot .cb-bubble {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-bottom-left-radius: 0.4rem;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.85) inset, 0 10px 28px -10px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
}

.cb-msg--user .cb-bubble {
  background: var(--cb-user-bubble);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom-right-radius: 0.4rem;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 12px 28px -10px rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
}

.cb-options {
  flex: 0 0 auto;
  min-height: 0;
  padding: 0.55rem 1.05rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42) 0%, rgba(248, 250, 252, 0.75) 100%);
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  overflow: hidden;
}

/* Cap quick choices so the message column keeps room; list scrolls inside */
.cb-options--many {
  height: 11.5rem;
  max-height: 11.5rem;
}

.cb-options-drawer {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 0.65rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.5);
  overflow: hidden;
}

.cb-options-drawer[hidden] {
  display: none !important;
}

.cb-options-drawer__summary {
  flex: 0 0 auto;
  padding: 0.42rem 0.65rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--cb-text-muted);
  user-select: none;
}

.cb-options-drawer__body {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0 0.45rem 0.5rem;
  flex: 1 1 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scroll-padding-bottom: 0.35rem;
  -webkit-overflow-scrolling: touch;
}

.cb-options--many .cb-options-drawer__body {
  /* Explicit cap so overflow scroll always engages (flex % alone is unreliable) */
  max-height: 9rem;
}

.cb-options-drawer__body .cb-option {
  padding: 0.5rem 0.8rem;
  min-height: 2.15rem;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.cb-options--many .cb-options-drawer__body .cb-option {
  min-height: 2rem;
  padding: 0.42rem 0.75rem;
  font-size: 0.8125rem;
}

.cb-options-below {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex-shrink: 0;
}

.cb-options-below:empty {
  display: none;
}

.cb-option {
  width: 100%;
  text-align: left;
  padding: 0.72rem 1.15rem;
  min-height: 2.75rem;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.92);
  font: inherit;
  font-weight: 600;
  font-size: 0.90625rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  color: var(--cb-text);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75) inset, 0 4px 12px -4px rgba(15, 23, 42, 0.08);
  transition: color 0.15s, background 0.15s, border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}

.cb-option:hover {
  background: var(--cb-chrome-soft);
  color: #f8fafc;
  border-color: rgba(15, 23, 42, 0.45);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35), 0 0 0 4px var(--cb-launcher-ring-dark), 0 14px 32px -10px rgba(15, 23, 42, 0.28);
  transform: translateY(-1px);
}

.cb-option:active {
  transform: translateY(0);
}

.cb-option:focus-visible {
  outline: 2px solid var(--cb-accent-ring);
  outline-offset: 2px;
}

.cb-option--ghost {
  background: rgba(248, 250, 252, 0.92);
  color: var(--cb-text-muted);
  font-weight: 600;
}

.cb-option--ghost:hover {
  background: rgba(241, 245, 249, 0.98);
  color: var(--cb-text);
  border-color: rgba(15, 23, 42, 0.14);
}

.cb-footer {
  flex-shrink: 0;
  padding: 0.55rem 1.05rem 1.05rem;
  background: rgba(255, 255, 255, 0.38);
  border-top: 1px solid rgba(15, 23, 42, 0.05);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.cb-freeform {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.cb-suggested-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
}

.cb-suggested-prompts[hidden] {
  display: none !important;
}

.cb-suggested-prompt {
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  background: rgba(255, 255, 255, 0.88);
  color: var(--cb-text-muted);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.cb-suggested-prompt:hover {
  border-color: var(--cb-accent-ring);
  color: var(--cb-text);
  background: #fff;
}

.cb-suggested-prompt:focus-visible {
  outline: 2px solid var(--cb-accent-ring);
  outline-offset: 2px;
}

.cb-bubble--typing {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  min-height: 1.25rem;
  padding: 0.55rem 0.75rem;
}

.cb-typing-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--cb-text-muted);
  opacity: 0.45;
  animation: cbTypingDot 1.1s ease-in-out infinite;
}

.cb-typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.cb-typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes cbTypingDot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.cb-freeform__input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 999px;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.94);
  color: var(--cb-text);
  font: inherit;
  font-size: 0.85rem;
}

.cb-freeform__input:focus-visible {
  outline: 2px solid var(--cb-accent-ring);
  outline-offset: 1px;
}

.cb-freeform__send {
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  background: rgba(255, 255, 255, 0.94);
  color: var(--cb-text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.cb-restart {
  width: 100%;
  padding: 0.45rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cb-text-muted);
  cursor: pointer;
  transition: color 0.15s;
}

.cb-restart:hover {
  color: var(--cb-chrome);
}

.cb-restart:focus-visible {
  outline: 2px solid var(--cb-accent-ring);
  outline-offset: 2px;
}

.cb-restart[hidden] {
  display: none !important;
}

/* Lead capture form (optional step.form in bot JSON) */
.cb-lead-form-wrap {
  width: 100%;
}

.cb-lead-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 100%;
}

.cb-honey {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.cb-lead-form__field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.cb-lead-form__label {
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--cb-text-muted);
}

.cb-lead-form__input,
.cb-lead-form__textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border-radius: 0.55rem;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.95);
  font: inherit;
  font-size: 0.875rem;
  color: var(--cb-text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.cb-lead-form__textarea {
  min-height: 5rem;
  resize: vertical;
}

.cb-lead-form__input:focus,
.cb-lead-form__textarea:focus {
  border-color: rgba(15, 23, 42, 0.28);
  box-shadow: 0 0 0 3px var(--cb-accent-soft);
}

.cb-lead-form__error {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #b91c1c;
  padding: 0.35rem 0.25rem 0;
}

.cb-lead-form__setup {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--cb-text-muted);
}

.cb-lead-form__actions {
  margin-top: 0.15rem;
}

.cb-lead-form__submit {
  margin-top: 0.15rem;
}

.cb-quote-follow {
  width: 100%;
  margin-top: 0.15rem;
}

a.cb-quote-follow__btn {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
}

.cb-root--error .cb-panel--error {
  position: relative;
  bottom: auto;
  right: auto;
  height: auto;
  max-height: none;
  padding: 1.25rem;
  border-radius: var(--cb-radius-panel-tl) var(--cb-radius-panel-tr) var(--cb-radius-panel-br) var(--cb-radius-panel-bl);
  background: var(--cb-glass-strong);
  backdrop-filter: var(--cb-blur-panel);
  -webkit-backdrop-filter: var(--cb-blur-panel);
  border: 1px solid var(--cb-glass-border);
}

.cb-error {
  margin: 0;
  color: #b91c1c;
  font-size: 0.9rem;
}

@media (prefers-reduced-motion: reduce) {
  .cb-launcher,
  .cb-option {
    transition: none;
  }

  .cb-launcher:hover,
  .cb-option:hover,
  .cb-option:active {
    transform: none;
  }

  .cb-launcher--peek .cb-launcher__puppet,
  .cb-launcher--peek .cb-launcher__character,
  .cb-launcher--peek .cb-launcher__shadow,
  .cb-launcher--peek .cb-launcher__character--entering,
  .cb-launcher--peek .cb-launcher__character--idle {
    animation: none !important;
    opacity: 1;
    transform: none;
    transition: none;
  }

  .cb-launcher--peek:hover .cb-launcher__character--idle,
  .cb-launcher--peek:focus-visible .cb-launcher__character--idle {
    animation: none;
    transform: none;
    filter: drop-shadow(0 10px 22px rgba(15, 23, 42, 0.2));
  }

  .cb-launcher--peek.cb-launcher--hint::before,
  .cb-launcher--peek.cb-launcher--hint::after,
  .cb-launcher--peek.cb-launcher--nudge .cb-launcher__puppet,
  .cb-peek-hint.is-visible {
    animation: none !important;
  }

  .cb-peek-hint.is-visible {
    opacity: 1;
    transform: none;
  }

  .cb-root--open .cb-mascot,
  .cb-mascot--hello,
  .cb-mascot--talk,
  .cb-msg__avatar--pop,
  .cb-launcher__character--wave,
  .cb-launcher__character--attention,
  .cb-launcher__character--talk {
    animation: none !important;
  }

  .cb-typing-dot {
    animation: none;
    opacity: 0.65;
  }
}
