/* Cosgral live chat — matches site language (Inter / Plex Mono, ink on black) */
.cg-chat-root {
  --cg-chat-bg: rgba(8, 8, 8, 0.92);
  --cg-chat-ink: #f5f5f5;
  --cg-chat-muted: #888;
  --cg-chat-border: rgba(255, 255, 255, 0.1);
  --cg-chat-fill: #f5f5f5;
  --cg-chat-on-fill: #030303;
  --cg-chat-bubble-agent: rgba(255, 255, 255, 0.07);
  --cg-chat-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --cg-chat-font: "Inter", system-ui, sans-serif;
  --cg-chat-mono: "Satoshi", system-ui, sans-serif;
  --cg-chat-fab: 2.85rem;
  position: fixed;
  left: 50%;
  right: auto;
  bottom: calc(2.35rem + env(safe-area-inset-bottom, 0px));
  z-index: 12050;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--cg-chat-font);
  color: var(--cg-chat-ink);
  pointer-events: none;
  -webkit-font-smoothing: antialiased;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translate3d(0, 1.55rem, 0);
  transition:
    opacity 0.55s var(--cg-chat-ease),
    transform 0.65s var(--cg-chat-ease),
    visibility 0s linear 0.65s;
}

.cg-chat-root.is-chat-visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translate3d(0, 0, 0);
  transition:
    opacity 0.55s var(--cg-chat-ease),
    transform 0.65s var(--cg-chat-ease),
    visibility 0s linear 0s;
}

.cg-chat-root.is-chat-visible .cg-chat-launcher,
.cg-chat-root.is-chat-visible .cg-chat-panel {
  pointer-events: auto;
}

html[data-theme="light"] .cg-chat-root {
  --cg-chat-bg: rgba(250, 250, 250, 0.94);
  --cg-chat-ink: #030303;
  --cg-chat-muted: #666;
  --cg-chat-border: rgba(0, 0, 0, 0.12);
  --cg-chat-fill: #030303;
  --cg-chat-on-fill: #f5f5f5;
  --cg-chat-bubble-agent: rgba(0, 0, 0, 0.06);
}

.cg-chat-root * {
  box-sizing: border-box;
}

.cg-chat-launcher,
.cg-chat-panel {
  pointer-events: none;
}

/* —— Launcher: live 3D cube + LIVE CZAT —— */
.cg-chat-launcher {
  --cg-chat-cube: 4.25rem;
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.22rem;
  width: auto;
  min-width: var(--cg-chat-cube);
  height: auto;
  padding: 0.15rem 0.4rem 0.1rem;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--cg-chat-ink);
  cursor: pointer;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition: transform 0.4s var(--cg-chat-ease), opacity 0.25s ease;
  overflow: visible;
}

html[data-theme="light"] .cg-chat-launcher {
  background: transparent;
  box-shadow: none;
}

.cg-chat-launcher:hover {
  transform: scale(1.06);
}

.cg-chat-launcher:active {
  transform: scale(0.97);
}

/* Open: keep cube, dim it (mega-menu style), white X on face */
.cg-chat-launcher[aria-expanded="true"] {
  background: transparent;
  box-shadow: none;
  border: none;
  color: #fff;
}

.cg-chat-launcher__stage {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--cg-chat-cube);
  height: var(--cg-chat-cube);
  flex-shrink: 0;
  pointer-events: none;
  overflow: visible;
}

.cg-chat-cube-canvas {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  overflow: visible;
  transition: filter 0.55s var(--cg-chat-ease), opacity 0.55s var(--cg-chat-ease);
}

.cg-chat-launcher[aria-expanded="true"] .cg-chat-cube-canvas {
  filter: brightness(0.42);
  opacity: 0.88;
}

.cg-chat-label {
  font-family: var(--cg-chat-mono);
  font-size: 0.52rem;
  font-weight: 400;
  letter-spacing: 0.16em;
  line-height: 1;
  text-transform: uppercase;
  color: rgba(245, 245, 245, 0.72);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.35s var(--cg-chat-ease), transform 0.45s var(--cg-chat-ease);
}

html[data-theme="light"] .cg-chat-label {
  color: rgba(3, 3, 3, 0.62);
}

.cg-chat-launcher[aria-expanded="true"] .cg-chat-label {
  opacity: 0;
  transform: translateY(0.35rem);
  pointer-events: none;
}

.cg-chat-launcher__icon {
  display: grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  flex-shrink: 0;
}

.cg-chat-launcher__icon--close {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  margin: auto;
  color: #ffffff;
  opacity: 0;
  transform: scale(0.72) rotate(-12deg);
  transition:
    opacity 0.45s var(--cg-chat-ease),
    transform 0.55s var(--cg-chat-ease);
  z-index: 2;
  pointer-events: none;
}

.cg-chat-launcher__icon--close svg {
  width: 1.55rem;
  height: 1.55rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 10px rgba(0, 0, 0, 0.55));
}

.cg-chat-launcher[aria-expanded="true"] .cg-chat-launcher__icon--close {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.cg-chat-badge {
  position: absolute;
  top: -0.1rem;
  right: -0.15rem;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: var(--cg-chat-fill);
  color: var(--cg-chat-on-fill);
  font-family: var(--cg-chat-mono);
  font-size: 0.58rem;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.05rem;
  text-align: center;
  text-transform: none;
  box-shadow: 0 0 0 2px rgba(8, 8, 8, 0.9);
}

/* —— Panel —— */
.cg-chat-panel {
  position: absolute;
  left: 50%;
  right: auto;
  bottom: calc(var(--cg-chat-cube, 3.35rem) + 1.65rem);
  width: min(22.5rem, calc(100vw - 1.5rem));
  height: min(30rem, calc(100dvh - 7.5rem));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--cg-chat-border);
  border-radius: 1.15rem;
  background: var(--cg-chat-bg);
  backdrop-filter: blur(22px) saturate(1.15);
  -webkit-backdrop-filter: blur(22px) saturate(1.15);
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
  transform-origin: center bottom;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-50%) translate3d(0, 1.1rem, 0) scale(0.92);
  filter: blur(6px);
  transition:
    opacity 0.42s var(--cg-chat-ease),
    transform 0.52s var(--cg-chat-ease),
    filter 0.42s var(--cg-chat-ease),
    visibility 0s linear 0.42s;
}

.cg-chat-panel.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translate3d(0, 0, 0) scale(1);
  filter: blur(0);
  transition:
    opacity 0.42s var(--cg-chat-ease),
    transform 0.52s var(--cg-chat-ease),
    filter 0.42s var(--cg-chat-ease),
    visibility 0s linear 0s;
}

.cg-chat-panel.is-open .cg-chat-head,
.cg-chat-panel.is-open .cg-chat-msgs,
.cg-chat-panel.is-open .cg-chat-form {
  animation: cg-chat-rise 0.55s var(--cg-chat-ease) both;
}

.cg-chat-panel.is-open .cg-chat-head {
  animation-delay: 0.06s;
}

.cg-chat-panel.is-open .cg-chat-msgs {
  animation-delay: 0.12s;
}

.cg-chat-panel.is-open .cg-chat-form {
  animation-delay: 0.18s;
}

@keyframes cg-chat-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cg-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 1rem 1.1rem 0.9rem;
  border-bottom: 1px solid var(--cg-chat-border);
}

.cg-chat-head__brand {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.cg-chat-head__eyebrow {
  font-family: var(--cg-chat-mono);
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cg-chat-muted);
}

.cg-chat-head strong {
  font-size: 0.95rem;
  font-weight: 300;
  letter-spacing: -0.02em;
  color: var(--cg-chat-ink);
}

.cg-chat-status {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--cg-chat-ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cg-chat-ink) 18%, transparent);
  flex-shrink: 0;
  animation: cg-chat-pulse 2.4s var(--cg-chat-ease) infinite;
}

@keyframes cg-chat-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.55;
    transform: scale(0.85);
  }
}

.cg-chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.05rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

html[data-theme="light"] .cg-chat-msgs {
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

.cg-chat-bubble {
  max-width: 84%;
  padding: 0.7rem 0.85rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  animation: cg-chat-bubble-in 0.4s var(--cg-chat-ease) both;
}

@keyframes cg-chat-bubble-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.cg-chat-bubble--visitor {
  align-self: flex-end;
  background: var(--cg-chat-fill);
  color: var(--cg-chat-on-fill);
  border-bottom-right-radius: 0.3rem;
}

.cg-chat-bubble--agent {
  align-self: flex-start;
  background: var(--cg-chat-bubble-agent);
  color: var(--cg-chat-ink);
  border: 1px solid var(--cg-chat-border);
  border-bottom-left-radius: 0.3rem;
}

.cg-chat-empty {
  margin: auto;
  text-align: center;
  max-width: 14rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  align-items: center;
}

.cg-chat-empty__mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: 1px solid var(--cg-chat-border);
  display: grid;
  place-items: center;
  opacity: 0.7;
}

.cg-chat-empty__mark svg {
  width: 1rem;
  height: 1rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cg-chat-empty__label {
  font-family: var(--cg-chat-mono);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cg-chat-muted);
}

.cg-chat-empty__text {
  font-size: 0.82rem;
  line-height: 1.5;
  color: color-mix(in srgb, var(--cg-chat-ink) 62%, transparent);
}

.cg-chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.85rem;
  border-top: 1px solid var(--cg-chat-border);
}

.cg-chat-form input {
  flex: 1;
  min-width: 0;
  height: 2.65rem;
  border: 1px solid var(--cg-chat-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--cg-chat-ink);
  padding: 0 1rem;
  font-family: var(--cg-chat-font);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.25s ease, background 0.25s ease;
}

html[data-theme="light"] .cg-chat-form input {
  background: rgba(0, 0, 0, 0.03);
}

.cg-chat-form input::placeholder {
  color: var(--cg-chat-muted);
}

.cg-chat-form input:focus {
  border-color: color-mix(in srgb, var(--cg-chat-ink) 45%, transparent);
  background: rgba(255, 255, 255, 0.06);
}

.cg-chat-form button {
  height: 2.65rem;
  padding: 0 1.05rem;
  border: 1px solid var(--cg-chat-fill);
  border-radius: 999px;
  background: var(--cg-chat-fill);
  color: var(--cg-chat-on-fill);
  font-family: var(--cg-chat-mono);
  font-size: 0.62rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.35s var(--cg-chat-ease), opacity 0.2s ease, filter 0.2s ease;
}

.cg-chat-form button:hover:not(:disabled) {
  transform: scale(1.04);
  filter: brightness(1.06);
}

.cg-chat-form button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Hide when megamenu / lightbox open */
html.is-nav-open .cg-chat-root,
html.is-lightbox-open .cg-chat-root,
body.is-nav-open .cg-chat-root,
.cg-nav-open .cg-chat-root {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

@media (max-width: 900px) {
  .cg-chat-root {
    --cg-chat-fab: 3.45rem;
    bottom: calc(3.35rem + env(safe-area-inset-bottom, 0px));
  }

  .cg-chat-launcher {
    --cg-chat-cube: 4.85rem;
    gap: 0.18rem;
  }

  .cg-chat-label {
    font-size: 0.56rem;
    letter-spacing: 0.14em;
  }
}

@media (max-width: 640px) {
  .cg-chat-panel {
    width: min(100vw - 1.25rem, 22.5rem);
    height: min(70dvh, 30rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cg-chat-root,
  .cg-chat-root.is-chat-visible {
    transition-duration: 0.01ms !important;
    transform: translateX(-50%);
  }
}

/* Glass cube: the page behind it, softened inside its outline */
.cg-chat-lens {
  position: absolute;
  inset: 0;
  z-index: 0;
  -webkit-backdrop-filter: blur(1.4px) saturate(1.35) brightness(1.07) contrast(1.04);
  backdrop-filter: blur(1.4px) saturate(1.35) brightness(1.07) contrast(1.04);
  pointer-events: none;
}
.cg-chat-launcher__stage.has-glass-cube .cg-chat-cube-canvas {
  position: relative;
  z-index: 1;
}
.cg-chat-launcher__stage.has-glass-cube .cg-chat-launcher__icon--close {
  z-index: 2;
}
