.sw-bot {
  --sw-panel: #292929;
  --sw-panel-2: #353535;
  --sw-soft: #ffffffa8;
  position: fixed;
  right: max(24px, env(safe-area-inset-right, 0px));
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  z-index: 70;
  color: #fff;
  font-family: var(--font);
  pointer-events: none;
}

.sw-launch-wrap {
  position: relative;
  width: 67px;
  height: 120px;
  margin-left: auto;
  pointer-events: auto;
}

.sw-launch {
  position: absolute;
  inset: 0;
  padding: 0;
  border: 0;
  border-radius: 40px;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}

.sw-char {
  position: absolute;
  inset: -25% -45% 0;
  pointer-events: none;
}

.sw-char canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.sw-char-img {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: auto;
  height: 80%;
  transform: translateX(-50%);
  user-select: none;
}

.sw-has-gl .sw-char-img {
  display: none;
}

.sw-shadow {
  position: absolute;
  bottom: -4px;
  left: 50%;
  width: 60px;
  height: 12px;
  margin-left: -30px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgb(0 0 0 / 0.35), rgb(25 214 140 / 0.18) 60%, transparent);
  pointer-events: none;
}

.sw-status {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 2px var(--paper);
  pointer-events: none;
}

.sw-hello {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  width: max-content;
  max-width: min(300px, calc(100vw - 48px));
  visibility: hidden;
  pointer-events: none;
}

.sw-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 10px;
  border-radius: 999px;
  background: var(--accent);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.sw-name::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
}

.sw-bubble {
  padding: 14px 16px;
  border-radius: 20px 20px 6px 20px;
  background: var(--sw-panel);
  font-size: 15px;
  line-height: 1.4;
  box-shadow: 0 24px 50px -20px rgb(0 0 0 / 0.55);
}

.sw-panel {
  position: absolute;
  right: calc(100% + 8px);
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 120px));
  height: min(560px, calc(100dvh - 48px));
  border-radius: 28px;
  background: var(--sw-panel);
  box-shadow: 0 40px 90px -30px rgb(0 0 0 / 0.6);
  overflow: hidden;
  visibility: hidden;
  pointer-events: auto;
  transform-origin: 100% 100%;
}

.sw-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 14px 14px 20px;
  border-bottom: 1px solid #ffffff14;
}

.sw-head-dot {
  position: relative;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #1d1d1d url("../images/swaggy/swaggy-cutout.webp") no-repeat 50% 6% / 120% auto;
}

.sw-head-dot::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 2px var(--sw-panel);
}

.sw-head-copy {
  flex: 1;
  min-width: 0;
}

.sw-head-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.sw-head-sub {
  margin-top: 2px;
  color: var(--sw-soft);
  font-size: 13px;
}

.sw-icon-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--sw-soft);
  transition:
    background-color 0.15s,
    color 0.15s;
}

.sw-icon-btn:hover {
  background: #ffffff14;
  color: #fff;
}

.sw-icon-btn svg {
  width: 20px;
  height: 20px;
}

.sw-icon-btn[aria-pressed="false"] .sw-on,
.sw-icon-btn[aria-pressed="true"] .sw-off,
.sw-icon-btn[hidden] {
  display: none;
}

.sw-log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  padding: 18px 16px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #ffffff30 transparent;
}

.sw-msg {
  max-width: 85%;
  padding: 11px 14px;
  border-radius: 18px;
  font-size: 15px;
  font-weight: 300;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.sw-msg-bot {
  align-self: flex-start;
  border-bottom-left-radius: 6px;
  background: var(--sw-panel-2);
}

.sw-msg-user {
  align-self: flex-end;
  border-bottom-right-radius: 6px;
  background: var(--accent);
}

.sw-msg a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
}

.sw-msg a:hover {
  background: var(--accent);
  color: #fff;
}

.sw-typing {
  display: inline-flex;
  gap: 5px;
  padding: 15px 16px;
}

.sw-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffffffb0;
}

.sw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 16px 12px;
}

.sw-chip {
  padding: 8px 13px;
  border: 1px solid #ffffff2e;
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  transition:
    background-color 0.15s,
    border-color 0.15s;
}

.sw-chip:hover {
  border-color: var(--accent);
  background: var(--accent);
}

.sw-form {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 12px 12px;
  padding: 6px 6px 6px 16px;
  border-radius: 999px;
  background: #ffffff12;
}

.sw-form:focus-within {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.sw-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-size: 15px;
  outline: none;
}

.sw-input::placeholder {
  color: #ffffff80;
}

.sw-send {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
}

.sw-send svg {
  width: 18px;
  height: 18px;
}

.sw-mic[data-listening] {
  background: var(--accent);
  color: #fff;
}

@media (max-width: 640px) {
  .sw-bot {
    right: 16px;
    bottom: 16px;
  }
  .sw-launch-wrap {
    width: 45px;
    height: 81px;
  }
  .sw-shadow {
    width: 42px;
    margin-left: -21px;
  }
  .sw-panel {
    right: 0;
    bottom: calc(100% + 10px);
    width: calc(100vw - 32px);
    height: min(64dvh, 520px);
  }
}

@media print {
  .sw-bot {
    display: none;
  }
}
