.nano-float {
  --n-ink: #151515;
  --n-paper: #f2f0e8;
  --n-blue: #2456f5;
  --n-orange: #ff6038;
  --n-acid: #d9ff43;
  position: fixed;
  z-index: 180;
  right: 18px;
  bottom: 18px;
  font-family: 'DM Sans', Arial, sans-serif;
}
.nano-float,
.nano-float * {
  box-sizing: border-box;
}
.nano-actions {
  width: max-content;
  margin-left: auto;
  padding: 5px;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(21, 21, 21, 0.24);
  border-radius: 17px;
  box-shadow: 0 10px 30px rgba(21, 21, 21, 0.12);
}
.nano-whatsapp,
.nano-chat-toggle {
  height: 47px;
  border: 0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 13px;
  text-decoration: none;
  font-size: 10px;
  font-weight: 700;
  transition:
    transform 0.2s,
    background 0.2s;
}
.nano-whatsapp {
  background: #25d366;
  color: #0d2616;
}
.nano-whatsapp svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}
.nano-chat-toggle {
  position: relative;
  background: var(--n-ink);
  color: #fff;
  cursor: pointer;
}
.nano-chat-toggle img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}
.nano-chat-toggle i {
  position: absolute;
  right: -2px;
  top: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--n-acid);
  border: 2px solid var(--n-ink);
}
.nano-whatsapp:hover,
.nano-chat-toggle:hover {
  transform: translateY(-2px);
}
/* Blue as an accent ring rather than a fill, so the silver mark stays readable. */
.nano-chat-toggle:hover {
  background: #232323;
  box-shadow: 0 0 0 2px rgba(36, 86, 245, 0.55);
}
.nano-chat {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(400px, calc(100vw - 24px));
  height: min(590px, calc(100dvh - 30px));
  background: var(--n-paper);
  border: 1.5px solid var(--n-ink);
  border-radius: 25px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow:
    5px 6px 0 var(--n-orange),
    0 25px 65px rgba(21, 21, 21, 0.22);
  opacity: 0;
  visibility: hidden;
  transform: translateY(24px) scale(0.96);
  transform-origin: bottom right;
  transition:
    opacity 0.24s,
    transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0.24s;
}
.nano-chat.open {
  opacity: 1;
  visibility: visible;
  transform: none;
}
.nano-chat > header {
  height: 78px;
  padding: 0 15px;
  background: #fff;
  color: var(--n-ink);
  border-bottom: 1px solid var(--n-ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  position: relative;
}
.nano-chat > header::after {
  content: '✦';
  position: absolute;
  right: 70px;
  top: 17px;
  color: var(--n-blue);
  font-size: 30px;
  opacity: 0.16;
}
.nano-chat > header > div {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 1;
  min-width: 0;
}
/* The brand mark is a silver gradient, which goes muddy on saturated blue.
   Ink keeps it legible and matches the logo chip used elsewhere on the site. */
.nano-chat > header img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  background: var(--n-ink);
  border: 1px solid var(--n-ink);
  border-radius: 12px;
  padding: 6px;
}
.nano-chat > header span {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.nano-chat > header b {
  font: 600 18px 'Space Grotesk';
  letter-spacing: -0.5px;
}
.nano-chat > header small {
  font-size: 7px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: #666;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nano-chat > header small i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #49c878;
  box-shadow: 0 0 0 4px rgba(73, 200, 120, 0.14);
}
.nano-close {
  position: relative;
  z-index: 1;
  width: 37px;
  height: 37px;
  border: 1px solid var(--n-ink);
  border-radius: 10px;
  background: var(--n-ink);
  color: #fff;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.2s;
  flex: none;
}
.nano-close:hover {
  background: var(--n-orange);
  transform: rotate(5deg);
}
.nano-messages {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 13px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background-color: #f6f3eb;
  background-image: radial-gradient(rgba(36, 86, 245, 0.08) 1px, transparent 1px);
  background-size: 18px 18px;
}
.nano-messages::before {
  content: '';
  position: absolute;
  right: -60px;
  top: 40%;
  width: 145px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(36, 86, 245, 0.09);
  box-shadow:
    0 0 0 28px rgba(36, 86, 245, 0.022),
    0 0 0 56px rgba(36, 86, 245, 0.015);
  pointer-events: none;
}
.nano-message {
  position: relative;
  z-index: 1;
  display: flex;
  min-width: 0;
}
/* The bubble is a div, not a p, so assistant replies can contain lists. */
.nano-bubble {
  max-width: 84%;
  overflow-wrap: anywhere;
  margin: 0;
  border: 1px solid rgba(21, 21, 21, 0.22);
  border-radius: 16px;
  padding: 11px 13px;
  font-size: 13px;
  line-height: 1.48;
  box-shadow: 0 4px 10px rgba(21, 21, 21, 0.04);
}
/* Visitor messages are inserted as text, so newlines need preserving. */
.nano-message.user .nano-bubble,
.nano-message.typing .nano-bubble {
  white-space: pre-wrap;
}
.nano-message.bot .nano-bubble {
  background: #fff;
  border-bottom-left-radius: 4px;
  border-left: 3px solid var(--n-blue);
}
.nano-message.user {
  justify-content: flex-end;
}
.nano-message.user .nano-bubble {
  background: var(--n-blue);
  color: #fff;
  border-color: var(--n-ink);
  border-bottom-right-radius: 4px;
}
.nano-message.typing .nano-bubble {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #777;
  font-size: 10px;
  background: #fff;
  border-left-color: var(--n-acid);
}

/* ------------------------------------------------ formatted reply content --- */

.nano-bubble > *:first-child {
  margin-top: 0;
}
.nano-bubble > *:last-child {
  margin-bottom: 0;
}
.nano-bubble p {
  margin: 0 0 8px;
}
.nano-bubble ul,
.nano-bubble ol {
  margin: 0 0 8px;
  padding-left: 17px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.nano-bubble li {
  padding-left: 2px;
}
.nano-bubble li::marker {
  color: var(--n-blue);
}
.nano-bubble strong {
  font-weight: 700;
}
.nano-bubble .nano-h {
  display: block;
  margin: 0 0 6px;
  font-size: 13px;
}
.nano-bubble code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(21, 21, 21, 0.07);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
}
.nano-bubble a {
  color: var(--n-blue);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.nano-message.user .nano-bubble a,
.nano-message.user .nano-bubble code {
  color: #fff;
}

/* Blocks stay hidden until the typewriter reaches their first character. */
.nano-bubble .nano-pending {
  visibility: hidden;
}

/* Animated dots while the reply is being generated. */
.nano-dots {
  display: inline-flex;
  gap: 3px;
}
.nano-dots b {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  animation: nanoDot 1.05s infinite ease-in-out;
}
.nano-dots b:nth-child(2) {
  animation-delay: 0.16s;
}
.nano-dots b:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes nanoDot {
  0%,
  70%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  35% {
    opacity: 1;
    transform: translateY(-3px);
  }
}
.nano-quick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 9px 10px;
  border-top: 1px solid rgba(21, 21, 21, 0.13);
  background: var(--n-paper);
  flex: none;
  min-width: 0;
}
.nano-quick[hidden] {
  display: none !important;
}
.nano-quick button {
  min-width: 0;
  border: 1px solid rgba(21, 21, 21, 0.25);
  border-radius: 11px;
  background: #fff;
  padding: 9px;
  text-align: left;
  font-size: 8px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  white-space: normal;
  overflow-wrap: anywhere;
  transition:
    background 0.2s,
    transform 0.2s;
}
.nano-quick button:last-child {
  grid-column: 1/-1;
}
.nano-quick button i {
  font-style: normal;
  color: var(--n-blue);
  margin-right: 4px;
}
.nano-quick button:hover {
  background: var(--n-acid);
  transform: translateY(-1px);
}
.nano-form {
  margin: 0 10px 8px;
  border: 1.5px solid var(--n-ink);
  border-radius: 15px;
  background: #fff;
  padding: 6px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  flex: none;
  min-width: 0;
}
.nano-form:focus-within {
  box-shadow: 0 4px 0 var(--n-blue);
}
.nano-form textarea {
  min-width: 0;
  flex: 1;
  min-height: 39px;
  max-height: 100px;
  border: 0;
  outline: 0;
  resize: none;
  padding: 10px 6px;
  background: transparent;
  font:
    13px/1.4 'DM Sans',
    Arial;
}
.nano-form > button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--n-ink);
  border-radius: 10px;
  background: var(--n-acid);
  color: var(--n-ink);
  font-size: 21px;
  font-weight: 700;
  cursor: pointer;
  flex: none;
  transition:
    transform 0.2s,
    background 0.2s;
}
.nano-form > button:hover {
  transform: rotate(5deg);
  background: var(--n-orange);
}
.nano-form > button:disabled {
  opacity: 0.45;
}
.nano-chat > footer {
  padding: 2px 12px 9px;
  font-size: 7px;
  color: #777;
  text-align: center;
  flex: none;
}
@media (max-width: 600px) {
  .nano-float {
    right: 9px;
    bottom: 9px;
  }
  .nano-actions {
    padding: 4px;
    border-radius: 15px;
  }
  .nano-whatsapp,
  .nano-chat-toggle {
    width: 45px;
    height: 45px;
    padding: 0;
    border-radius: 11px;
  }
  .nano-actions span {
    display: none;
  }
  .nano-chat {
    position: fixed;
    inset: auto 8px 8px;
    height: min(70dvh, 560px);
    width: auto;
    max-height: none;
    border-radius: 23px;
    transform: translateY(105%);
    transform-origin: center;
    box-shadow:
      4px 5px 0 var(--n-orange),
      0 22px 55px rgba(21, 21, 21, 0.25);
  }
  .nano-chat.open {
    transform: none;
  }
  .nano-chat > header {
    height: 72px;
  }
  .nano-chat > header img {
    width: 39px;
    height: 39px;
  }
  .nano-messages {
    padding: 13px 11px;
  }
  .nano-bubble {
    max-width: 90%;
    font-size: 13px;
  }
  .nano-quick {
    padding: 7px;
  }
  .nano-form {
    margin-inline: 7px;
  }
  .nano-whatsapp:hover,
  .nano-chat-toggle:hover {
    transform: none;
  }
}
@media (max-width: 360px) {
  .nano-chat {
    inset: auto 4px 4px;
    height: min(74dvh, 560px);
  }
  .nano-quick {
    grid-template-columns: 1fr;
  }
  .nano-quick button:last-child {
    grid-column: auto;
  }
}
@media (prefers-reduced-motion: reduce) {
  .nano-chat,
  .nano-whatsapp,
  .nano-chat-toggle,
  .nano-quick button {
    transition: none !important;
  }
  /* The reply is rendered in full instead of typed; see floating-assistant.js. */
  .nano-dots b {
    animation: none;
    opacity: 0.6;
  }
}
