body.chat-open {
  overflow: hidden;
}

.chat {
  position: fixed;
  right: 26px;
  bottom: 28px;
  z-index: 200;
  opacity: 0;
  transform: translateY(14px) scale(0.92);
  pointer-events: none;
  transition: opacity 0.45s var(--ease), transform 0.45s var(--ease);
}
.chat.is-ready {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
@media (max-width: 560px) {
  .chat {
    right: 16px;
    bottom: 18px;
  }
}

.chatfab {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--brand);
  color: #06180e;
  border: none;
  box-shadow: 0 16px 34px -12px rgba(61, 181, 74, 0.7);
  transition: transform 0.4s var(--ease), background 0.3s, box-shadow 0.3s;
}
.chatfab:hover {
  background: var(--lime);
  transform: translateY(-3px);
}
.chatfab:active {
  transform: translateY(0);
}
.chatfab.is-attn {
  animation: chatfabpulse 1.8s var(--ease) 3;
}
.chatfab svg {
  width: 26px;
  height: 26px;
  stroke-width: 1.9;
}
.chatfab__open, .chatfab__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chatfab__close {
  display: none;
}
.chatfab__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 21px;
  height: 21px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e1503a;
  color: #fff;
  font-family: "Google Sans", system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 21px;
  text-align: center;
  border: 2px solid var(--bone);
  box-shadow: 0 5px 12px -3px rgba(0, 0, 0, 0.4);
}
.chatfab__badge[hidden] {
  display: none;
}

.chat.is-open .chatfab {
  background: var(--forest);
  color: var(--on-dark);
  box-shadow: 0 16px 34px -14px rgba(15, 42, 30, 0.7);
}
.chat.is-open .chatfab:hover {
  background: var(--forest-2);
}
.chat.is-open .chatfab__open {
  display: none;
}
.chat.is-open .chatfab__close {
  display: inline-flex;
}
.chat.is-open .chatnudge {
  display: none;
}
@media (max-width: 560px) {
  .chat.is-open {
    transform: none;
  }
}

.chatnudge {
  position: absolute;
  right: 2px;
  bottom: 80px;
  z-index: 1;
  display: flex;
  align-items: stretch;
  width: max-content;
  max-width: min(300px, 100vw - 44px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 26px 50px -24px rgba(15, 42, 30, 0.5);
  transform-origin: bottom right;
  animation: chatnudgein 0.55s var(--ease) both;
}
.chatnudge[hidden] {
  display: none;
}
.chatnudge__open {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 8px 13px 14px;
  background: transparent;
  border: none;
  text-align: left;
  border-radius: 18px 0 0 18px;
}
.chatnudge__avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--forest);
  color: var(--brand);
  display: grid;
  place-items: center;
}
.chatnudge__avatar svg {
  width: 20px;
  height: 20px;
}
.chatnudge__text {
  font-size: 0.86rem;
  line-height: 1.4;
  color: var(--ink);
}
.chatnudge__text strong {
  display: block;
  font-family: "Google Sans", system-ui, sans-serif;
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  color: var(--brand-d);
  margin-bottom: 1px;
}
.chatnudge__close {
  flex: 0 0 auto;
  align-self: flex-start;
  width: 26px;
  height: 26px;
  margin: 7px 7px 0 0;
  border-radius: 50%;
  border: none;
  background: var(--cream);
  color: var(--ink-soft);
  display: grid;
  place-items: center;
  transition: background 0.2s, color 0.2s;
}
.chatnudge__close:hover {
  background: var(--sand);
  color: var(--ink);
}
.chatnudge__close svg {
  width: 14px;
  height: 14px;
}
.chatnudge::after {
  content: "";
  position: absolute;
  right: 26px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: var(--paper);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transform: rotate(45deg);
}
@media (max-width: 560px) {
  .chatnudge {
    bottom: 76px;
    max-width: calc(100vw - 32px);
  }
}

.chatpanel {
  position: absolute;
  right: 0;
  bottom: 80px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  width: 420px;
  max-width: calc(100vw - 32px);
  height: min(640px, 100vh - 128px);
  background: var(--bone);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 44px 84px -30px rgba(15, 42, 30, 0.58);
  overflow: hidden;
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}
.chat.is-open .chatpanel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.chatpanel__head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 16px 18px;
  background: radial-gradient(140% 120% at 0% 0%, var(--forest-3), transparent 60%), var(--forest);
  color: var(--on-dark);
}
.chatpanel__avatar {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--brand);
  color: #06180e;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 3px rgba(61, 181, 74, 0.22);
}
.chatpanel__avatar svg {
  width: 22px;
  height: 22px;
}
.chatpanel__id {
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}
.chatpanel__id strong {
  display: block;
  font-family: "Google Sans", system-ui, sans-serif;
  font-weight: 500;
  font-size: 0.98rem;
}
.chatpanel__id span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  color: var(--on-dark-soft);
}
.chatpanel__live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 0 rgba(155, 212, 92, 0.5);
  animation: chatlive 2.4s infinite;
}
.chatpanel__tools {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chatpanel__close, .chatpanel__act {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line-light);
  background: transparent;
  color: var(--on-dark);
  display: grid;
  place-items: center;
  transition: background 0.25s, border-color 0.25s;
}
.chatpanel__close:hover, .chatpanel__act:hover {
  background: rgba(246, 242, 233, 0.08);
  border-color: var(--bone);
}
.chatpanel__close svg {
  width: 20px;
  height: 20px;
}
.chatpanel__act svg {
  width: 17px;
  height: 17px;
}
.chatpanel__body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 18px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  background: radial-gradient(120% 55% at 100% 0%, rgba(61, 181, 74, 0.05), transparent 62%), var(--bone);
}
.chatpanel__body::-webkit-scrollbar {
  width: 9px;
}
.chatpanel__body::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 99px;
  border: 3px solid var(--bone);
}
.chatpanel__form {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 12px 9px;
  border-top: 1px solid var(--line);
  background: var(--bone);
}
.chatpanel__form input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 16px;
  font: inherit;
  font-size: 0.9rem;
  background: var(--paper);
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chatpanel__form input::placeholder {
  color: var(--ink-mute);
}
.chatpanel__form input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(61, 181, 74, 0.16);
}
.chatpanel__form button {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--brand);
  color: #06180e;
  display: grid;
  place-items: center;
  transition: background 0.25s, transform 0.3s var(--ease);
}
.chatpanel__form button:hover {
  background: var(--lime);
}
.chatpanel__form button:active {
  transform: scale(0.94);
}
.chatpanel__form button svg {
  width: 19px;
  height: 19px;
}
.chatpanel__foot {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 16px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 0.67rem;
  line-height: 1;
  color: var(--ink-mute);
  background: var(--bone);
}
.chatpanel__foot svg {
  width: 11px;
  height: 11px;
}
@media (max-width: 560px) {
  .chatpanel {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    height: 100dvh;
    border: none;
    border-radius: 0;
    opacity: 1;
    transform: translateY(100%);
    transition: transform 0.42s var(--ease);
  }
  .chat.is-open .chatpanel {
    transform: translateY(0);
  }
  .chatpanel__head {
    padding-top: max(16px, env(safe-area-inset-top));
  }
  .chatpanel__foot {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}

.chatmsg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 90%;
  animation: chatmsgin 0.34s var(--ease) both;
}
.chatmsg__avatar {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--forest);
  color: var(--brand);
  display: grid;
  place-items: center;
}
.chatmsg__avatar svg {
  width: 16px;
  height: 16px;
}
.chatmsg__main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}
.chatmsg__bubble {
  padding: 11px 14px;
  border-radius: 17px;
  font-size: 0.92rem;
  line-height: 1.55;
  word-break: break-word;
}
.chatmsg__bubble p {
  margin: 0 0 8px;
}
.chatmsg__bubble p:last-child {
  margin-bottom: 0;
}
.chatmsg__bubble ul, .chatmsg__bubble ol {
  margin: 7px 0;
  padding-left: 20px;
}
.chatmsg__bubble li {
  margin: 3px 0;
}
.chatmsg__bubble li::marker {
  color: var(--brand-d);
}
.chatmsg__bubble strong {
  font-weight: 600;
}
.chatmsg__bubble em {
  font-style: italic;
}
.chatmsg__bubble a {
  color: var(--brand-d);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.chatmsg__bubble code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--cream);
  padding: 1px 5px;
  border-radius: 6px;
}
.chatmsg__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px;
}
.chatmsg__time {
  flex: 0 0 auto;
  font-size: 0.68rem;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}
.chatmsg__acts {
  display: flex;
  gap: 4px;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
}
.chatmsg:hover .chatmsg__acts, .chatmsg:focus-within .chatmsg__acts {
  opacity: 1;
  transform: none;
}
.chatmsg__act {
  width: 25px;
  height: 25px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bone);
  color: var(--ink-soft);
  display: grid;
  place-items: center;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.chatmsg__act:hover {
  color: var(--brand-d);
  border-color: var(--brand);
  background: var(--paper);
}
.chatmsg__act.is-done {
  color: var(--brand-d);
  border-color: var(--brand);
}
.chatmsg__act svg {
  width: 13px;
  height: 13px;
  stroke-width: 2;
}
.chatmsg--bot {
  align-self: flex-start;
}
.chatmsg--bot .chatmsg__bubble {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line-2);
  border-bottom-left-radius: 5px;
}
.chatmsg--user {
  align-self: flex-end;
}
.chatmsg--user .chatmsg__main {
  align-items: flex-end;
}
.chatmsg--user .chatmsg__meta {
  flex-direction: row-reverse;
}
.chatmsg--user .chatmsg__bubble {
  background: var(--forest);
  color: var(--on-dark);
  border-bottom-right-radius: 5px;
}
.chatmsg--user .chatmsg__bubble a {
  color: var(--lime);
}
.chatmsg--user .chatmsg__bubble li::marker {
  color: var(--lime);
}
.chatmsg--user .chatmsg__bubble code {
  background: rgba(255, 255, 255, 0.14);
  color: var(--on-dark);
}

.chatchips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
}

.chatchip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bone);
  font-family: "Google Sans", system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--brand-d);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.chatchip:hover {
  border-color: var(--brand);
  background: var(--paper);
  transform: translateY(-1px);
}
.chatchip:active {
  transform: translateY(0);
}
.chatchip svg {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}

.chattyping {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 2px;
}
.chattyping span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-mute);
  animation: chattype 1.3s infinite ease-in-out both;
}
.chattyping span:nth-child(2) {
  animation-delay: 0.16s;
}
.chattyping span:nth-child(3) {
  animation-delay: 0.32s;
}

@media (max-width: 560px) {
  .chatpanel__body {
    padding: 16px 14px 12px;
    gap: 15px;
  }
  .chatmsg {
    max-width: 92%;
  }
  .chatmsg__bubble {
    font-size: 0.95rem;
  }
  .chatmsg__acts {
    opacity: 1;
    transform: none;
  }
  .chatmsg__act {
    width: 30px;
    height: 30px;
  }
  .chatmsg__act svg {
    width: 15px;
    height: 15px;
  }
  .chatchip {
    padding: 9px 14px;
    font-size: 0.84rem;
  }
  .chatpanel__form {
    padding: 12px 12px 10px;
  }
  .chatpanel__form input {
    padding: 13px 16px;
  }
}
@keyframes chatlive {
  0% {
    box-shadow: 0 0 0 0 rgba(155, 212, 92, 0.5);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(155, 212, 92, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(155, 212, 92, 0);
  }
}
@keyframes chatfabpulse {
  0% {
    box-shadow: 0 16px 34px -12px rgba(61, 181, 74, 0.7), 0 0 0 0 rgba(61, 181, 74, 0.5);
  }
  70% {
    box-shadow: 0 16px 34px -12px rgba(61, 181, 74, 0.7), 0 0 0 16px rgba(61, 181, 74, 0);
  }
  100% {
    box-shadow: 0 16px 34px -12px rgba(61, 181, 74, 0.7), 0 0 0 0 rgba(61, 181, 74, 0);
  }
}
@keyframes chatnudgein {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes chatmsgin {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes chattype {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .chat,
  .chatpanel,
  .chatnudge,
  .chatmsg,
  .chatfab.is-attn,
  .chatpanel__live,
  .chattyping span {
    animation: none !important;
    transition: none !important;
  }
}
