.pfn-chat-launcher {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 13px 18px;
}

.pfn-chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 48;
  display: none;
  background: rgba(7, 10, 15, 0.42);
  backdrop-filter: blur(3px);
}

.pfn-chat-overlay[data-open="true"] {
  display: block;
}

.pfn-chat-panel {
  position: fixed;
  right: 18px;
  bottom: 76px;
  z-index: 49;
  width: min(380px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 100px));
  display: none;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
}

.pfn-chat-panel[data-open="true"] {
  display: grid;
}

.pfn-chat-overlay[data-open="true"] + .pfn-chat-panel[data-open="true"] {
  right: 50%;
  bottom: 50%;
  width: min(460px, calc(100vw - 32px));
  max-height: min(700px, calc(100vh - 48px));
  transform: translate(50%, 50%);
}

.pfn-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
}

.pfn-chat-title {
  margin: 0;
  font-size: 15px;
  font-weight: 850;
}

.pfn-chat-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.pfn-chat-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--secondary);
  color: var(--ink);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.pfn-chat-messages {
  min-height: 220px;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pfn-chat-choice-group {
  display: grid;
  gap: 8px;
}

.pfn-chat-choice-label {
  margin: 2px 2px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pfn-chat-choice-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pfn-chat-message {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 8px;
  white-space: pre-wrap;
  font-size: 14px;
}

.pfn-chat-message a {
  color: inherit;
  font-weight: 800;
}

.pfn-chat-message[data-role="assistant"] {
  align-self: flex-start;
  background: var(--soft);
  border: 1px solid var(--soft-border);
}

.pfn-chat-message[data-role="user"] {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}

.pfn-chat-chip,
.pfn-chat-cta {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  padding: 9px 12px;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.pfn-chat-chip:hover,
.pfn-chat-cta:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.pfn-chat-cta {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.pfn-chat-chip:disabled,
.pfn-chat-cta:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.pfn-chat-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.pfn-chat-input {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  background: var(--field-bg);
  color: var(--ink);
  font: inherit;
  padding: 10px;
}

.pfn-chat-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pfn-chat-note {
  color: var(--muted);
  font-size: 11px;
}

.pfn-chat-send {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 9px 14px;
}

.pfn-chat-send:disabled,
.pfn-chat-launcher:disabled {
  cursor: wait;
  opacity: 0.7;
}

@media (max-width: 640px) {
  .pfn-chat-overlay[data-open="true"] + .pfn-chat-panel[data-open="true"] {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    transform: none;
  }

  .pfn-chat-panel {
    right: 12px;
    bottom: 70px;
    width: calc(100vw - 24px);
  }

  .pfn-chat-launcher {
    right: 12px;
    bottom: 12px;
  }
}
