/* Cloud + attentive AI presence. Based on bloub (MIT); see bloub.LICENSE.txt. */
.ai-bloub {
  --ai-bloub-size: 48px;
  --ai-bloub-hi: color-mix(in srgb, var(--gold, #d7ad68) 72%, #fff 28%);
  --ai-bloub-mid: color-mix(in srgb, var(--accent, #a72d27) 48%, var(--gold, #d7ad68) 52%);
  --ai-bloub-low: color-mix(in srgb, var(--accent, #a72d27) 88%, #210b0a 12%);
  display: inline-grid;
  place-items: center;
  width: var(--ai-bloub-size);
  height: var(--ai-bloub-size);
  min-width: var(--ai-bloub-size);
  flex: 0 0 var(--ai-bloub-size);
  vertical-align: middle;
  contain: layout paint;
  filter: drop-shadow(0 8px 14px color-mix(in srgb, var(--accent, #a72d27) 28%, transparent));
}
.ai-bloub svg { display: block; width: 100%; height: 100%; overflow: visible; }
.ai-bloub-stop-hi { stop-color: var(--ai-bloub-hi); }
.ai-bloub-stop-mid { stop-color: var(--ai-bloub-mid); }
.ai-bloub-stop-low { stop-color: var(--ai-bloub-low); }
.ai-bloub-body {
  transform-box: view-box;
  transform-origin: 110px 108px;
  animation: aiBloubBreathe 5.4s cubic-bezier(.37, 0, .25, 1) infinite;
}
.ai-bloub-gaze {
  transform-box: view-box;
  transform-origin: 110px 100px;
  animation: aiBloubGaze 7.2s cubic-bezier(.22, 1, .36, 1) infinite;
}
.ai-bloub-eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: aiBloubBlink 6.1s linear infinite;
}
.ai-bloub-eye--right { animation-delay: .045s; }
.ai-bloub--thinking .ai-bloub-body { animation-duration: 1.55s; }
.ai-bloub--thinking .ai-bloub-gaze { animation-name: aiBloubThink; animation-duration: 2.05s; }
.ai-bloub--thinking { filter: drop-shadow(0 8px 18px color-mix(in srgb, var(--gold, #d7ad68) 42%, transparent)); }
.ai-bloub--speaking .ai-bloub-body { animation-name: aiBloubSpeak; animation-duration: .92s; }
.ai-bloub--speaking .ai-bloub-gaze { animation-duration: 3.6s; }
.ai-bloub--ready .ai-bloub-body { animation-name: aiBloubReady; animation-duration: 1.8s; animation-iteration-count: 1; }

.ai-bloub-message {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: min(100%, 360px);
  min-width: 0;
  margin: 0 auto;
  color: var(--text);
  text-align: left;
}
.ai-bloub-message.is-compact { gap: 9px; }
.ai-bloub-message-copy { min-width: 0; }
.ai-bloub-message-copy b { display: block; font-size: .72rem; line-height: 1.35; }
.ai-bloub-message-copy small { display: block; margin-top: 3px; color: var(--hint); font-size: .58rem; line-height: 1.35; }
.ai-bloub-feature-head,
.ph-ai-presence {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.ai-bloub-feature-head > div,
.ph-ai-presence > div { min-width: 0; }
.ai-bloub-feature-head .form-label { margin: 0 0 3px !important; }
.ph-ai-presence {
  padding: 12px 13px;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 16%, var(--border));
  background: color-mix(in srgb, var(--accent) 5%, var(--card));
}
.ph-ai-presence b { display: block; font-size: .78rem; }
.ph-ai-presence small { display: block; margin-top: 2px; color: var(--hint); font-size: .61rem; line-height: 1.35; }
.ph-ai-toggle-inner { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.apoc-action-status > .ai-bloub { margin: -5px 0; }
.apoc-bunker-visual-pending .ai-bloub-message { padding: 2px 0; }

.ai-bloub-speech {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  padding: 12px 13px;
  border: 1px solid color-mix(in srgb, var(--accent, #a72d27) 20%, var(--border));
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent, #a72d27) 6%, var(--card));
  color: var(--text);
}
.ai-bloub-speech.is-compact { gap: 9px; padding: 9px 10px; border-radius: 11px; }
.ai-bloub-speech-copy { min-width: 0; flex: 1; }
.ai-bloub-speech-copy small {
  display: block;
  margin-bottom: 4px;
  color: color-mix(in srgb, var(--gold, #d7ad68) 82%, var(--text));
  font-size: .56rem;
  font-weight: 900;
  text-transform: uppercase;
}
.ai-bloub-speech-copy > div { font-size: .76rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-bloub-question-btn { display: flex !important; align-items: center; justify-content: center; gap: 9px; }
.ai-bloub-question-btn .ai-bloub { margin: -8px 0; }
.ai-bloub-question-state { margin-top: 9px; }
.ai-bloub-role-voice { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.ai-bloub-role-voice .btn { flex: 1; margin: 0 !important; }
.ai-bloub-role-voice[aria-busy="true"] .btn { opacity: .72; }
.ai-bloub-question-card { padding: 12px; border-bottom: 1px solid var(--border); }
.ai-bloub-question-card:last-child { border-bottom: 0; }
.ai-bloub-question-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ai-bloub-question-head > div { min-width: 0; flex: 1; }
.ai-bloub-question-head strong { display: block; font-size: .78rem; }
.ai-bloub-question-head span { display: block; margin-top: 2px; color: var(--hint); font-size: .6rem; }
.ai-bloub-question-text { margin: 0 0 8px; font-size: .75rem; line-height: 1.45; color: var(--text); }
.ai-bloub-host-inbox { margin: 0 0 10px; overflow: hidden; border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border)); border-radius: 14px; background: var(--card); }
.ai-bloub-host-inbox > header { display: flex; align-items: center; gap: 10px; padding: 11px 12px; background: color-mix(in srgb, var(--accent) 6%, var(--card)); }
.ai-bloub-host-inbox > header > div { min-width: 0; flex: 1; }
.ai-bloub-host-inbox > header strong { display: block; font-size: .82rem; }
.ai-bloub-host-inbox > header small { display: block; margin-top: 2px; color: var(--hint); font-size: .6rem; }
.ai-bloub-host-inbox > header > b { min-width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-size: .7rem; }
.ai-bloub-answer-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ai-bloub-answer-actions .btn { flex: 1 1 120px; }
.squiri-pool-dock {
  position: fixed;
  top: clamp(260px, 67dvh, calc(100dvh - 165px));
  right: max(0px, env(safe-area-inset-right));
  z-index: 190;
  width: 46px;
  height: 66px;
  transform: translateY(-50%);
  animation: squiriDockIn .52s cubic-bezier(.22, 1, .36, 1) both;
}
.squiri-pool-call {
  position: absolute;
  top: 0;
  right: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(194px, calc(100vw - 58px));
  height: 66px;
  padding: 7px 12px 7px 8px;
  border: 1px solid color-mix(in srgb, var(--gold, #d7ad68) 38%, var(--border));
  border-radius: 18px 0 0 18px;
  background: color-mix(in srgb, var(--card, #18191d) 93%, var(--accent, #a72d27) 7%);
  color: var(--text);
  box-shadow: 0 15px 38px rgba(0, 0, 0, .34), inset 0 1px 0 rgba(255, 255, 255, .06);
  -webkit-backdrop-filter: blur(16px) saturate(1.08);
  backdrop-filter: blur(16px) saturate(1.08);
  text-align: left;
  cursor: pointer;
  appearance: none;
  opacity: 0;
  pointer-events: none;
  transform: translateX(20px) scale(.97);
  transform-origin: 100% 50%;
  transition: opacity .25s ease, transform .38s cubic-bezier(.22, 1, .36, 1), border-color .28s ease, box-shadow .28s ease;
}
.squiri-pool-dock.is-open .squiri-pool-call { opacity: 1; pointer-events: auto; transform: translateX(0) scale(1); }
.squiri-pool-call:active { transform: scale(.97) !important; }
.squiri-pool-call:focus-visible,
.squiri-pool-toggle:focus-visible { outline: 2px solid var(--gold, #d7ad68); outline-offset: 2px; }
.squiri-pool-toggle {
  position: absolute;
  top: 5px;
  right: 0;
  display: grid;
  place-items: center;
  width: 44px;
  height: 56px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--gold, #d7ad68) 42%, var(--border));
  border-right: 0;
  border-radius: 17px 0 0 17px;
  background: color-mix(in srgb, var(--card, #18191d) 91%, var(--accent, #a72d27) 9%);
  color: color-mix(in srgb, var(--gold, #d7ad68) 82%, var(--text));
  box-shadow: -8px 10px 28px rgba(0, 0, 0, .32), inset 0 1px 0 rgba(255, 255, 255, .06);
  cursor: pointer;
  appearance: none;
  transition: background .25s ease, border-color .25s ease, transform .22s ease;
}
.squiri-pool-toggle span { display: block; font-family: Georgia, serif; font-size: 2rem; line-height: 1; transform: translateY(-1px); }
.squiri-pool-toggle:active { transform: scale(.94); }
.squiri-pool-fab-bloub { display: grid; place-items: center; width: 46px; height: 46px; flex: 0 0 46px; }
.squiri-pool-fab-copy { min-width: 0; flex: 1; }
.squiri-pool-fab-copy b { display: block; font-size: .78rem; line-height: 1.2; }
.squiri-pool-fab-copy small { display: block; margin-top: 4px; color: var(--hint); font-size: .59rem; line-height: 1.25; overflow-wrap: anywhere; }
.squiri-help-dialog { display: grid; gap: 12px; }
.squiri-help-prompts { display: flex; flex-wrap: wrap; gap: 7px; }
.squiri-help-prompts button {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid color-mix(in srgb, var(--gold, #d7ad68) 28%, var(--border));
  border-radius: 11px;
  background: color-mix(in srgb, var(--gold, #d7ad68) 7%, var(--card));
  color: var(--text);
  font: inherit;
  font-size: .64rem;
  font-weight: 750;
  cursor: pointer;
  transition: transform .2s ease, background .2s ease, border-color .2s ease;
}
.squiri-help-prompts button:active { transform: scale(.97); }
.squiri-help-input { min-height: 112px; resize: vertical; }
.squiri-help-note { margin-top: -5px; color: var(--hint); font-size: .61rem; line-height: 1.4; }
.squiri-help-dialog .ai-bloub-question-state { margin-top: 0; }
.squiri-help-dialog [aria-busy="true"] { opacity: .72; pointer-events: none; }
.squiri-feature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}
.squiri-feature-grid button { min-width: 0; text-align: center; }
.squiri-local-context {
  display: grid;
  gap: 7px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.squiri-context-line { display: grid; grid-template-columns: minmax(92px, .42fr) 1fr; gap: 8px 12px; align-items: start; }
.squiri-context-line b { color: color-mix(in srgb, var(--gold, #d7ad68) 80%, var(--text)); font-size: .66rem; line-height: 1.4; }
.squiri-context-line span { color: var(--hint); font-size: .64rem; line-height: 1.45; overflow-wrap: anywhere; }
.squiri-context-line button {
  grid-column: 2;
  width: max-content;
  padding: 5px 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 7%, var(--card));
  color: var(--text);
  font: inherit;
  font-size: .6rem;
  font-weight: 750;
}
.squiri-context-line.is-error b { color: #ef7770; }
.squiri-watchlist { display: grid; gap: 2px; padding: 3px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.squiri-watchlist header { display: flex; align-items: center; gap: 8px; padding: 7px 2px 5px; }
.squiri-watchlist header b { flex: 1; font-size: .68rem; }
.squiri-watchlist header span { min-width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: color-mix(in srgb, var(--gold) 14%, var(--card)); color: var(--gold); font-size: .6rem; font-weight: 800; }
.squiri-watchlist > button {
  display: grid;
  grid-template-columns: 8px 1fr;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 8px 2px;
  border: 0;
  border-top: 1px solid color-mix(in srgb, var(--border) 64%, transparent);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: .64rem;
  line-height: 1.4;
  text-align: left;
}
.squiri-watchlist i { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px color-mix(in srgb, var(--gold) 46%, transparent); }
.squiri-watchlist i.is-warning { background: #e79048; }
.squiri-watchlist i.is-success { background: #55b889; }
#squiriHostAnswer:empty { display: none; }
#squiriHostAnswer:not(:empty) { margin-top: 2px; }
.apoc-ai-action-head { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.apoc-ai-action-head > div { min-width: 0; }
.apoc-ai-action-head b { display: block; font-size: .8rem; }
.apoc-ai-action-head small { display: block; margin-top: 2px; color: var(--hint); font-size: .58rem; }
#playerAckTitle.is-ai-bloub { margin-bottom: 12px !important; }

body[data-app-theme="light"] .ai-bloub,
body[data-pad-core-theme="light"] .ai-bloub {
  --ai-bloub-hi: color-mix(in srgb, var(--gold, #b48843) 70%, #fff 30%);
  --ai-bloub-mid: color-mix(in srgb, var(--accent, #8f2924) 62%, var(--gold, #b48843) 38%);
  --ai-bloub-low: color-mix(in srgb, var(--accent, #8f2924) 84%, #3a1210 16%);
  filter: drop-shadow(0 7px 12px color-mix(in srgb, var(--accent, #8f2924) 18%, transparent));
}

@keyframes aiBloubBreathe {
  0%, 100% { transform: scale(1); }
  48% { transform: scale(1.018, .985); }
  72% { transform: scale(.992, 1.012); }
}
@keyframes aiBloubGaze {
  0%, 14%, 100% { transform: translate(0, 0) rotate(-2deg); }
  24%, 38% { transform: translate(7px, -2px) rotate(1deg); }
  52%, 66% { transform: translate(-6px, 3px) rotate(-4deg); }
  78%, 90% { transform: translate(2px, -4px) rotate(-1deg); }
}
@keyframes aiBloubThink {
  0%, 100% { transform: translate(-5px, 1px) rotate(-4deg); }
  35% { transform: translate(7px, -4px) rotate(1deg); }
  68% { transform: translate(1px, 4px) rotate(-2deg); }
}
@keyframes aiBloubBlink {
  0%, 42%, 45%, 78%, 81%, 100% { scale: 1 1; }
  43.5%, 79.5% { scale: 1 .08; }
}
@keyframes aiBloubSpeak {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.035, .975); }
}
@keyframes aiBloubReady {
  0% { transform: scale(.92); opacity: .4; }
  48% { transform: scale(1.045); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes squiriDockIn {
  from { opacity: 0; transform: translate3d(18px, -50%, 0) scale(.94); }
  to { opacity: 1; transform: translate3d(0, -50%, 0) scale(1); }
}

@media (hover: hover) and (pointer: fine) {
  .squiri-pool-call:hover {
    border-color: color-mix(in srgb, var(--gold, #d7ad68) 58%, var(--border));
    box-shadow: 0 19px 46px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .08);
  }
  .squiri-pool-toggle:hover { background: color-mix(in srgb, var(--card) 82%, var(--gold, #d7ad68) 18%); }
  .squiri-help-prompts button:hover {
    background: color-mix(in srgb, var(--gold, #d7ad68) 13%, var(--card));
    border-color: color-mix(in srgb, var(--gold, #d7ad68) 48%, var(--border));
  }
}

@media (max-width: 360px) {
  .squiri-feature-grid { grid-template-columns: 1fr; }
  .squiri-context-line { grid-template-columns: 1fr; }
  .squiri-context-line button { grid-column: 1; }
}

body[data-app-theme="light"] .squiri-pool-call,
body[data-app-theme="light"] .squiri-pool-toggle,
body[data-pad-core-theme="light"] .squiri-pool-call,
body[data-pad-core-theme="light"] .squiri-pool-toggle {
  box-shadow: 0 14px 32px rgba(78, 48, 25, .18), inset 0 1px 0 rgba(255, 255, 255, .78);
}

@media (prefers-reduced-motion: reduce) {
  .ai-bloub-body,
  .ai-bloub-gaze,
  .ai-bloub-eye,
  .squiri-pool-dock,
  .squiri-pool-call,
  .squiri-pool-toggle { animation: none !important; transition: none !important; }
}
html[data-a11y-motion="reduce"] .ai-bloub-body,
html[data-a11y-motion="reduce"] .ai-bloub-gaze,
html[data-a11y-motion="reduce"] .ai-bloub-eye,
html[data-a11y-motion="reduce"] .squiri-pool-dock,
html[data-a11y-motion="reduce"] .squiri-pool-call,
html[data-a11y-motion="reduce"] .squiri-pool-toggle { animation: none !important; transition: none !important; }
