/* Theme-aware, compact PET page guide and Ask MyDasma AI composer. */
.bims-pet-stage {
  --bims-pet-brand: var(--bims-primary, #6d28d9);
  --bims-pet-brand-strong: var(--bims-primary-strong, #4c1d95);
  --bims-pet-brand-soft: var(--bims-primary-soft, #f3e8ff);
  --bims-pet-accent: var(--bims-accent, #a16207);
  --bims-pet-surface: var(--bims-surface, #ffffff);
  --bims-pet-surface-soft: var(--bims-surface-soft, #faf5ff);
  --bims-pet-inset: var(--bims-surface-inset, #f5eeff);
  --bims-pet-text: var(--bims-text, #2a1740);
  --bims-pet-text-strong: var(--bims-text-strong, #1e1033);
  --bims-pet-muted: var(--bims-muted, #705f7f);
  --bims-pet-border: var(--bims-border-strong, #cfb8e5);
  width: min(316px, calc(100vw - 24px));
  filter: drop-shadow(0 12px 24px var(--bims-shadow, rgba(76, 29, 149, .16))) !important;
}

.bims-pet-stage.is-dragging {
  filter: drop-shadow(0 18px 28px var(--bims-shadow, rgba(76, 29, 149, .24))) !important;
}

.bims-pet-character::before {
  background: radial-gradient(ellipse at 50% 70%, var(--bims-pet-brand-soft), transparent 68%) !important;
}

.bims-pet-character::after {
  border-color: var(--bims-pet-surface) !important;
  background: var(--bims-pet-brand) !important;
  box-shadow: 0 0 0 0 var(--bims-focus, rgba(109, 40, 217, .28)) !important;
}

/* The same pose illustrations are retained for consistency, while their hue
   follows all five approved organization presets. These selectors are also a
   release contract: PET cannot silently fall back to the old purple artwork. */
html[data-bims-theme="violet"] .bims-pet-character img {
  filter: hue-rotate(34deg) saturate(1.18) contrast(1.05) !important;
}

html[data-bims-theme="emerald"] .bims-pet-character img {
  filter: hue-rotate(-78deg) saturate(1.08) contrast(1.04) !important;
}

html[data-bims-theme="crimson"] .bims-pet-character img {
  filter: hue-rotate(137deg) saturate(1.16) contrast(1.05) !important;
}

html[data-bims-theme="ocean"] .bims-pet-character img {
  filter: hue-rotate(-16deg) saturate(1.08) contrast(1.04) !important;
}

html[data-bims-theme="midnight"] .bims-pet-character img {
  filter: hue-rotate(6deg) saturate(.98) brightness(.9) contrast(1.13) !important;
}

html[data-citizen-theme="dark"][data-bims-theme] .bims-pet-character img {
  brightness: .94;
}

.bims-pet-context-menu,
.bims-pet-greeting,
.bims-pet-stage .bims-toast {
  border-color: var(--bims-pet-border) !important;
  background: var(--bims-pet-surface) !important;
  color: var(--bims-pet-text) !important;
  box-shadow: 0 10px 24px var(--bims-shadow, rgba(76, 29, 149, .16)) !important;
}

.bims-pet-greeting strong,
.bims-pet-stage .bims-pet-alert-title {
  color: var(--bims-pet-brand-strong) !important;
}

.bims-pet-greeting span,
.bims-pet-stage .bims-toast-content {
  color: var(--bims-pet-muted) !important;
}

.bims-pet-stage .bims-toast-info {
  --bims-pet-alert-accent: var(--bims-pet-brand);
  --bims-pet-alert-mark-bg: var(--bims-pet-brand-soft);
}

.bims-pet-stage .bims-toast-content a,
.bims-pet-typewriter-text::after {
  color: var(--bims-pet-brand-strong) !important;
}

.bims-pet-greeting.bims-pet-assistant {
  width: min(296px, 100%);
  max-height: min(316px, calc(100vh - 132px));
  padding: 0;
  overflow: hidden;
  border-width: 1px;
  border-left: 4px solid var(--bims-pet-brand) !important;
  border-radius: 15px 15px 4px 15px;
  background:
    linear-gradient(145deg, var(--bims-pet-surface), var(--bims-pet-surface-soft)) !important;
}

.bims-pet-assistant-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 7px 8px 6px 10px;
  border-bottom: 1px solid var(--bims-pet-border);
  background: linear-gradient(135deg, var(--bims-pet-brand-soft), var(--bims-pet-surface));
}

.bims-pet-assistant-head > div {
  flex: 1 1 auto;
  min-width: 0;
}

.bims-pet-assistant-eyebrow {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bims-pet-assistant-eyebrow {
  color: var(--bims-pet-accent);
  font-size: .638rem;
  font-weight: 900;
  letter-spacing: .07em;
}

.bims-pet-assistant-title {
  display: block;
  margin-top: 1px;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  color: var(--bims-pet-text-strong) !important;
  font-size: .924rem !important;
  line-height: 1.25 !important;
}

body.bims-admin-shell .bims-pet-assistant-minimize {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border: 1px solid var(--bims-pet-border);
  border-radius: 50%;
  background: var(--bims-pet-surface);
  color: var(--bims-pet-brand-strong);
  font: inherit;
  font-size: 1rem;
  font-weight: 850;
  cursor: pointer;
  margin-top: 1px;
}

.bims-pet-assistant-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 4px;
  padding: 4px;
  border-bottom: 1px solid var(--bims-pet-border);
  background: var(--bims-pet-inset);
}

body.bims-admin-shell .bims-pet-assistant-tabs button {
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  min-height: 36px;
  height: auto;
  padding: 5px 6px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--bims-pet-muted);
  font: inherit;
  font-size: .704rem;
  font-weight: 850;
  line-height: 1.2;
  text-align: center;
  white-space: normal !important;
  overflow-wrap: anywhere;
  word-break: normal;
  text-wrap: balance;
  cursor: pointer;
}

body.bims-admin-shell .bims-pet-assistant-tabs button[aria-selected="true"] {
  border-color: var(--bims-pet-brand);
  background: var(--bims-pet-surface);
  color: var(--bims-pet-brand-strong);
  box-shadow: inset 0 -2px 0 var(--bims-pet-brand);
}

.bims-pet-assistant-panels {
  min-height: 0;
}

.bims-pet-assistant-panel {
  max-height: 209px;
  padding: 8px 9px 9px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--bims-pet-border) transparent;
}

.bims-pet-assistant-panel[hidden] {
  display: none !important;
}

.bims-pet-assistant-intro,
.bims-pet-ask-response p {
  margin: 0;
  color: var(--bims-pet-muted);
  font-size: .748rem;
  font-weight: 700;
  line-height: 1.42;
}

.bims-pet-guide-list,
.bims-pet-guide-more-list {
  display: grid;
  gap: 6px;
  margin: 8px 0;
  padding-left: 18px;
  color: var(--bims-pet-text);
  font-size: .759rem;
  font-weight: 740;
  line-height: 1.4;
}

.bims-pet-guide-list li::marker {
  color: var(--bims-pet-brand) !important;
  font-weight: 900;
}

.bims-pet-guide-more,
.bims-pet-chat-answer {
  border: 1px solid var(--bims-pet-border);
  border-radius: 10px;
  background: var(--bims-pet-surface);
}

.bims-pet-guide-more > summary {
  padding: 7px 9px;
  color: var(--bims-pet-brand-strong);
  font-size: .737rem;
  font-weight: 850;
  line-height: 1.3;
  cursor: pointer;
}

.bims-pet-guide-more-list {
  margin: 0;
  padding: 0 11px 10px 25px;
}

.bims-pet-ask-form {
  display: grid;
  gap: 4px;
  margin-top: 7px;
}

.bims-pet-ask-composer {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: 40px;
  padding: 4px 47px 4px 8px;
  border: 1px solid var(--bims-pet-border);
  border-radius: 14px;
  background: var(--bims-pet-surface);
  box-shadow: inset 0 1px 2px var(--bims-shadow, rgba(76, 29, 149, .08));
}

.bims-pet-ask-composer textarea {
  width: 100%;
  min-height: 30px;
  max-height: 68px;
  padding: 6px 0;
  overflow-y: auto;
  border: 0 !important;
  outline: 0 !important;
  background: transparent !important;
  color: var(--bims-pet-text) !important;
  font: inherit;
  font-size: .759rem;
  line-height: 1.35;
  resize: none;
}

body.bims-admin-shell .bims-pet-ask-submit {
  position: absolute;
  top: 50%;
  right: 5px;
  bottom: auto;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 0 !important;
  border-radius: 50%;
  background: transparent !important;
  box-shadow: none;
  color: var(--bims-pet-brand);
  font: inherit;
  cursor: pointer;
}

body.bims-admin-shell .bims-pet-ask-submit:hover:not(:disabled) {
  transform: translateY(-50%) !important;
  background: var(--bims-primary-soft, rgba(109, 40, 217, .1)) !important;
}

body.bims-admin-shell .bims-pet-ask-submit:focus-visible {
  transform: translateY(-50%) !important;
  outline: 2px solid var(--bims-pet-brand) !important;
  outline-offset: 1px;
  background: var(--bims-primary-soft, rgba(109, 40, 217, .1)) !important;
}

body.bims-admin-shell .bims-pet-ask-submit:disabled {
  cursor: default;
  color: var(--bims-pet-muted) !important;
  opacity: .55;
}

.bims-pet-send-icon {
  display: block;
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.bims-pet-composer-help {
  margin: 0 3px;
  color: var(--bims-pet-muted);
  font-size: .616rem;
  line-height: 1.2;
}

.bims-pet-ask-response {
  display: grid;
  gap: 6px;
  max-height: 114px;
  margin-top: 7px;
  overflow-y: auto;
  color: var(--bims-pet-text);
  font-size: .748rem;
  font-weight: 740;
  line-height: 1.42;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bims-pet-ask-response:empty {
  display: none;
}

.bims-pet-chat-question {
  justify-self: end;
  max-width: 86%;
  padding: 6px 8px;
  border-radius: 11px 11px 3px 11px;
  background: var(--bims-pet-brand);
  color: var(--bims-on-primary, #fff) !important;
}

.bims-pet-chat-answer {
  justify-self: start;
  max-width: 94%;
  padding: 7px 8px;
  border-radius: 3px 11px 11px 11px;
  color: var(--bims-pet-text);
}

.bims-pet-chat-answer p {
  color: var(--bims-pet-text);
}

.bims-pet-ask-response small {
  display: block;
  margin-bottom: 3px;
  color: var(--bims-pet-brand-strong);
  font-size: .638rem;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.bims-pet-ask-response[data-state="error"] .bims-pet-chat-answer {
  border-color: #c7464b;
  background: #fff0f0;
  color: #8f252b;
}

.bims-pet-ask-response[data-state="fallback"] .bims-pet-chat-answer {
  border-color: var(--bims-pet-accent);
  background: var(--bims-accent-soft, #fef3c7);
}

.bims-pet-typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  height: 16px;
}

.bims-pet-typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--bims-pet-brand);
  animation: bims-pet-dot 1s ease-in-out infinite;
}

.bims-pet-typing-dots i:nth-child(2) { animation-delay: .14s; }
.bims-pet-typing-dots i:nth-child(3) { animation-delay: .28s; }

@keyframes bims-pet-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: .48; }
  30% { transform: translateY(-3px); opacity: 1; }
}

.bims-pet-ask-response[data-typing="true"] .bims-pet-typewriter-text::after {
  content: '\258d';
  color: var(--bims-pet-brand);
  animation: bims-pet-caret .7s steps(1) infinite;
}

.bims-pet-assistant-panel[data-guide-typing="true"] [data-bims-pet-guide-current]::after {
  content: '\258d';
  color: var(--bims-pet-brand);
  animation: bims-pet-caret .7s steps(1) infinite;
}

@keyframes bims-pet-caret {
  50% { opacity: 0; }
}

.bims-pet-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.bims-pet-assistant :is(button, input, summary):focus-visible {
  outline: 3px solid var(--bims-focus, rgba(109, 40, 217, .28)) !important;
  outline-offset: 1px;
}

html[data-bims-theme] body.bims-admin-shell .bims-pet-assistant .bims-pet-ask-composer textarea:focus,
html[data-bims-theme] body.bims-admin-shell .bims-pet-assistant .bims-pet-ask-composer textarea:focus-visible {
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
}

html[data-bims-theme] body.bims-admin-shell .bims-pet-character:focus,
html[data-bims-theme] body.bims-admin-shell .bims-pet-character:focus-visible {
  outline: 0 !important;
  outline-offset: 0 !important;
  box-shadow: none !important;
}

html[data-bims-theme] body.bims-admin-shell .bims-pet-character:focus-visible::before {
  box-shadow: 0 0 0 3px var(--bims-focus, color-mix(in srgb, var(--bims-pet-brand) 30%, transparent)) !important;
}

@media (max-width: 1180px) and (min-width: 1025px) {
  .bims-pet-stage {
    width: min(296px, calc(100vw - 20px));
  }

  .bims-pet-greeting.bims-pet-assistant {
    width: min(278px, 100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bims-pet-assistant,
  .bims-pet-assistant * {
    scroll-behavior: auto !important;
  }

  .bims-pet-typing-dots i,
  .bims-pet-ask-response[data-typing="true"] .bims-pet-typewriter-text::after,
  .bims-pet-assistant-panel[data-guide-typing="true"] [data-bims-pet-guide-current]::after {
    animation: none !important;
  }
}
