.pi-help-assistant {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 9000;
  font-family: "Poppins", sans-serif;
}

html.pi-help-panel-open,
html.pi-help-panel-open body {
  overflow: hidden;
  overscroll-behavior: none;
}

.pi-help-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  border: 0;
  background: rgba(17, 24, 39, .3);
  cursor: default;
}

.pi-help-backdrop[hidden] { display: none; }

.pi-help-toggle {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-left: auto;
  border: 0;
  border-radius: 999px;
  background: #3155b7;
  color: #fff;
  padding: .65rem 1rem .65rem .65rem;
  font: inherit;
  font-size: .875rem;
  font-weight: 700;
  min-height: 3rem;
  box-shadow: 0 14px 36px rgba(26, 45, 100, .28);
  cursor: pointer;
}

.pi-help-toggle:focus-visible,
.pi-help-header-actions button:focus-visible,
.pi-help-form button:focus-visible,
.pi-help-feedback button:focus-visible,
.pi-help-followups button:focus-visible,
.pi-help-suggestions button:focus-visible,
.pi-help-center-link:focus-visible,
.help-home-question:focus-visible {
  outline: 3px solid rgba(249, 189, 3, .82);
  outline-offset: 3px;
}

.pi-help-toggle-icon {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  font-size: 1rem;
}

.pi-help-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + .75rem);
  display: grid;
  width: min(420px, calc(100vw - 2rem));
  height: min(680px, calc(100vh - 7rem));
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  overflow: hidden;
  border: 1px solid #dce2f2;
  border-radius: 1.25rem;
  background: #fff;
  color: #202433;
  box-shadow: 0 24px 70px rgba(20, 30, 60, .28);
  z-index: 2;
}

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

.pi-help-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  background: #111827;
  color: #fff;
}

.pi-help-header strong,
.pi-help-header span { display: block; }
.pi-help-header strong { font-size: .95rem; }
.pi-help-header span { margin-top: .1rem; color: rgba(255, 255, 255, .64); font-size: .72rem; }
.pi-help-header-actions { display: flex; gap: .35rem; }
.pi-help-header-actions button {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border: 0;
  border-radius: .6rem;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
}

.pi-help-privacy {
  padding: .7rem 1rem;
  border-bottom: 1px solid #e7eaf3;
  background: #fff8e6;
  color: #725414;
  font-size: .68rem;
  line-height: 1.45;
}

.pi-help-messages {
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  background: #f7f8fe;
}

.pi-help-message { display: flex; flex-direction: column; margin-bottom: .85rem; }
.pi-help-message.is-user { align-items: flex-end; }
.pi-help-message.is-assistant { align-items: flex-start; }
.pi-help-message.has-error .pi-help-bubble { border: 1px solid #d94b5b; }
.pi-help-bubble {
  max-width: 88%;
  border-radius: 1rem;
  background: #fff;
  padding: .75rem .85rem;
  font-size: .79rem;
  line-height: 1.65;
  box-shadow: 0 5px 16px rgba(30, 45, 80, .08);
}
.pi-help-bubble p { margin: 0; white-space: pre-wrap; }
.pi-help-message.is-user .pi-help-bubble { background: #3155b7; color: #fff; border-bottom-right-radius: .3rem; }
.pi-help-message.is-assistant .pi-help-bubble { border-bottom-left-radius: .3rem; }

.pi-help-steps { margin: .65rem 0 0; padding-left: 1.25rem; }
.pi-help-steps li + li { margin-top: .35rem; }
.pi-help-notices {
  margin-top: .65rem;
  border: 1px solid #ead28d;
  border-radius: .65rem;
  background: #fff8e6;
  color: #725414;
  padding: .5rem .6rem;
  font-size: .66rem;
}
.pi-help-notices p + p { margin-top: .3rem; }
.pi-help-links { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .7rem; }
.pi-help-links a {
  border-radius: 999px;
  background: #edf1ff;
  color: #3155b7;
  padding: .35rem .6rem;
  font-size: .68rem;
  font-weight: 700;
  text-decoration: none;
}
.pi-help-sources { margin-top: .7rem; border-top: 1px solid #e7eaf3; padding-top: .55rem; }
.pi-help-sources summary { color: #63708d; font-size: .66rem; font-weight: 700; cursor: pointer; }
.pi-help-sources ul { margin: .45rem 0 0; padding-left: 1rem; color: #63708d; font-size: .63rem; }
.pi-help-sources li + li { margin-top: .25rem; }
.pi-help-verification,
.pi-help-checks {
  margin-top: .7rem;
  border: 1px solid #dce2f2;
  border-radius: .7rem;
  background: #f8f9fd;
  padding: .5rem .6rem;
}
.pi-help-verification summary,
.pi-help-checks summary {
  color: #3155b7;
  font-size: .67rem;
  font-weight: 700;
  cursor: pointer;
}
.pi-help-verification ol,
.pi-help-checks ul {
  margin: .5rem 0 0;
  padding-left: 1.05rem;
  color: #58647d;
  font-size: .63rem;
}
.pi-help-verification li + li,
.pi-help-checks li + li { margin-top: .35rem; }
.pi-help-checks li strong,
.pi-help-checks li span { display: block; }
.pi-help-checks li strong::before {
  content: "✓";
  margin-right: .3rem;
  color: #2f855a;
}
.pi-help-checks li[data-status="limited"] strong::before {
  content: "!";
  color: #b7791f;
}

.pi-help-feedback { display: flex; align-items: center; gap: .35rem; margin-top: .35rem; color: #7b8499; font-size: .62rem; }
.pi-help-feedback button,
.pi-help-followups button,
.pi-help-suggestions button {
  border: 1px solid #dce2f2;
  border-radius: 999px;
  background: #fff;
  color: #3155b7;
  font: inherit;
  font-size: .64rem;
  font-weight: 700;
  cursor: pointer;
}
.pi-help-feedback button { padding: .22rem .45rem; }
.pi-help-feedback button[data-active="true"] { border-color: #3155b7; background: #3155b7; color: #fff; }
.pi-help-followups { display: flex; flex-wrap: wrap; gap: .35rem; margin: -.35rem 0 .85rem; }
.pi-help-followups button { padding: .38rem .6rem; text-align: left; }

.pi-help-suggestions { display: flex; gap: .4rem; overflow-x: auto; padding: .65rem 1rem 0; background: #fff; }
.pi-help-suggestions[hidden] { display: none; }
.pi-help-suggestions button { flex: 0 0 auto; padding: .4rem .65rem; }

.pi-help-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .55rem; padding: .75rem 1rem; background: #fff; }
.pi-help-form textarea {
  min-height: 3rem;
  max-height: 7rem;
  resize: vertical;
  border: 1px solid #d6dceb;
  border-radius: .8rem;
  padding: .65rem .75rem;
  color: #202433;
  font: inherit;
  font-size: .75rem;
  line-height: 1.45;
  outline: none;
}
.pi-help-form textarea:focus { border-color: #3155b7; box-shadow: 0 0 0 3px rgba(49, 85, 183, .1); }
.pi-help-form button {
  align-self: stretch;
  border: 0;
  border-radius: .8rem;
  background: #3155b7;
  color: #fff;
  padding: 0 .8rem;
  font: inherit;
  font-size: .7rem;
  font-weight: 700;
  cursor: pointer;
}
.pi-help-form button:disabled { opacity: .6; cursor: wait; }
.pi-help-error { margin: 0; padding: 0 1rem .6rem; color: #c43d50; font-size: .68rem; }
.pi-help-center-link { padding: 0 1rem .8rem; color: #3155b7; font-size: .66rem; font-weight: 700; text-align: center; text-decoration: none; }

.help-home-question {
  cursor: pointer;
  transform-origin: center;
}

.help-home-question:active,
.pi-help-toggle:active,
.pi-help-header-actions button:active,
.pi-help-form button:active,
.pi-help-feedback button:active,
.pi-help-followups button:active,
.pi-help-suggestions button:active {
  transform: translateY(1px) scale(.985);
}

.pi-help-home-primary {
  box-shadow: 0 10px 24px rgba(49, 85, 183, .18);
}

@media (max-width: 640px) {
  .pi-help-assistant {
    right: max(.75rem, env(safe-area-inset-right));
    bottom: max(1rem, calc(env(safe-area-inset-bottom) + .5rem));
  }
  .pi-help-toggle {
    min-width: 7.5rem;
    justify-content: center;
    box-shadow: 0 16px 40px rgba(26, 45, 100, .38);
  }
  .pi-help-panel {
    position: fixed;
    top: calc(var(--pi-help-viewport-top, 0px) + max(.5rem, env(safe-area-inset-top)));
    right: max(.5rem, env(safe-area-inset-right));
    bottom: auto;
    left: max(.5rem, env(safe-area-inset-left));
    width: auto;
    height: calc(var(--pi-help-viewport-height, 100dvh) - 1rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    max-height: none;
    border-radius: 1rem;
  }
  .pi-help-assistant.is-open .pi-help-toggle { visibility: hidden; }
}

@media (prefers-reduced-motion: no-preference) {
  .pi-help-toggle,
  .pi-help-header-actions button,
  .pi-help-form button,
  .pi-help-feedback button,
  .pi-help-followups button,
  .pi-help-suggestions button,
  .help-home-question {
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background-color .16s ease;
  }
  .pi-help-toggle:hover { transform: translateY(-2px); box-shadow: 0 18px 42px rgba(26, 45, 100, .34); }
  .help-home-question:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(49, 85, 183, .16); }
  .pi-help-home-primary:hover { box-shadow: 0 15px 32px rgba(49, 85, 183, .28); }
}
