:root {
  --mascot-dock-width: 108px;
  --mascot-dock-height: 126px;
  --mascot-dock-right: max(14px, env(safe-area-inset-right));
  --mascot-dock-bottom: max(10px, env(safe-area-inset-bottom));
}

.mascot-dock[data-demo] { --mascot-dock-bottom: max(70px, env(safe-area-inset-bottom)); }
.mascot-dock[hidden], .mascot-dock [hidden] { display: none; }
.mascot-view canvas, .mascot-poster { position: absolute; inset: 0; width: 100%; height: 100%; }
.mascot-poster { object-fit: contain; pointer-events: none; }
.mascot-view canvas { opacity: 0; pointer-events: none; }
.mascot-view[data-state='ready'] canvas { opacity: 1; }
.mascot-view[data-state='ready'] .mascot-poster { display: none; }
.mascot-dock .mascot-view, .mascot-stage[data-floating='true'] .mascot-view {
  position: fixed;
  z-index: 138;
  right: var(--mascot-dock-right);
  bottom: var(--mascot-dock-bottom);
  width: var(--mascot-dock-width);
  height: var(--mascot-dock-height);
  border: 0;
  background: radial-gradient(ellipse at 50% 50%, #28614848, transparent 70%);
  filter: drop-shadow(0 3px 4px #0714108c);
  pointer-events: none;
}

.mascot-dock { font-family: var(--font-sans, system-ui, sans-serif); color: #172a25; }
.mascot-dock :is(button, input, textarea) { box-sizing: border-box; font: inherit; }
.mascot-dock button { cursor: pointer; }
.mascot-dock button:focus-visible { outline: 2px solid #21a471; outline-offset: 3px; }
.mascot-launch {
  position: fixed;
  z-index: 139;
  right: calc(var(--mascot-dock-right) + var(--mascot-dock-width) * .5 - 22px);
  bottom: calc(var(--mascot-dock-bottom) + var(--mascot-dock-height) * .57);
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #e7fff3;
  background: transparent;
}
.mascot-launch span {
  position: absolute;
  top: 50%;
  right: calc(100% + 6px);
  transform: translateY(-50%);
  padding: 8px 11px;
  border: 1px solid #477f6b;
  border-radius: 13px 13px 3px 13px;
  background: #122a24;
  box-shadow: 0 3px 10px #0e201f38;
  white-space: nowrap;
  font-size: .79rem;
  font-weight: 720;
}
.mascot-launch:hover span, .mascot-launch[aria-expanded='true'] span { background: #27564a; }

.mascot-chat {
  position: fixed;
  z-index: 140;
  right: var(--mascot-dock-right);
  bottom: calc(var(--mascot-dock-bottom) + var(--mascot-dock-height) + 8px);
  width: min(358px, calc(100vw - var(--mascot-dock-right) - 12px));
  max-height: calc(100dvh - var(--mascot-dock-bottom) - var(--mascot-dock-height) - 20px);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
  border: 1px solid #507464;
  border-radius: 18px;
  background: #f5faf7;
  box-shadow: 0 18px 55px #06191550;
  text-align: left;
}
.mascot-chat-head {
  display: grid;
  grid-template-columns: 39px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 8px;
  color: #edfff6;
  background: #132d25;
  line-height: 1.2;
}
.mascot-chat-avatar, .mascot-chat-line[data-speaker='bot']::before {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #224d3e url('/assets/mascota-bitcores.webp') no-repeat center 15% / auto 245%;
}
.mascot-chat-name { display: block; font-size: .94rem; }
.mascot-chat-subtitle { font-size: .73rem; color: #b7dacd; }
.mascot-dock .mascot-chat-close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font-size: 1.5rem;
}
.mascot-chat-close:hover { background: #295345; }
.mascot-chat-log {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 0;
  max-height: 300px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 13px;
  background: #eaf3ed;
}
.mascot-chat-line {
  max-width: 91%;
  margin: 0;
  padding: 9px 11px;
  border: 1px solid #cfe0d5;
  border-radius: 13px 13px 13px 3px;
  background: #fff;
  color: #172a25;
  font-size: .86rem;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.mascot-chat-line[data-speaker='user'] {
  align-self: flex-end;
  border-color: #244e41;
  border-radius: 13px 13px 3px 13px;
  color: #f4fff9;
  background: #244e41;
}
.mascot-chat-line[data-speaker='bot'] { position: relative; margin-left: 29px; }
.mascot-chat-line[data-speaker='bot']::before {
  content: '';
  position: absolute;
  top: 4px;
  left: -29px;
  width: 23px;
  height: 23px;
}
.mascot-chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: none;
  padding: 10px;
  border-top: 1px solid #d6e5dc;
}
.mascot-dock .mascot-chat-actions button {
  min-height: 36px;
  padding: 5px 10px;
  border: 1px solid #b5cebf;
  border-radius: 10px;
  background: #fff;
  color: #224638;
  font-size: .79rem;
  font-weight: 700;
  line-height: 1.2;
}
.mascot-dock .mascot-chat-actions button:hover { background: #dff1e7; }
.mascot-dock .mascot-chat-actions .mascot-chat-primary { background: #244e41; border-color: #244e41; color: #fff; }
.mascot-dock .mascot-chat-actions .mascot-chat-primary:hover { background: #326856; }
.mascot-chat-answer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  width: 100%;
}
.mascot-chat-answer input {
  min-width: 0;
  min-height: 40px;
  padding-inline: 8px;
  border: 1px solid #a6c3b4;
  border-radius: 9px;
  background: #fff;
  color: #172a25;
  font-size: 1rem;
}
.mascot-chat-copy {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  line-height: 1.4;
}

@media (max-width: 720px) {
  :root {
    --mascot-dock-width: 60px;
    --mascot-dock-height: 77px;
    --mascot-dock-right: max(4px, env(safe-area-inset-right));
  }
  .mascot-launch { bottom: calc(var(--mascot-dock-bottom) + var(--mascot-dock-height) * .38); }
  .mascot-launch span { padding: 6px 8px; font-size: .73rem; }
  .mascot-chat { right: max(8px, var(--mascot-dock-right)); }
  body:has(:is(#contactForm, #swForm) :is(input, textarea, select):focus) :is(.mascot-dock, .mascot-stage[data-floating='true'] .mascot-view) { display: none; }
  .mascot-chat:has(.mascot-chat-answer) { bottom: 8px; max-height: calc(100dvh - 16px); }
}

@media (max-height: 420px) {
  .mascot-chat { bottom: 8px; max-height: calc(100dvh - 16px); }
}
