/* Plainwell chat widget. Uses the page's brand tokens from site.css (--surface, --ink, --accent...). */
.pwc-launch, .pwc-panel, .pwc-panel *, .pwc-panel *::before, .pwc-panel *::after { box-sizing: border-box; }
.pwc-launch {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 30;
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 16px 0 14px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 700; font-size: 0.95rem; cursor: pointer;
  box-shadow: 0 10px 28px -12px rgb(10 20 15 / 0.45);
}
.pwc-launch svg { width: 22px; height: 22px; color: var(--accent); flex: none; }
.pwc-launch:hover { border-color: var(--accent); }
.pwc-launch[aria-expanded="true"] { display: none; }
body:has(.sticky-cta.is-on) .pwc-launch { bottom: calc(82px + env(safe-area-inset-bottom, 0px)); }

.pwc-panel {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 31;
  width: min(390px, calc(100vw - 32px)); height: min(600px, calc(100dvh - 32px));
  display: grid; grid-template-rows: auto 1fr auto; overflow: hidden;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 24px 60px -20px rgb(10 20 15 / 0.5);
  font-family: var(--font-body); font-size: 0.95rem; line-height: 1.5;
}
.pwc-panel[hidden] { display: none; }
@media (max-width: 520px) {
  .pwc-panel { right: 0; bottom: 0; width: 100vw; height: 100dvh; border-radius: 0; border: 0;
    padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
}

.pwc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 14px 12px 16px; border-bottom: 1px solid var(--line); }
.pwc-title { font-family: var(--font-display); font-weight: var(--display-weight, 600); font-size: 1.15rem; line-height: 1.2; margin: 0; }
.pwc-sub { margin: 2px 0 0; font-size: 0.8rem; color: var(--muted); }
.pwc-tag { display: inline-block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; margin-left: 6px; vertical-align: 2px; color: var(--muted); font-family: var(--font-body); }
.pwc-close { flex: none; width: 40px; height: 40px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--ink); cursor: pointer; display: grid; place-items: center; }
.pwc-close:hover { border-color: var(--line); }

.pwc-log { overflow-y: auto; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.pwc-msg { max-width: 88%; display: grid; gap: 4px; }
.pwc-msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.pwc-who { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; color: var(--muted); }
.pwc-bubble { padding: 9px 12px; border-radius: 12px; }
.pwc-msg.bot .pwc-bubble, .pwc-msg.ai .pwc-bubble { background: var(--bg); border: 1px solid var(--line); border-top-left-radius: 4px; }
.pwc-msg.human .pwc-bubble { background: var(--accent-soft); border: 1px solid var(--accent); border-top-left-radius: 4px; }
.pwc-msg.visitor { align-self: flex-end; }
.pwc-msg.visitor .pwc-who { text-align: right; }
.pwc-msg.visitor .pwc-bubble { background: var(--ink); color: var(--bg); border-top-right-radius: 4px; }
.pwc-msg.system { align-self: center; max-width: 100%; text-align: center; font-size: 0.82rem; color: var(--muted); }
.pwc-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.pwc-links a { font-size: 0.85rem; font-weight: 600; color: var(--link); }
.pwc-time { font-size: 0.7rem; color: var(--muted); }

.pwc-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 4px; }
.pwc-chip { font: inherit; font-size: 0.85rem; font-weight: 600; min-height: 36px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--accent); background: var(--surface); color: var(--ink); cursor: pointer; text-align: left; }
.pwc-chip:hover { background: var(--accent-soft); }

.pwc-typing { display: inline-flex; gap: 4px; padding: 12px; }
.pwc-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: pwc-dot 1.2s infinite ease-in-out; }
.pwc-typing span:nth-child(2) { animation-delay: 0.15s; }
.pwc-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes pwc-dot { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.pwc-foot { border-top: 1px solid var(--line); padding: 10px 12px 12px; display: grid; gap: 8px; }
.pwc-compose { display: flex; gap: 8px; align-items: flex-end; }
.pwc-compose textarea { flex: 1; min-width: 0; min-height: 44px; max-height: 120px; resize: none; padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.pwc-send { flex: none; min-height: 44px; padding: 0 14px; border-radius: 10px; border: 2px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 700; cursor: pointer; }
.pwc-send:disabled { opacity: 0.6; cursor: default; }
.pwc-row { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 0.78rem; color: var(--muted); }
.pwc-row button { font: inherit; font-weight: 600; color: var(--link); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.pwc-row a { color: var(--muted); }
.pwc-contact { display: grid; gap: 6px; padding: 10px; border: 1px dashed var(--line); border-radius: 10px; }
.pwc-contact p { margin: 0; font-size: 0.85rem; }
.pwc-contact input { width: 100%; min-height: 40px; padding: 8px 10px; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.pwc-contact .pwc-send { justify-self: start; }
.pwc-err { color: var(--bad); font-size: 0.82rem; margin: 0; }
.pwc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .pwc-typing span { animation: none; opacity: 0.6; } }
@media print { .pwc-launch, .pwc-panel { display: none !important; } }
