/* Pointcoin AI hosted chat styles. Reuses Pointcoin tokens:
   Instrument Sans, brand #314a6b, solid CTA (matches /dashboard .cta-button), pill radius, 16px cards. */
@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&display=swap');

:root {
  --pai-brand: #314a6b;
  --pai-bg: #f5f5f5;
  --pai-card: #ffffff;
  --pai-border: #e0e0e0;
  --pai-text: #1f2733;
  --pai-muted: #5f6368;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

.pai-body {
  font-family: 'Instrument Sans', system-ui, -apple-system, sans-serif;
  background: var(--pai-bg);
  color: var(--pai-text);
  min-height: 100vh;
  padding-bottom: 140px;
}

/* Header */
.pai-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--pai-card);
  border-bottom: 1px solid var(--pai-border);
}
.pai-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  white-space: nowrap;
  text-decoration: none;
  color: var(--pai-brand);
  font-weight: 600;
  font-size: 18px;
}
.pai-ghost-btn {
  background: rgba(0, 0, 0, 0.06);
  border: none;
  color: #333;
  padding: 8px 16px;
  border-radius: 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
}
.pai-ghost-btn:hover { background: rgba(0, 0, 0, 0.12); }
.pai-ghost-btn[hidden] { display: none; }
/* Full label on desktop; "Help" is the phone label (set in the mobile query). */
.pai-help-short { display: none; }
/* Header actions: sign-in CTA for logged-out visitors */
.pai-header-actions { display: flex; align-items: center; gap: 10px; flex: 0 1 auto; min-width: 0; }
.pai-signin-btn {
  background: var(--pai-brand);
  color: #fff;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
}
.pai-signin-btn:hover { background: #253a52; color: #fff; }

/* Post-pick sign-up modal (logged-out conversion): email capture form */
.pai-signup-sub { font-size: 14px; color: var(--pai-muted); margin-bottom: 20px; line-height: 1.5; }

/* Reward pop: the "+N Pointcoins earned" card that floats above the sign-up
   card after a logged-out pick. Navy card + gold coin ring, pops in, then a
   light shine sweeps across it once. */
.pai-modal-stack {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 460px;
  padding: 0 20px;
}
.pai-modal-stack .pai-modal-card { width: 100%; }
.pai-reward-pop {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, #314a6b 0%, #1f3550 100%);
  color: #fff;
  box-shadow: 0 14px 36px rgba(31, 53, 80, 0.45);
  animation: pai-reward-in 0.55s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.pai-reward-pop[hidden] { display: none; }
.pai-reward-pop::after {
  content: '';
  position: absolute;
  top: -40%;
  left: -60%;
  width: 40%;
  height: 180%;
  background: linear-gradient(100deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.28) 50%, rgba(255,255,255,0) 100%);
  transform: skewX(-18deg);
  animation: pai-reward-shine 1.4s ease-out 0.5s 1 both;
  pointer-events: none;
}
.pai-reward-coin {
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 30%, #ffe9a3 0%, #f4c542 55%, #d99a17 100%);
  box-shadow: 0 0 0 3px rgba(255, 221, 120, 0.35), 0 6px 16px rgba(0, 0, 0, 0.3);
  animation: pai-coin-spin 1.1s ease-out 0.15s 1 both;
}
.pai-reward-coin img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: block;
  background: #fff;
}
.pai-reward-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pai-reward-amount {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.pai-reward-amount .pai-reward-plus { color: #ffd76a; }
.pai-reward-sub { font-size: 13px; color: rgba(255, 255, 255, 0.82); line-height: 1.4; }
.pai-reward-spark {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffd76a;
  opacity: 0;
  animation: pai-spark 1.2s ease-out 0.35s 1 both;
  pointer-events: none;
}
.pai-reward-spark:nth-child(1) { top: 10px; left: 58px; animation-delay: 0.3s; }
.pai-reward-spark:nth-child(2) { top: 44px; left: 66px; animation-delay: 0.5s; width: 4px; height: 4px; }
.pai-reward-spark:nth-child(3) { top: 6px; left: 20px; animation-delay: 0.65s; width: 5px; height: 5px; }
.pai-reward-spark:nth-child(4) { top: 52px; left: 14px; animation-delay: 0.8s; width: 4px; height: 4px; }
@keyframes pai-reward-in {
  0%   { opacity: 0; transform: translateY(18px) scale(0.85); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes pai-reward-shine {
  0%   { left: -60%; }
  100% { left: 140%; }
}
@keyframes pai-coin-spin {
  0%   { transform: rotateY(0deg) scale(0.6); }
  60%  { transform: rotateY(360deg) scale(1.1); }
  100% { transform: rotateY(360deg) scale(1); }
}
@keyframes pai-spark {
  0%   { opacity: 0; transform: translateY(0) scale(0.4); }
  30%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-18px) scale(1.2); }
}
@media (prefers-reduced-motion: reduce) {
  .pai-reward-pop, .pai-reward-pop::after, .pai-reward-coin, .pai-reward-spark { animation: none; }
  .pai-reward-spark { display: none; }
}
.pai-signup-form { display: flex; flex-direction: column; gap: 12px; }
.pai-signup-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--pai-border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 16px;
  outline: none;
}
.pai-signup-input:focus { border-color: var(--pai-brand); }
.pai-signup-terms {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--pai-muted);
  line-height: 1.5;
  text-align: left;
}
.pai-signup-terms input { margin-top: 2px; flex-shrink: 0; }
.pai-signup-terms a { color: var(--pai-brand); text-decoration: none; }
.pai-signup-terms a:hover { text-decoration: underline; }
.pai-signup-btn { width: 100%; border: none; cursor: pointer; font-size: 15px; }

/* Layout */
.pai-main {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* Embed mode (loaded inside the extension's in-page modal): no site header */
.pai-embed .pai-main { padding-top: 16px; }
/* Dashboard (desktop): room under the "Ways to Earn" pull-tab that hangs over the frame */
.pai-dash-tab .pai-main { padding-top: 48px; }

/* Thread */
.pai-thread { display: flex; flex-direction: column; gap: 16px; }
.pai-msg { display: flex; }
/* Offset for scrollResponseTop(): keep response tops clear of the sticky header. */
.pai-msg, #pai-duel { scroll-margin-top: 76px; }
.pai-msg-user { justify-content: flex-end; }
.pai-msg-assistant { justify-content: flex-start; }
/* Follow-up message: rises in as the thread slides up to make room for the answer */
.pai-msg-lift .pai-msg-content { animation: pai-lift 0.28s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes pai-lift { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .pai-msg-lift .pai-msg-content { animation: none; } }
.pai-msg-content {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 15px;
  white-space: normal;
  word-wrap: break-word;
}
.pai-msg-user .pai-msg-content {
  background: var(--pai-brand);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.pai-msg-assistant .pai-msg-content {
  background: var(--pai-card);
  border: 1px solid var(--pai-border);
  border-bottom-left-radius: 4px;
}
.pai-msg-content code {
  background: rgba(0, 0, 0, 0.07);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
}
.pai-code {
  background: #1f2733;
  color: #e6edf3;
  padding: 12px 14px;
  border-radius: 10px;
  overflow-x: auto;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  margin: 8px 0;
}

/* Rendered Markdown blocks (used in chat bubbles and duel option bodies) */
.pai-msg-content p,
.pai-option-body p { margin: 0 0 8px; }
.pai-msg-content p:last-child,
.pai-option-body p:last-child { margin-bottom: 0; }
.pai-msg-content ul,
.pai-msg-content ol,
.pai-option-body ul,
.pai-option-body ol { margin: 4px 0 8px; padding-left: 22px; }
.pai-msg-content li,
.pai-option-body li { margin: 3px 0; }
.pai-msg-content h1,
.pai-msg-content h2,
.pai-msg-content h3,
.pai-option-body h1,
.pai-option-body h2,
.pai-option-body h3 {
  font-size: 1.05em;
  font-weight: 600;
  margin: 10px 0 4px;
  line-height: 1.3;
}
.pai-msg-content h1:first-child,
.pai-msg-content h2:first-child,
.pai-msg-content h3:first-child,
.pai-option-body h1:first-child,
.pai-option-body h2:first-child,
.pai-option-body h3:first-child { margin-top: 0; }

.pai-msg-content a,
.pai-option-body a {
  color: #4a6cf7;
  text-decoration: underline;
  word-break: break-word;
}

/* Links inside the navy user bubble: blue is unreadable, use white */
.pai-msg-user .pai-msg-content a,
.pai-msg-user .pai-msg-content a:hover {
  color: #fff;
}

/* Tables */
.pai-table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 13px;
  display: block;
  max-width: 100%;
  overflow-x: auto;
}
.pai-table th,
.pai-table td {
  border: 1px solid var(--pai-border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.pai-table th {
  background: rgba(0, 0, 0, 0.04);
  font-weight: 600;
}
.pai-msg-content a:hover,
.pai-option-body a:hover { color: #314a6b; }

/* Typing indicator (shown in a streaming target until its first token) */
.pai-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
}
.pai-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9aa3b0;
  display: inline-block;
  animation: pai-typing-bounce 1.2s infinite ease-in-out both;
}
.pai-typing span:nth-child(1) { animation-delay: -0.24s; }
.pai-typing span:nth-child(2) { animation-delay: -0.12s; }
.pai-typing span:nth-child(3) { animation-delay: 0s; }

@keyframes pai-typing-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Duel */
.pai-duel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}
/* hidden attribute must win over the grid/flex display above */
.pai-duel[hidden],
.pai-option[hidden] { display: none; }
/* after a pick, the surviving option spans the full width */
.pai-duel-picked { grid-template-columns: 1fr; }
.pai-option {
  display: flex;
  flex-direction: column;
  background: var(--pai-card);
  border: 1px solid var(--pai-border);
  border-radius: 16px;
  padding: 16px;
}
.pai-option-head {
  font-weight: 600;
  color: var(--pai-brand);
  margin-bottom: 10px;
  font-size: 14px;
  letter-spacing: 0.3px;
}
.pai-option-body {
  flex: 1;
  line-height: 1.5;
  font-size: 14px;
  word-wrap: break-word;
  min-height: 40px;
}
.pai-pick-btn {
  margin-top: 14px;
  background-color: #314a6b;
  color: #fff;
  border: 2px solid transparent;
  padding: 12px 18px;
  border-radius: 25px;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(49, 74, 107, 0.25);
  transition: all 0.3s ease;
}
.pai-pick-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 35px rgba(49, 74, 107, 0.35);
}
.pai-pick-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pai-pick-btn.pai-picked { border-color: rgba(49, 74, 107, 0.4); }

/* Feedback chips */
.pai-feedback {
  margin-top: 18px;
  background: var(--pai-card);
  border: 1px solid var(--pai-border);
  border-radius: 16px;
  padding: 18px;
}
.pai-feedback-q { font-weight: 600; margin-bottom: 12px; }
.pai-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.pai-chip {
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid var(--pai-border);
  color: #333;
  padding: 8px 14px;
  border-radius: 20px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pai-chip:hover { background: rgba(0, 0, 0, 0.09); color: #1f2733; }
.pai-chip-on {
  background: var(--pai-brand);
  color: #fff;
  border-color: var(--pai-brand);
}
/* keep selected chips readable on hover (white text stays on a dark fill) */
.pai-chip-on:hover {
  background: #253a52;
  border-color: #253a52;
  color: #fff;
}

/* Welcome / sample questions (empty-state lander) */
.pai-welcome {
  margin-top: 18px;
  text-align: center;
}
.pai-welcome h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--pai-text);
  margin-bottom: 18px;
}
.pai-samples {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.pai-sample {
  background: var(--pai-card);
  border: 1px solid var(--pai-border);
  color: var(--pai-text);
  padding: 10px 16px;
  border-radius: 20px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pai-sample:hover {
  background: var(--pai-brand);
  border-color: var(--pai-brand);
  color: #fff;
}

/* CTA */
.pai-cta {
  display: inline-block;
  background-color: #314a6b;
  color: #fff;
  border: 2px solid transparent;
  padding: 15px 30px;
  border-radius: 25px;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  box-shadow: 0 8px 25px rgba(49, 74, 107, 0.25);
  transition: all 0.3s ease;
  cursor: pointer;
}
.pai-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 35px rgba(49, 74, 107, 0.35);
}
.pai-cta:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* Composer: one rounded box. The field must be allowed to shrink (min-width: 0)
   or the mic and send button are pushed outside the box on a phone. */
.pai-form {
  position: fixed;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 16px;
  right: 16px;
  z-index: 20;
  display: flex;
  align-items: flex-end; /* buttons hug the bottom as the box grows upward */
  gap: 6px;
  max-width: 820px;
  margin: 0 auto;
  padding: 8px 8px 8px 16px;
  background: #fff;
  border: 1px solid var(--pai-border);
  border-radius: 16px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
}
/* Placeholder never wraps (a wrapped one grew the empty composer to two lines) */
.pai-input::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pai-input {
  flex: 1 1 0;
  min-width: 0;
  width: 100%;
  display: block;
  padding: 10px 0;
  border: none;
  border-radius: 0;
  font-family: inherit;
  font-size: 16px; /* >=16px keeps iOS from zooming the field on focus */
  line-height: 1.4;
  background: transparent;
  outline: none;
  color: var(--pai-text);
  /* Auto-growing composer (autogrow.js): wraps long questions and grows up to
     max-height, then scrolls inside. Never a horizontal scroll. */
  resize: none;
  overflow-y: hidden;
  max-height: 160px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.pai-input:focus { box-shadow: none; }
.pai-input:disabled { opacity: 0.7; }
.pai-input::placeholder { color: var(--pai-muted); }
/* Composer while a duel is unresolved: looks active (invites a click) but is
   readonly; the click surfaces a "pick first" nudge rather than typing. */
.pai-input-locked { cursor: pointer; }

/* Attention pulse drawn on the options (or feedback card) when the user tries to
   continue the conversation before resolving the duel. */
@keyframes pai-nudge-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(49, 74, 107, 0.45); }
  70%  { box-shadow: 0 0 0 10px rgba(49, 74, 107, 0); }
  100% { box-shadow: 0 0 0 0 rgba(49, 74, 107, 0); }
}
.pai-nudge {
  border-radius: 16px;
  animation: pai-nudge-pulse 0.9s ease-out 2;
}
.pai-send, .pai-mic {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  padding: 0;
  border: none;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.pai-send svg, .pai-mic svg { display: block; width: 20px; height: 20px; }
.pai-send {
  background: var(--pai-brand);
  color: #fff;
}
.pai-send:hover:not(:disabled) { background: #253a52; }
.pai-send:disabled { opacity: 0.6; cursor: not-allowed; }
.pai-prompts { flex: 0 0 42px; width: 42px; height: 42px; }
.pai-mic { background: transparent; color: var(--pai-brand); }
.pai-mic:hover { background: #eef2f7; }
.pai-mic[hidden] { display: none; }
.pai-mic.recording { color: #c0392b; animation: pai-mic-pulse 1.2s infinite; }
.pai-mic .pai-mic-stop { display: none; }
.pai-mic.recording .pai-mic-icon { display: none; }
.pai-mic.recording .pai-mic-stop { display: block; }
.pai-form { flex-wrap: wrap; }
.pai-listen {
  flex: 1 0 100%;
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 600;
  color: #c0392b;
  text-align: left;
}
.pai-listen[hidden] { display: none; }
@keyframes pai-mic-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Message actions: copy under every bubble, plus "save prompt" under your own.
   Hidden until hover on a mouse; always visible with 44px targets on touch. */
.pai-msg { flex-wrap: wrap; }
.pai-msg-user { justify-content: flex-end; }
.pai-actions {
  flex: 0 0 100%;
  display: flex;
  gap: 2px;
  margin-top: 2px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.pai-msg-user .pai-actions { justify-content: flex-end; }
.pai-msg:hover .pai-actions, .pai-actions:focus-within { opacity: 1; }
.pai-act {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: transparent;
  color: var(--pai-muted);
  padding: 4px 8px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  min-height: 28px;
}
.pai-act svg { width: 14px; height: 14px; display: block; }
.pai-act:hover { background: rgba(0, 0, 0, 0.06); color: var(--pai-text); }
.pai-act.copied { color: #1e6b36; }
.pai-option-head { display: flex; align-items: center; justify-content: space-between; }
.pai-option-copy {
  border: none;
  background: transparent;
  color: var(--pai-muted);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.pai-option-copy svg { width: 15px; height: 15px; }
.pai-option:hover .pai-option-copy, .pai-option-copy:focus-visible { opacity: 1; }
.pai-option-copy:hover { background: rgba(0, 0, 0, 0.06); color: var(--pai-text); }
.pai-option-copy.copied { color: #1e6b36; opacity: 1; }
@media (hover: none) {
  .pai-actions { opacity: 1; }
  .pai-act { min-height: 40px; padding: 6px 12px; font-size: 13px; }
  .pai-option-copy { opacity: 1; width: 40px; height: 40px; }
}

/* Read-only / empty */
.pai-readonly-banner {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.pai-badge {
  background: rgba(49, 74, 107, 0.08);
  color: var(--pai-brand);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}
.pai-empty { text-align: center; padding: 80px 20px; }
.pai-empty h1 { margin-bottom: 12px; color: var(--pai-brand); }
.pai-empty p { color: var(--pai-muted); margin-bottom: 24px; }

/* Earn celebration (rewarded pick): same language as the sign-up reward pop */
.pai-earn {
  position: fixed;
  left: 50%;
  bottom: 90px;
  z-index: 65;
  width: min(360px, calc(100% - 32px));
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px 12px 12px;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(135deg, #314a6b 0%, #1f3550 100%);
  color: #fff;
  box-shadow: 0 18px 40px rgba(31, 53, 80, 0.45), inset 0 0 0 1px rgba(255, 215, 106, 0.22);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  animation: pai-earn-in 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.pai-earn.pai-earn-out { animation: pai-earn-out 0.26s ease-in both; }
.pai-earn::after {
  content: '';
  position: absolute;
  top: -40%;
  left: -60%;
  width: 40%;
  height: 180%;
  background: linear-gradient(100deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.26) 50%, rgba(255,255,255,0) 100%);
  transform: skewX(-18deg);
  animation: pai-reward-shine 1.2s ease-out 0.45s 1 both;
  pointer-events: none;
}
@keyframes pai-earn-in {
  0%   { opacity: 0; transform: translate(-50%, 24px) scale(0.9); }
  100% { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@keyframes pai-earn-out {
  0%   { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, 16px) scale(0.96); }
}
.pai-earn-coin {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 30%, #ffe9a3 0%, #f4c542 55%, #d99a17 100%);
  box-shadow: 0 0 0 3px rgba(255, 221, 120, 0.3), 0 6px 14px rgba(0, 0, 0, 0.3);
  animation: pai-coin-spin 1s ease-out 0.12s 1 both;
}
.pai-earn-coin img { width: 34px; height: 34px; border-radius: 50%; background: #fff; display: block; }
.pai-earn-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pai-earn-amount { font-size: 16px; font-weight: 600; line-height: 1.2; white-space: nowrap; }
.pai-earn-n {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #ffd76a;
  font-variant-numeric: tabular-nums;
}
.pai-earn-sub { font-size: 13px; color: rgba(255, 255, 255, 0.78); white-space: nowrap; }
.pai-earn-sub strong { color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
.pai-earn-spark {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffd76a;
  opacity: 0;
  animation: pai-spark 1.1s ease-out 0.3s 1 both;
  pointer-events: none;
}
.pai-earn-spark:nth-child(1) { top: 8px;  left: 52px; animation-delay: 0.28s; }
.pai-earn-spark:nth-child(2) { top: 40px; left: 60px; animation-delay: 0.45s; width: 4px; height: 4px; }
.pai-earn-spark:nth-child(3) { top: 4px;  left: 16px; animation-delay: 0.6s;  width: 5px; height: 5px; }
.pai-earn-spark:nth-child(4) { top: 48px; left: 10px; animation-delay: 0.72s; width: 4px; height: 4px; }
.pai-earn-spark:nth-child(5) { top: 14px; left: 118px; animation-delay: 0.9s; width: 4px; height: 4px; }
@media (prefers-reduced-motion: reduce) {
  .pai-earn, .pai-earn.pai-earn-out, .pai-earn::after, .pai-earn-coin, .pai-earn-spark { animation: none; }
  .pai-earn { transform: translateX(-50%); }
  .pai-earn-spark { display: none; }
}

/* Toast */
.pai-toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1f2733;
  color: #fff;
  padding: 14px 22px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 50;
  max-width: 90%;
}
.pai-toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Sticky pick nudge: shown instead of auto-scrolling when a duel is ready */
#pai-pick-nudge {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--pai-brand);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  max-width: calc(100% - 32px);
  /* One line: label + arrow */
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  font-family: inherit;
}
#pai-pick-nudge span { overflow: hidden; text-overflow: ellipsis; }
#pai-pick-nudge .pc-ico { font-size: 16px; }
#pai-pick-nudge[hidden] { display: none; }
@media (max-width: 480px) { #pai-pick-nudge { font-size: 13px; padding: 10px 16px; gap: 6px; } }
#pai-pick-nudge:hover { filter: brightness(1.08); }

@media (max-width: 768px) {
  /* One compact row. Buttons must not shrink, or "Sign in" and the brand wrap. */
  .pai-header {
    padding: 10px 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    gap: 8px;
  }
  .pai-brand { font-size: 16px; }
  .pai-header-actions { gap: 6px; justify-content: flex-end; }
  .pai-ghost-btn,
  .pai-signin-btn {
    flex: 0 0 auto;
    padding: 6px 10px;
    font-size: 13px;
  }
  .pai-help-long { display: none; }
  .pai-help-short { display: inline; }

  /* Duel becomes a swipeable snap carousel: each option is 85% wide so the
     next option peeks in and users know there is a second choice. Desktop
     keeps the side-by-side grid. */
  .pai-duel {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 12px;
    margin-left: -16px;
    margin-right: -16px;
    padding: 4px 16px 12px;
  }
  .pai-option { flex: 0 0 85%; scroll-snap-align: center; }
  /* After a pick only the winner remains: back to a full-width single card. */
  .pai-duel-picked {
    display: grid;
    grid-template-columns: 1fr;
    overflow: visible;
    margin: 20px 0 0;
    padding: 0;
  }
  .pai-duel-picked .pai-option { flex: none; }
  .pai-msg-content { max-width: 90%; }

  /* Empty lander: no rail. Reads top-down like the home page — title, then
     the ask box, then the sample questions underneath it — and starts near
     the top of the screen rather than floating in the vertical middle.
     Once a message exists the composer pins back to the bottom. */
  .pai-main:not(:has(.pai-msg)) {
    min-height: calc(100dvh - 64px);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: clamp(24px, 9vh, 80px);
  }
  .pai-body:has(.pai-main:not(:has(.pai-msg))) { padding-bottom: 24px; }
  /* The welcome wrapper dissolves so its title and chips can be ordered
     around the composer (title 0, composer 1, chips 2). app.js hides the
     wrapper with an inline display:none once a question is sent, which
     still wins over display:contents. */
  .pai-main:not(:has(.pai-msg)) .pai-welcome { display: contents; }
  .pai-main:not(:has(.pai-msg)) .pai-welcome h2 {
    order: 0;
    text-align: center;
    margin: 0 0 16px;
    font-size: 19px;
  }
  .pai-main:not(:has(.pai-msg)) .pai-form {
    order: 1;
    position: static;
    margin: 0;
  }
  .pai-main:not(:has(.pai-msg)) .pai-samples {
    order: 2;
    margin-top: 16px;
    justify-content: center;
  }
  .pai-main:not(:has(.pai-msg)) .pai-thread { display: none; }
}

/* How-it-works modal */
.pai-modal[hidden] { display: none; }
.pai-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pai-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.pai-modal-card {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 16px;
  max-width: 460px;
  width: calc(100% - 40px);
  padding: 28px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.pai-modal-card h2 {
  color: var(--pai-brand);
  font-size: 20px;
  margin-bottom: 14px;
}
.pai-modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: #8a9099;
  cursor: pointer;
}
.pai-modal-close:hover { color: #5f6368; }
.pai-help-list {
  margin: 0;
  padding-left: 20px;
}
.pai-help-list li {
  margin: 10px 0;
  line-height: 1.5;
  font-size: 14px;
}

/* Gravity contextual ad — sits in the slot between the duel and the compose bar */
.pai-ad {
  margin-top: 18px;
  background: var(--pai-card);
  border: 1px solid var(--pai-border);
  border-radius: 16px;
  padding: 16px 18px;
  position: relative;
}
.pai-ad[hidden] { display: none; }
.pai-ad-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--pai-muted);
  margin-bottom: 8px;
}
.pai-ad-body {
  display: block;
  text-decoration: none;
  color: inherit;
}
/* Anchor body (Gravity) and SDK-clickable body (Velocity, whose SDK opens the
   click destination on the target) both get the pointer/hand cursor. */
a.pai-ad-body,
.pai-ad-body.is-clickable { cursor: pointer; }
.pai-ad-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.pai-ad-favicon { border-radius: 4px; display: block; }
.pai-ad-brand { font-size: 13px; color: var(--pai-muted); }
.pai-ad-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.pai-ad-text { font-size: 14px; line-height: 1.5; color: var(--pai-text); margin-bottom: 12px; }
.pai-ad-cta {
  display: inline-flex;
  align-items: center;
  background: var(--pai-brand);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
}
a.pai-ad-body:hover .pai-ad-cta,
.pai-ad-body.is-clickable:hover .pai-ad-cta { background: #253a52; }
.pai-ad-feedback {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}
/* Inline Lucide icons (lucide.dev): sized by font-size, colored by currentColor */
.pc-ico { width: 1em; height: 1em; display: inline-block; vertical-align: -0.125em; flex-shrink: 0; }
.pai-ad-fb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--pai-brand);
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid var(--pai-border);
  border-radius: 16px;
  padding: 4px 10px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pai-ad-fb:hover:not(:disabled) { background: rgba(0, 0, 0, 0.09); }
.pai-ad-fb:disabled { cursor: default; opacity: 0.55; }
.pai-ad-fb-on { opacity: 1; border-color: var(--pai-brand); background: rgba(49, 74, 107, 0.12); }
