/* دستیار عمومی — Premium minimal conversational UI */

.pa-root {
  --pa-brand: #7c3aed;
  --pa-brand-hover: #6d28d9;
  --pa-brand-soft: rgba(124, 58, 237, 0.1);
  --pa-brand-line: rgba(124, 58, 237, 0.18);
  --pa-surface: #ffffff;
  --pa-surface-2: #f6f7f9;
  --pa-ink: #111827;
  --pa-ink-muted: #6b7280;
  --pa-line: rgba(17, 24, 39, 0.08);
  --pa-radius-xl: 20px;
  --pa-radius-lg: 14px;
  --pa-shadow: 0 8px 32px rgba(17, 24, 39, 0.1), 0 2px 8px rgba(17, 24, 39, 0.04);
  --pa-motion: 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  --pa-motion-fast: 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  --pa-system-limit-bg: linear-gradient(
    145deg,
    rgba(124, 58, 237, 0.07) 0%,
    rgba(99, 102, 241, 0.04) 48%,
    rgba(248, 250, 252, 0.9) 100%
  );
  --pa-system-limit-border: rgba(124, 58, 237, 0.14);
  --pa-system-limit-ink: #5b21b6;
  --pa-system-limit-muted: #6b6280;
  --pa-system-error-bg: linear-gradient(
    145deg,
    rgba(244, 63, 94, 0.06) 0%,
    rgba(251, 113, 133, 0.03) 55%,
    rgba(255, 251, 252, 0.95) 100%
  );
  --pa-system-error-border: rgba(244, 63, 94, 0.16);
  --pa-system-error-ink: #9f1239;
  --pa-fab-h: 52px;
  --pa-edge: max(20px, env(safe-area-inset-inline-end, 20px));
  --pa-bottom: max(20px, env(safe-area-inset-bottom, 20px));

  position: fixed;
  inset: 0;
  z-index: 10050;
  pointer-events: none;
  font-family: Vazirmatn, system-ui, sans-serif;
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
  color: var(--pa-ink);
}

.pa-root[hidden] {
  display: none !important;
}

.pa-root *,
.pa-root *::before,
.pa-root *::after {
  box-sizing: border-box;
}

/* Backdrop — mobile sheet only */
.pa-backdrop {
  position: fixed;
  inset: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--pa-motion), visibility var(--pa-motion);
  pointer-events: none;
  cursor: pointer;
}

@media (min-width: 641px) {
  .pa-backdrop {
    display: none;
  }
}

.pa-root.is-open .pa-backdrop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Dock — mobile: children stay fixed; desktop: shared draggable anchor */
.pa-dock {
  display: contents;
}

@media (min-width: 641px) {
  .pa-dock {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    position: fixed;
    inset-inline-end: var(--pa-edge);
    inset-block-end: var(--pa-bottom);
    z-index: 10051;
    pointer-events: none;
  }

  .pa-dock > * {
    pointer-events: auto;
  }

  .pa-dock.is-custom-position {
    inset: auto;
    right: auto;
    bottom: auto;
  }

  .pa-root.is-open .pa-dock {
    gap: 0;
  }

  .pa-root.is-dragging,
  .pa-root.is-dragging * {
    user-select: none;
  }

  .pa-root.is-dragging .pa-dock,
  .pa-root.is-dragging .pa-fab,
  .pa-root.is-dragging .pa-panel {
    transition: none !important;
    animation: none !important;
  }
}

/* Launcher pill */
.pa-fab {
  position: fixed;
  inset-inline-end: var(--pa-edge);
  inset-block-end: var(--pa-bottom);
  min-height: var(--pa-fab-h);
  min-width: var(--pa-fab-h);
  padding: 8px 14px 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: linear-gradient(145deg, #9333ea 0%, #7c3aed 48%, #6d28d9 100%);
  color: #fff;
  box-shadow:
    0 0 0 1px rgba(124, 58, 237, 0.12),
    0 4px 14px rgba(109, 40, 217, 0.28),
    0 10px 28px rgba(124, 58, 237, 0.16);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  z-index: 10052;
  isolation: isolate;
  transition:
    transform var(--pa-motion-fast),
    box-shadow var(--pa-motion-fast),
    opacity var(--pa-motion-fast);
  animation: pa-fab-idle 4.5s ease-in-out infinite;
}

.pa-fab__pulse {
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  background: radial-gradient(ellipse at 50% 50%, rgba(167, 139, 250, 0.45), transparent 68%);
  opacity: 0.55;
  z-index: -1;
  animation: pa-fab-glow 3.2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pa-fab-idle {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-1px);
  }
}

@keyframes pa-fab-glow {
  0%,
  100% {
    opacity: 0.4;
    transform: scale(1);
  }
  50% {
    opacity: 0.72;
    transform: scale(1.03);
  }
}

.pa-fab__content {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.pa-bot-icon {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.pa-fab__icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.35);
  overflow: hidden;
  padding: 1px;
}

.pa-fab__copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 0;
  text-align: right;
}

.pa-fab__title {
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
}

.pa-fab__subtitle {
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.35;
  opacity: 0.88;
  white-space: nowrap;
}

.pa-fab__badge {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  display: grid;
  place-items: center;
}

.pa-fab__badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.25);
  animation: pa-status-pulse 2.4s ease-in-out infinite;
}

@keyframes pa-status-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.75;
    transform: scale(0.92);
  }
}

.pa-fab:hover {
  transform: translateY(-3px);
  box-shadow:
    0 0 0 1px rgba(124, 58, 237, 0.18),
    0 6px 20px rgba(109, 40, 217, 0.35),
    0 14px 36px rgba(124, 58, 237, 0.22);
  animation: none;
}

.pa-fab:active {
  transform: translateY(-1px) scale(0.99);
}

.pa-fab:focus-visible {
  outline: 2px solid var(--pa-brand);
  outline-offset: 3px;
}

.pa-root.is-open .pa-fab {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(0.94);
  animation: none;
}

@media (min-width: 641px) {
  .pa-fab {
    position: relative;
    inset: auto;
    cursor: grab;
  }

  .pa-root.is-open .pa-fab {
    position: absolute;
    width: 0;
    height: 0;
    min-height: 0;
    min-width: 0;
    padding: 0;
    margin: 0;
    border-width: 0;
    overflow: hidden;
    opacity: 0;
    transform: none;
  }

  .pa-root.is-dragging .pa-fab,
  .pa-root.is-dragging .pa-head {
    cursor: grabbing;
  }
}

/* Panel */
.pa-panel {
  position: fixed;
  inset-inline-end: var(--pa-edge);
  inset-block-end: var(--pa-bottom);
  width: min(432px, calc(100vw - 24px));
  height: min(620px, calc(100dvh - var(--pa-bottom) - 28px));
  background: var(--pa-surface);
  border: 1px solid var(--pa-line);
  border-radius: var(--pa-radius-xl);
  box-shadow: var(--pa-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: none;
  z-index: 10051;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.98);
  transition:
    opacity var(--pa-motion),
    transform var(--pa-motion),
    visibility var(--pa-motion);
}

.pa-root.is-open .pa-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.pa-panel[hidden] {
  display: none !important;
}

@media (min-width: 641px) {
  .pa-panel {
    position: relative;
    inset: auto;
    width: min(432px, calc(100vw - 48px));
    height: min(620px, calc(100dvh - 48px));
  }
}

/* Header */
.pa-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--pa-line);
  background: var(--pa-surface);
}

@media (min-width: 641px) {
  .pa-head {
    cursor: grab;
    touch-action: none;
  }

  .pa-head__tools {
    cursor: default;
  }
}

.pa-head__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.pa-head__avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--pa-line);
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 2px;
}

.pa-head__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pa-head__title {
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pa-head__status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--pa-ink-muted);
  line-height: 1.3;
  transition: color var(--pa-motion-fast);
}

.pa-head__status-dot {
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
  transition: background var(--pa-motion-fast), box-shadow var(--pa-motion-fast);
}

.pa-root.is-waiting .pa-head__status {
  color: var(--pa-brand-hover);
}

.pa-root.is-waiting .pa-head__status-dot {
  background: var(--pa-brand);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
  animation: pa-status-pulse 1.2s ease-in-out infinite;
}

.pa-head__tools {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.pa-icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--pa-ink-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--pa-motion-fast), color var(--pa-motion-fast);
}

.pa-icon-btn:hover {
  background: var(--pa-surface-2);
  color: var(--pa-ink);
}

.pa-icon-btn:focus-visible {
  outline: 2px solid rgba(124, 58, 237, 0.35);
  outline-offset: 1px;
}

/* Thread */
.pa-thread {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.pa-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, var(--pa-surface) 0%, var(--pa-surface-2) 100%);
  -webkit-overflow-scrolling: touch;
}

.pa-jump {
  position: absolute;
  inset-inline-end: 16px;
  inset-block-end: 12px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--pa-line);
  border-radius: 50%;
  background: var(--pa-surface);
  color: var(--pa-ink-muted);
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.08);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: opacity var(--pa-motion-fast), transform var(--pa-motion-fast), color var(--pa-motion-fast);
  z-index: 2;
}

.pa-jump:hover {
  color: var(--pa-brand);
  transform: translateY(-1px);
}

.pa-jump:focus-visible {
  outline: 2px solid rgba(124, 58, 237, 0.35);
  outline-offset: 2px;
}

/* Welcome */
.pa-welcome {
  margin: auto 0;
  padding: 8px 4px 16px;
  text-align: center;
  max-width: 100%;
  animation: pa-welcome-in 0.32s var(--pa-motion) both;
}

.pa-root.has-chat .pa-welcome {
  display: none;
}

@keyframes pa-welcome-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pa-welcome__mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, #faf5ff 0%, #ffffff 100%);
  border: 1px solid var(--pa-brand-line);
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.1);
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 3px;
}

.pa-bot-icon--welcome {
  transform: scale(1.02);
}

.pa-welcome__title {
  margin: 0 0 10px;
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.45;
  color: var(--pa-ink);
}

.pa-welcome__wave {
  display: inline-block;
  animation: pa-wave 2.8s ease-in-out infinite;
  transform-origin: 70% 70%;
}

@keyframes pa-wave {
  0%,
  100% {
    transform: rotate(0deg);
  }
  18% {
    transform: rotate(12deg);
  }
  36% {
    transform: rotate(-6deg);
  }
  54% {
    transform: rotate(8deg);
  }
}

.pa-welcome__lead {
  margin: 0 0 10px;
  font-size: 0.84rem;
  line-height: 1.75;
  color: var(--pa-ink-muted);
  text-align: center;
  max-width: 34em;
  margin-inline: auto;
}

.pa-welcome__privacy {
  margin: 0 0 18px;
  font-size: 0.68rem;
  line-height: 1.5;
  color: #9ca3af;
}

.pa-welcome__suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: right;
}

.pa-chip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--pa-line);
  background: var(--pa-surface);
  color: var(--pa-ink);
  border-radius: 14px;
  padding: 11px 12px;
  font-size: 0.8rem;
  line-height: 1.6;
  cursor: pointer;
  text-align: right;
  transition:
    background var(--pa-motion-fast),
    border-color var(--pa-motion-fast),
    color var(--pa-motion-fast),
    transform var(--pa-motion-fast),
    box-shadow var(--pa-motion-fast);
}

.pa-chip__icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin-top: 1px;
  border-radius: 8px;
  background: var(--pa-brand-soft);
  color: var(--pa-brand);
  display: grid;
  place-items: center;
}

.pa-chip__text {
  flex: 1;
  min-width: 0;
}

.pa-chip:hover {
  background: var(--pa-brand-soft);
  border-color: var(--pa-brand-line);
  color: var(--pa-brand-hover);
  box-shadow: 0 2px 10px rgba(124, 58, 237, 0.08);
  transform: translateY(-1px);
}

.pa-chip:active {
  transform: scale(0.99);
}

.pa-chip:focus-visible {
  outline: 2px solid rgba(124, 58, 237, 0.35);
  outline-offset: 2px;
}

/* Messages */
.pa-msg {
  max-width: 88%;
  font-size: 0.875rem;
  line-height: 1.8;
  word-break: break-word;
  overflow-wrap: anywhere;
  animation: pa-msg-in 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes pa-msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pa-msg--user {
  align-self: flex-end;
  padding: 11px 15px;
  border-radius: 18px 18px 6px 18px;
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.12) 0%, rgba(124, 58, 237, 0.08) 100%);
  border: 1px solid var(--pa-brand-line);
  color: #1e1b4b;
  box-shadow: 0 1px 2px rgba(124, 58, 237, 0.06);
}

.pa-msg--user .pa-msg__body,
.pa-msg--user .pa-msg__body p,
.pa-msg--user .pa-msg__body strong,
.pa-msg--user .pa-msg__body em {
  color: inherit;
}

.pa-msg--bot {
  align-self: flex-start;
  max-width: 96%;
  padding: 0;
  color: var(--pa-ink);
}

.pa-msg--bot .pa-msg__body {
  max-width: 100%;
  padding: 12px 14px;
  border-radius: 18px 18px 18px 6px;
  background: var(--pa-surface);
  border: 1px solid var(--pa-line);
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.05);
}

/* System notices (rate limit, connection) — متمایز از حباب پاسخ عادی */
.pa-msg--system {
  align-self: stretch;
  max-width: 100%;
  padding: 2px 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.pa-msg--system .pa-msg__body {
  padding: 0;
  border: none;
  box-shadow: none;
  background: transparent;
  border-radius: 0;
}

.pa-system-notice {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid var(--pa-system-limit-border);
  background: var(--pa-system-limit-bg);
  backdrop-filter: blur(6px);
}

.pa-system-notice--error {
  border-color: var(--pa-system-error-border);
  background: var(--pa-system-error-bg);
}

.pa-system-notice__mark {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  color: var(--pa-system-limit-ink);
  background: rgba(124, 58, 237, 0.1);
}

.pa-system-notice--error .pa-system-notice__mark {
  color: var(--pa-system-error-ink);
  background: rgba(244, 63, 94, 0.1);
}

.pa-system-notice__copy {
  flex: 1;
  min-width: 0;
  padding-top: 1px;
}

.pa-system-notice__title {
  display: block;
  font-size: 0.8rem;
  font-weight: 650;
  line-height: 1.45;
  color: var(--pa-system-limit-ink);
  letter-spacing: -0.01em;
}

.pa-system-notice--error .pa-system-notice__title {
  color: var(--pa-system-error-ink);
}

.pa-system-notice__desc {
  display: block;
  margin-top: 3px;
  font-size: 0.78rem;
  line-height: 1.7;
  color: var(--pa-system-limit-muted);
}

.pa-system-notice--error .pa-system-notice__desc {
  color: var(--pa-ink-muted);
}

.pa-system-notice__retry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  margin-inline-start: 45px;
  padding: 5px 13px;
  border-radius: 999px;
  border: 1px solid var(--pa-brand-line);
  background: rgba(255, 255, 255, 0.65);
  color: var(--pa-brand-hover);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background var(--pa-motion-fast),
    border-color var(--pa-motion-fast),
    color var(--pa-motion-fast),
    transform var(--pa-motion-fast);
}

.pa-system-notice__retry:hover {
  background: var(--pa-brand-soft);
  border-color: rgba(124, 58, 237, 0.28);
  color: var(--pa-brand);
}

.pa-system-notice__retry:active {
  transform: scale(0.98);
}

.pa-system-notice__retry:focus-visible {
  outline: 2px solid var(--pa-brand);
  outline-offset: 2px;
}

.pa-msg--notice .pa-msg__body {
  padding: 10px 12px;
  border-radius: 12px;
  background: #fffbeb;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.pa-msg__body h3,
.pa-msg__body .pa-md-h3 {
  margin: 0 0 8px;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--pa-ink);
}

.pa-msg__body p {
  margin: 0 0 10px;
  color: var(--pa-ink);
}

.pa-msg__body p:last-child {
  margin-bottom: 0;
}

.pa-msg__body ul,
.pa-msg__body ol {
  margin: 6px 0 10px;
  padding-inline-start: 1.2rem;
}

.pa-msg__body li {
  margin-bottom: 4px;
}

.pa-msg__body blockquote,
.pa-msg__body .pa-md-tip {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--pa-surface-2);
  border-inline-start: 2px solid var(--pa-brand);
  font-size: 0.82rem;
}

.pa-msg__body a {
  color: var(--pa-brand);
  font-weight: 500;
  text-decoration: none;
}

.pa-msg__body a:hover {
  text-decoration: underline;
}

.pa-md-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 0;
  border-radius: 4px;
  transition: color var(--pa-motion-fast), background var(--pa-motion-fast);
}

.pa-md-link svg {
  flex-shrink: 0;
  opacity: 0.75;
}

.pa-md-link:hover {
  text-decoration: none;
  background: var(--pa-brand-soft);
}

.pa-msg__retry {
  margin-top: 10px;
  border: none;
  background: var(--pa-brand);
  color: #fff;
  font: inherit;
  font-size: 0.78rem;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--pa-motion-fast);
}

.pa-msg__retry:hover {
  background: var(--pa-brand-hover);
}

.pa-msg__meta {
  margin-top: 8px;
  padding-top: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  animation: pa-meta-in 0.28s ease 0.08s both;
}

@keyframes pa-meta-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pa-msg__sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}

.pa-msg__sources-label {
  font-size: 0.68rem;
  color: var(--pa-ink-muted);
  margin: 0;
  flex-shrink: 0;
}

.pa-msg__source-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.pa-source-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  background: transparent;
  color: var(--pa-brand-hover);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 500;
  transition: background var(--pa-motion-fast), color var(--pa-motion-fast);
}

.pa-source-chip:hover {
  background: var(--pa-brand-soft);
  text-decoration: none;
}

.pa-source-chip svg {
  flex-shrink: 0;
  opacity: 0.65;
}

.pa-msg__actions {
  display: inline-flex;
  gap: 2px;
  margin-inline-start: auto;
}

.pa-msg__act {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--pa-ink-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--pa-motion-fast), color var(--pa-motion-fast);
}

.pa-msg__act:hover {
  background: var(--pa-surface-2);
  color: var(--pa-ink);
}

.pa-msg__act.is-selected {
  color: var(--pa-brand);
  background: var(--pa-brand-soft);
}

.pa-msg__act.is-copied {
  color: #059669;
}

.pa-msg__act:focus-visible {
  outline: 2px solid rgba(124, 58, 237, 0.35);
  outline-offset: 1px;
}

/* Loading */
.pa-msg.pa-msg--loading {
  align-self: flex-start;
  max-width: 96%;
  padding: 0;
  animation-name: none;
  animation-duration: 0s;
}

.pa-msg--loading.is-out {
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.pa-loading-bubble {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding: 14px 18px;
  border-radius: 18px 18px 18px 6px;
  background: var(--pa-surface);
  border: 1px solid var(--pa-line);
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.05);
}

.pa-loading__dots {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  min-height: 16px;
  padding-bottom: 1px;
}

.pa-loading__dots span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pa-brand);
  opacity: 0.35;
  transform: translate3d(0, 0, 0) scale(1);
  will-change: transform, opacity;
  animation-name: pa-dot-wave;
  animation-duration: 1.25s;
  animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1);
  animation-iteration-count: infinite;
}

.pa-loading__dots span:nth-child(1) {
  animation-delay: 0s;
}

.pa-loading__dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.pa-loading__dots span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes pa-dot-wave {
  0%,
  60%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: 0.35;
  }
  30% {
    transform: translate3d(0, -6px, 0) scale(1.12);
    opacity: 1;
  }
}

/* Footer */
.pa-footer {
  flex-shrink: 0;
  padding: 10px 12px 12px;
  background: var(--pa-surface);
  border-top: 1px solid var(--pa-line);
}

.pa-compose__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.pa-compose__shell {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 5px 5px 5px 8px;
  background: var(--pa-surface-2);
  border-radius: 14px;
  border: 1px solid transparent;
  transition: border-color var(--pa-motion-fast), box-shadow var(--pa-motion-fast), background var(--pa-motion-fast);
}

.pa-compose__shell:focus-within {
  border-color: rgba(124, 58, 237, 0.28);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.08);
  background: var(--pa-surface);
}

.pa-compose__input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  resize: none;
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.6;
  padding: 8px 4px;
  max-height: 120px;
  min-height: 38px;
  color: var(--pa-ink);
}

.pa-compose__input:focus {
  outline: none;
}

.pa-compose__input::placeholder {
  color: #9ca3af;
}

.pa-send {
  position: relative;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 11px;
  background: var(--pa-brand);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--pa-motion-fast), transform var(--pa-motion-fast), opacity var(--pa-motion-fast);
}

.pa-send:hover:not(:disabled) {
  background: var(--pa-brand-hover);
}

.pa-send:active:not(:disabled) {
  transform: scale(0.96);
}

.pa-send:disabled {
  opacity: 1;
  cursor: not-allowed;
  background: #d1d5db;
  color: #9ca3af;
}

.pa-send:disabled .pa-send__icon {
  opacity: 0.65;
}

.pa-root.is-sending .pa-send__icon {
  opacity: 0;
}

.pa-root.is-sending .pa-send__spinner {
  opacity: 1;
}

.pa-send__spinner {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  opacity: 0;
  animation: pa-spin 0.65s linear infinite;
}

@keyframes pa-spin {
  to {
    transform: rotate(360deg);
  }
}

.pa-send:focus-visible {
  outline: 2px solid rgba(124, 58, 237, 0.4);
  outline-offset: 2px;
}

.pa-send svg {
  transform: scaleX(-1);
}

/* Mobile sheet */
@media (max-width: 640px) {
  .pa-root {
    --pa-bottom: max(0px, env(safe-area-inset-bottom, 0px));
  }

  .pa-fab {
    --pa-fab-h: 48px;
    inset-block-end: max(14px, env(safe-area-inset-bottom, 14px));
    padding: 6px 10px 6px 8px;
    width: auto;
    min-width: 48px;
  }

  .pa-fab__subtitle {
    display: none;
  }

  .pa-fab__title {
    font-size: 0.72rem;
    max-width: 9.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .pa-fab__badge {
    display: none;
  }

  .pa-fab__content {
    gap: 8px;
  }

  .pa-fab__icon {
    width: 36px;
    height: 36px;
    border-radius: 11px;
  }


  .pa-panel {
    inset-inline: 0;
    inset-block-end: 0;
    width: 100%;
    height: min(92dvh, 720px);
    max-height: 92dvh;
    border-radius: var(--pa-radius-xl) var(--pa-radius-xl) 0 0;
    border-inline: none;
    border-bottom: none;
    transform: translateY(100%) scale(1);
  }

  .pa-root.is-open .pa-panel {
    transform: translateY(0) scale(1);
  }

  .pa-welcome__suggestions {
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pa-fab,
  .pa-fab__pulse,
  .pa-fab__badge-dot,
  .pa-welcome__wave,
  .pa-head__status-dot,
  .pa-panel,
  .pa-backdrop,
  .pa-msg:not(.pa-msg--loading),
  .pa-welcome,
  .pa-msg__meta,
  .pa-send__spinner {
    animation: none !important;
    transition: none !important;
  }

  .pa-loading__dots span {
    animation: none !important;
    opacity: 0.65;
    transform: none;
  }

  .pa-msg--loading.is-out {
    transition: none !important;
  }
}

html[data-theme='dark'] .pa-root {
  --pa-surface: #18181f;
  --pa-surface-2: #1f1f28;
  --pa-ink: #f3f4f6;
  --pa-ink-muted: #9ca3af;
  --pa-line: rgba(255, 255, 255, 0.08);
  --pa-brand-soft: rgba(167, 139, 250, 0.14);
  --pa-brand-line: rgba(167, 139, 250, 0.22);
  --pa-system-limit-bg: linear-gradient(
    145deg,
    rgba(167, 139, 250, 0.12) 0%,
    rgba(129, 140, 248, 0.06) 50%,
    rgba(24, 24, 31, 0.92) 100%
  );
  --pa-system-limit-border: rgba(167, 139, 250, 0.22);
  --pa-system-limit-ink: #ddd6fe;
  --pa-system-limit-muted: #a8a3b8;
  --pa-system-error-bg: linear-gradient(
    145deg,
    rgba(251, 113, 133, 0.1) 0%,
    rgba(244, 63, 94, 0.05) 55%,
    rgba(24, 24, 31, 0.95) 100%
  );
  --pa-system-error-border: rgba(251, 113, 133, 0.22);
  --pa-system-error-ink: #fecdd3;
}

html[data-theme='dark'] .pa-msg--user {
  color: #ede9fe;
}

html[data-theme='dark'] .pa-chip {
  background: #1f1f28;
}

html[data-theme='dark'] .pa-send:disabled {
  background: #2d2d38;
  color: #6b7280;
}

html[data-theme='dark'] .pa-system-notice__retry {
  background: rgba(24, 24, 31, 0.55);
}

html[data-theme='dark'] .pa-msg--bot .pa-msg__body {
  background: #1f1f28;
}
