.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.help-kb {
  position: fixed;
  z-index: 120;
  top: calc(var(--help-top, 3.5rem) + 0.35rem);
  right: clamp(0.75rem, 2.5vw, 1.35rem);
  pointer-events: none;
  color: var(--help-fg);
}

.help-kb--open {
  pointer-events: auto;
}

.help-kb__panel {
  pointer-events: auto;
  width: min(22.5rem, calc(100vw - 1.7rem));
  max-height: min(42rem, calc(100svh - 4.75rem));
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.85rem 0.9rem 0.95rem;
  border: 1px solid color-mix(in srgb, var(--help-fg) 18%, var(--help-bg));
  border-radius: 14px;
  background: var(--help-bg);
  color: var(--help-fg);
  box-shadow: 0 12px 32px color-mix(in srgb, var(--help-fg) 12%, transparent);
  overflow: hidden;
}

.help-kb__panel[hidden] {
  display: none;
}

.help-kb__head,
.help-kb__hint,
.help-kb__search,
.help-kb__chips {
  flex-shrink: 0;
}

.help-kb__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.help-kb__title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--help-fg);
}

.help-kb__close {
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--help-fg) 18%, var(--help-bg));
  border-radius: 8px;
  background: var(--help-bg);
  color: color-mix(in srgb, var(--help-fg) 65%, var(--help-bg));
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.28rem 0.55rem;
  cursor: pointer;
}

.help-kb__close:hover {
  color: var(--help-fg);
}

.help-kb__hint {
  margin: 0;
  font-size: 0.8rem;
  color: color-mix(in srgb, var(--help-fg) 65%, var(--help-bg));
  line-height: 1.4;
}

.help-kb__input {
  width: 100%;
  border: 1px solid color-mix(in srgb, var(--help-fg) 18%, var(--help-bg));
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: var(--help-fg);
  background: var(--help-bg);
}

.help-kb__input:focus {
  outline: 2px solid color-mix(in srgb, var(--help-fg) 28%, transparent);
  outline-offset: 1px;
}

.help-kb__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.help-kb__chip {
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--help-fg) 18%, var(--help-bg));
  border-radius: 999px;
  background: color-mix(in srgb, var(--help-fg) 6%, var(--help-bg));
  color: color-mix(in srgb, var(--help-fg) 70%, var(--help-bg));
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.22rem 0.55rem;
  cursor: pointer;
}

.help-kb__chip:hover {
  color: var(--help-fg);
}

.help-kb__list {
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  -webkit-overflow-scrolling: touch;
}

.help-kb__empty {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  color: color-mix(in srgb, var(--help-fg) 65%, var(--help-bg));
}

.help-kb__item {
  border: 1px solid color-mix(in srgb, var(--help-fg) 18%, var(--help-bg));
  border-radius: 10px;
  background: var(--help-bg);
  padding: 0.15rem 0.55rem 0.35rem;
}

.help-kb__summary {
  cursor: pointer;
  list-style: none;
  display: block;
  padding: 0.4rem 0.1rem;
}

.help-kb__summary::-webkit-details-marker {
  display: none;
}

.help-kb__cat {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--help-fg) 72%, var(--help-bg));
}

.help-kb__name {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--help-fg);
  line-height: 1.35;
}

.help-kb__body {
  margin: 0 0 0.35rem;
  padding: 0 0.1rem 0.25rem;
  font-size: 0.88rem;
  color: color-mix(in srgb, var(--help-fg) 65%, var(--help-bg));
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.help-kb__ask-lead {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  color: color-mix(in srgb, var(--help-fg) 65%, var(--help-bg));
  line-height: 1.45;
}

.help-kb__ask-btn {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  color: var(--help-fg);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

body.help-dialog-open {
  overflow: hidden;
}

.help-dialog[hidden] {
  display: none !important;
}

.help-dialog {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.help-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--help-fg) 45%, transparent);
}

.help-dialog__panel {
  position: relative;
  z-index: 1;
  width: min(100%, 28rem);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  padding: 1.25rem 1.35rem 1.35rem;
  border: 1px solid color-mix(in srgb, var(--help-fg) 18%, var(--help-bg));
  border-radius: 14px;
  background: var(--help-bg);
  color: var(--help-fg);
  box-shadow: 0 12px 32px color-mix(in srgb, var(--help-fg) 12%, transparent);
}

.help-dialog__title {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  color: var(--help-fg);
}

.help-dialog__intro {
  margin: 0 0 0.85rem;
  font-size: 0.88rem;
  color: color-mix(in srgb, var(--help-fg) 65%, var(--help-bg));
}

.help-dialog__field {
  display: grid;
  gap: 0.3rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.help-dialog__field textarea {
  font: inherit;
  width: 100%;
  border: 1px solid color-mix(in srgb, var(--help-fg) 18%, var(--help-bg));
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  color: var(--help-fg);
  background: var(--help-bg);
}

.help-dialog__error {
  margin: 0 0 0.75rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.help-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: flex-end;
}

.help-dialog__btn {
  appearance: none;
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--help-fg) 18%, var(--help-bg));
  background: var(--help-bg);
  color: var(--help-fg);
}

.help-dialog__btn--primary {
  font-weight: 700;
}

.help-dialog__done {
  display: grid;
  gap: 0.85rem;
}

.help-dialog [hidden] {
  display: none !important;
}

.help-dialog__success {
  margin: 0;
}

@media (max-width: 640px) {
  .help-kb {
    right: 0.75rem;
    left: 0.75rem;
  }
  .help-kb__panel {
    width: 100%;
    max-height: min(78svh, 40rem);
  }
}
