.pat-root {
  --pat-blue: #006eb7;
  --pat-blue-dark: #00548c;
  --pat-green: #73c539;
  --pat-ink: #1f2a37;
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  /* Above the basket pill (1200) so an open chat is never covered, below the cookie banner. */
  z-index: 1300;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.45;
  color: var(--pat-ink);
}

.pat-root[hidden] {
  display: none;
}

.pat-launcher {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  /* Tucks the closed icon into the bottom-right corner (the open panel keeps its normal spacing). */
  margin: 0 -0.8rem -0.8rem 0;
}

.pat-launcher[hidden] {
  display: none;
}

.pat-launcher__bubble {
  position: relative;
  max-width: 230px;
  padding: 0.55rem 0.85rem;
  border: 1px solid #d6e4f0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 62, 142, 0.18);
  color: var(--pat-ink);
  font-size: 0.9rem;
  cursor: pointer;
  animation: pat-pop 0.35s ease-out;
}

.pat-launcher__bubble[hidden] {
  display: none;
}

.pat-launcher__bubble::after {
  content: "";
  position: absolute;
  right: -7px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-top: 1px solid #d6e4f0;
  border-right: 1px solid #d6e4f0;
  background: #fff;
  transform: rotate(45deg);
}

.pat-launcher__button {
  position: relative;
  /* Pat is a cut-out figure (no circle or background), so size by width and let the height follow. */
  width: 120px;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: none;
  cursor: pointer;
  overflow: visible;
  transition: transform 0.15s ease;
}

.pat-launcher__button:hover,
.pat-launcher__button:focus-visible {
  transform: scale(1.06);
}

.pat-launcher__button:focus-visible,
.pat-panel button:focus-visible,
.pat-panel input:focus-visible {
  outline: 3px solid var(--pat-green);
  outline-offset: 2px;
}

.pat-launcher__button img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 6px 10px rgba(0, 40, 90, 0.35));
}

.pat-launcher__label {
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%);
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--pat-blue);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}

.pat-panel {
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 2rem));
  height: min(560px, calc(100vh - 2rem));
  border: 1px solid #d6e4f0;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 16px 48px rgba(0, 40, 90, 0.28);
  overflow: hidden;
}

.pat-panel[hidden] {
  display: none;
}

.pat-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.85rem;
  background: var(--pat-blue);
  color: #fff;
}

.pat-header img {
  width: 44px;
  height: 44px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #fdebc4;
}

.pat-header__text {
  flex: 1;
  min-width: 0;
}

.pat-header__title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.2;
}

.pat-header__sub {
  margin: 0;
  font-size: 0.78rem;
  opacity: 0.9;
}

.pat-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.pat-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.pat-messages {
  flex: 1;
  padding: 0.85rem;
  overflow-y: auto;
  background: #f5f9fc;
}

.pat-msg {
  display: block;
  max-width: 88%;
  margin: 0 0 0.6rem;
  padding: 0.55rem 0.8rem;
  border-radius: 14px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.pat-msg a {
  color: inherit;
  text-decoration: underline;
}

.pat-msg--pat {
  margin-right: auto;
  border-bottom-left-radius: 4px;
  border: 1px solid #dbe7f1;
  background: #fff;
}

.pat-msg--pat a {
  color: var(--pat-blue-dark);
  font-weight: 600;
}

.pat-msg--you {
  margin-left: auto;
  border-bottom-right-radius: 4px;
  background: var(--pat-blue);
  color: #fff;
}

.pat-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.pat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8aa7bd;
  animation: pat-bounce 1s infinite ease-in-out;
}

.pat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.pat-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

.pat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.2rem 0 0.6rem;
}

.pat-chip {
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--pat-blue);
  border-radius: 999px;
  background: #fff;
  color: var(--pat-blue);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.pat-chip:hover {
  background: var(--pat-blue);
  color: #fff;
}

.pat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-top: 1px solid #e4edf5;
  background: #fff;
}

.pat-form input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid #c5d4e0;
  border-radius: 10px;
  font: inherit;
  /* 16px stops iOS zooming the page when the field is focused */
  font-size: 16px;
}

.pat-send {
  padding: 0 1rem;
  border: 0;
  border-radius: 10px;
  background: var(--pat-green);
  color: #123;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.pat-send:disabled {
  opacity: 0.55;
  cursor: default;
}

.pat-note {
  margin: 0;
  padding: 0 0.85rem 0.6rem;
  background: #fff;
  color: #667085;
  font-size: 0.72rem;
}

.pat-note a {
  color: #667085;
}

@keyframes pat-pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pat-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* Desktop and tablet only: sit a little in from the corner (phones stay tucked in). */
@media (min-width: 521px) {
  .pat-launcher {
    margin: 0 1.6rem 2.2rem 0;
  }

  .pat-launcher__button {
    width: 150px;
  }
}

@media (max-width: 520px) {
  .pat-root {
    right: 0.6rem;
    bottom: 0.6rem;
  }

  .pat-panel {
    width: calc(100vw - 1.2rem);
    height: min(75vh, 560px);
  }

  /* Phones: smaller Pat, tucked into the bottom-right corner. */
  .pat-launcher {
    margin: 0 -0.4rem -0.4rem 0;
  }

  .pat-launcher__bubble {
    max-width: 150px;
  }

  .pat-launcher__button {
    width: 104px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pat-launcher__bubble,
  .pat-typing span {
    animation: none;
  }
}

@media print {
  .pat-root {
    display: none;
  }
}
