/* Chat panel (visitor page and widget iframe). The widget colour comes from --pb-primary (set on .pb-chat together with
   --pb-primary-contrast, the accessible text colour for it). The colour is used for fills/accents only: user bubbles are a
   light tint of it with ink text, links and small text always use ink / brand-text, so any chosen colour stays readable. */
/* Visitor home page only (not in /embed): small "Sign in" link above the chat card, right-aligned. */
.pb-topbar { max-width: 880px; margin: 0 auto; padding: 12px 24px 0; display: flex; justify-content: flex-end; height: 44px; }
.pb-signin { font-size: 14px; font-weight: 600; color: var(--ink); text-decoration: none; padding: 4px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-raised); line-height: 22px; }
.pb-signin:hover { border-color: var(--brand); }
.pb-page { max-width: 880px; margin: 0 auto; padding: 24px; height: 100vh; height: 100dvh; display: flex; }
.pb-topbar + .pb-page { padding-top: 12px; height: calc(100vh - 44px); height: calc(100dvh - 44px); }
.pb-chat {
  --pb-user-bg: color-mix(in srgb, var(--pb-primary) 20%, white);
  --pb-user-border: color-mix(in srgb, var(--pb-primary) 45%, white);
  display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0;
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); overflow: hidden;
  font-family: var(--font); color: var(--ink);
}
.pb-chat.pb-compact { position: fixed; inset: 0; border: 0; border-radius: 0; box-shadow: none; }
.pb-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-raised); }
.pb-icon { display: block; width: 36px; height: 36px; flex-shrink: 0; }
.pb-title { margin: 0; font-size: 18px; font-weight: 400; letter-spacing: -.01em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-title .brand-name { font-weight: 400; }
.pb-title strong, .pb-title .brand-name strong { font-weight: 700; }
.pb-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
.pb-actions button { padding: 6px 14px; font-size: 13px; }
.pb-actions .pb-close { font-size: 22px; line-height: 1; padding: 0; width: 34px; height: 34px; border-radius: 50%; }

.pb-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 24px 20px; display: flex; flex-direction: column; gap: 16px; scroll-behavior: smooth; background: var(--surface); }
.pb-msg { display: flex; flex-direction: column; max-width: 86%; }
.pb-msg.pb-user { align-self: flex-end; align-items: flex-end; }
.pb-msg.pb-assistant { align-self: flex-start; align-items: flex-start; }
.pb-bubble { padding: 12px 16px; border-radius: var(--radius-card); overflow-wrap: anywhere; word-break: break-word; line-height: 1.55; }
.pb-user .pb-bubble { background: var(--pb-user-bg); color: var(--ink); border: 1px solid var(--pb-user-border); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.pb-assistant .pb-bubble { background: var(--surface-raised); color: var(--ink); border: 1px solid var(--border); border-bottom-left-radius: 4px; box-shadow: 0 2px 8px rgba(180, 120, 60, .06); }
.pb-bubble p { margin: 0 0 10px; }
.pb-bubble > :last-child { margin-bottom: 0; }
.pb-bubble ul, .pb-bubble ol { margin: 0 0 10px; padding-left: 22px; }
.pb-bubble code { background: var(--chip-neutral); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.pb-bubble pre { background: var(--navy); color: #fff; padding: 12px 14px; border-radius: var(--radius-sm); overflow-x: auto; margin: 0 0 10px; }
.pb-bubble pre code { background: none; padding: 0; color: inherit; }
.pb-bubble h3, .pb-bubble h4, .pb-bubble h5 { margin: 4px 0 6px; font-size: 16px; }
.pb-bubble a { color: var(--brand-text); font-weight: 600; }
.pb-bubble a:hover { color: var(--ink); }
.pb-cite { display: inline-block; font-size: 11px; font-weight: 700; line-height: 1.5; padding: 0 6px; margin: 0 1px; border-radius: var(--radius-pill); background: var(--peach); color: var(--ink); vertical-align: baseline; }

.pb-thinking { color: var(--ink-soft); font-style: italic; }
.pb-thinking::after { content: ""; display: inline-block; width: 1em; text-align: left; animation: pb-dots 1.2s steps(4, end) infinite; }
@keyframes pb-dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
@media (prefers-reduced-motion: reduce) { .pb-thinking::after { animation: none; content: "..."; } .pb-messages { scroll-behavior: auto; } }

/* Sources block: numbered pills */
.pb-sources { margin-top: 8px; font-size: 13px; color: var(--ink-soft); max-width: 100%; }
.pb-sources h3 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--ink-soft); }
.pb-sources ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pb-sources li { display: flex; align-items: baseline; gap: 8px; overflow-wrap: anywhere; line-height: 1.4; }
.pb-sources .pb-num { flex-shrink: 0; min-width: 22px; height: 22px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-pill); background: var(--peach); color: var(--ink); font-size: 12px; font-weight: 700; align-self: flex-start; }
.pb-sources a { color: var(--ink); font-weight: 600; text-decoration-color: var(--brand); text-decoration-thickness: 2px; }
.pb-sources a:hover { color: var(--brand-text); }

.pb-error { margin-top: 8px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--negative); font-size: 14px; font-weight: 600; background: var(--negative-bg); border-radius: var(--radius-sm); padding: 8px 12px; }
.pb-error button { padding: 4px 14px; font-size: 13px; }
.pb-stopped { margin-top: 4px; font-size: 13px; color: var(--ink-soft); }

/* Empty state */
.pb-empty { margin: auto; text-align: center; max-width: 34rem; color: var(--ink-soft); display: flex; flex-direction: column; align-items: center; padding: 16px 0; }
.pb-empty-icon { display: block; width: 72px; height: 72px; margin-bottom: 4px; }
.pb-empty .kicker { font-size: 30px; margin: 0 0 8px; }
.pb-empty .pb-welcome { font-size: 17px; color: var(--ink); margin: 0 0 24px; max-width: 28rem; }
.pb-empty h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 8px; color: var(--ink-soft); }
.pb-empty ul { list-style: none; margin: 0; padding: 0; font-size: 13px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.pb-empty li { margin: 0; padding: 4px 12px; border-radius: var(--radius-pill); background: var(--surface-raised); border: 1px solid var(--border); color: var(--ink); font-weight: 600; }

.pb-form { display: flex; gap: 8px; align-items: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-raised); }
.pb-input { flex: 1; resize: none; max-height: 144px; line-height: 1.4; min-height: 42px; }
.pb-form button { flex-shrink: 0; height: 42px; padding: 0 22px; }
.pb-form .pb-send { background: var(--pb-primary); border-color: var(--pb-primary); color: var(--pb-primary-contrast); }
.pb-form .pb-send:hover { filter: brightness(.94); background: var(--pb-primary); border-color: var(--pb-primary); color: var(--pb-primary-contrast); }

/* Narrow panels (widget iframe is 380px wide, phones): compact header so the product name never truncates. */
.pb-compact .pb-header, .pb-header.pb-narrow { padding: 10px 12px; gap: 8px; }
.pb-compact .pb-icon { width: 28px; height: 28px; }
.pb-compact .pb-title { font-size: 15px; }
.pb-compact .pb-actions { gap: 6px; }
.pb-compact .pb-actions button { padding: 4px 10px; font-size: 12px; }
.pb-compact .pb-actions .pb-close { width: 28px; height: 28px; font-size: 20px; padding: 0; }
.pb-compact .pb-messages { padding: 16px 12px; }
.pb-compact .pb-form { padding: 10px 12px; }

@media (max-width: 520px) {
  .pb-header { padding: 10px 12px; gap: 8px; }
  .pb-icon { width: 30px; height: 30px; }
  .pb-title { font-size: 16px; }
  .pb-actions button { padding: 4px 12px; font-size: 12px; }
  .pb-page { padding: 0; }
  .pb-topbar { padding: 8px 12px 0; }
  .pb-topbar + .pb-page { padding-top: 8px; }
  .pb-chat { border-radius: 0; border-left: 0; border-right: 0; border-top: 0; border-bottom: 0; box-shadow: none; }
  .pb-msg { max-width: 94%; }
  .pb-messages { padding: 16px 12px; }
  .pb-form { padding: 10px 12px; }
}
.pb-chat [hidden] { display: none !important; }
