/* ═══ Global AI Insight Popup (portaled to document.body) ═══ */
#aioAiInsightPortal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  pointer-events: none;
}

#aioAiInsightPortal #aiInsightPop {
  pointer-events: auto;
}

#aiInsightPop.aio-ai-pop-open {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

#aiInsightPop {
  position: fixed;
  z-index: 100000;
  top: 80px;
  right: 24px;
  width: 450px;
  max-width: calc(100vw - 48px);
  height: 550px;
  max-height: calc(100vh - 120px);
  min-width: 300px;
  min-height: 250px;
  background: var(--surface-panel-modal, #0d0d1e);
  border: 1px solid var(--border-glow, rgba(124, 58, 237, .35));
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .45), 0 0 0 1px var(--border-glow, rgba(124, 58, 237, .15));
  display: none;
  flex-direction: column;
  overflow: visible;
  animation: aioAiPopIn .18s cubic-bezier(.34, 1.56, .64, 1);
  color: var(--text-primary);
}

.embed-mode #aiInsightPop {
  top: 10px;
  right: 10px;
  width: min(420px, calc(100vw - 20px));
  max-width: calc(100vw - 20px);
  height: min(520px, calc(100vh - 20px));
  max-height: calc(100vh - 20px);
}

@keyframes aioAiPopIn {
  from {
    opacity: 0;
    transform: scale(.95) translateY(-8px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.ai-size-btn {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text3);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.ai-size-btn:hover {
  background: var(--purple-dim);
  color: var(--text-primary);
  border-color: var(--border-glow);
}

.ai-size-btn.active {
  background: var(--purple);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 8px rgba(124, 58, 237, 0.35);
}

.ai-pop-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  background: linear-gradient(90deg, rgba(124, 58, 237, .12) 0%, rgba(6, 182, 212, .06) 100%);
  border-bottom: 1px solid var(--border);
  border-top-left-radius: 15px;
  border-top-right-radius: 15px;
}

.ai-pop-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(124, 58, 237, .4);
}

.ai-pop-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}

.ai-pop-close,
.ai-pop-min {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
  border-radius: 4px;
  transition: all .15s;
  line-height: 1;
}

.ai-pop-close:hover,
.ai-pop-min:hover {
  color: var(--text-primary);
  background: var(--surface-hover-strong);
}

#aiInsightPop.ai-minimized {
  height: 52px !important;
  min-height: 52px !important;
}

#aiInsightPop.ai-minimized .ai-pop-body,
#aiInsightPop.ai-minimized .ai-pop-input-wrap,
#aiInsightPop.ai-minimized .ai-pop-footer,
#aiInsightPop.ai-minimized .ai-pop-ribbons,
#aiInsightPop.ai-minimized .ai-pop-minichart {
  display: none !important;
}

#aiInsightPop.has-minichart .ai-pop-ribbons {
  right: calc(100% + 390px);
}

.ai-pop-ribbons {
  position: absolute;
  top: 64px;
  right: 100%;
  margin-right: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  z-index: 100010;
  pointer-events: auto;
}

.ai-ribbon-tag {
  background: var(--surface-panel-strong);
  border: 1px solid var(--border-glow);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(8px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  white-space: nowrap;
  width: fit-content;
  transform-origin: right center;
}

.ai-ribbon-tag:hover {
  transform: scale(1.05) translateX(-2px);
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.18);
  color: var(--text-primary);
}

.ai-ribbon-tag.buy {
  border-left: 3px solid #10b981;
}

.ai-ribbon-tag.support {
  border-left: 3px solid #3b82f6;
}

.ai-ribbon-tag.resistance {
  border-left: 3px solid #f59e0b;
}

.ai-ribbon-tag.stoploss {
  border-left: 3px solid #ef4444;
}

.ai-pop-body,
#aiPopBody {
  flex: 1;
  padding: 20px 16px;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--text-primary);
  overflow-y: auto;
  max-height: none !important;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface-panel-modal);
}

.ai-pop-bubble {
  padding: 12px 14px;
  border-radius: 12px;
  line-height: 1.6;
  font-size: 0.85rem;
  word-wrap: break-word;
  animation: aioAiBubbleIn 0.2s ease-out;
  box-sizing: border-box;
  width: 100%;
}

@keyframes aioAiBubbleIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-pop-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  width: 100%;
  align-items: flex-start;
  animation: aioAiBubbleIn 0.25s ease-out;
}

.ai-suggestion-btn {
  background: var(--purple-dim);
  border: 1px solid var(--border-glow);
  border-radius: 8px;
  color: var(--purple-light);
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all 0.15s;
}

.ai-suggestion-btn:hover {
  background: rgba(124, 58, 237, 0.14);
  color: var(--text-primary);
  border-color: rgba(124, 58, 237, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.12);
}

.ai-pop-bubble.user {
  background: #7c3aed;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
  max-width: 85%;
  width: auto;
}

.ai-pop-bubble.ai {
  background: var(--surface-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 2px;
  max-width: 100%;
  width: 100%;
}

.ai-pop-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 0.9rem;
}

.ai-pop-meta {
  font-size: 0.72rem;
  color: var(--text3);
  margin: 2px 8px 10px;
  display: block;
}

.ai-pop-meta.user {
  text-align: right;
}

.ai-pop-meta.ai {
  text-align: left;
}

.ai-pop-bubble th,
.ai-pop-bubble td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
}

.ai-pop-bubble th {
  background: var(--purple-dim);
  font-weight: 600;
  color: var(--text-primary);
}

.ai-pop-bubble p {
  margin: 0 0 10px 0;
}

.ai-pop-bubble p:last-child {
  margin-bottom: 0;
}

.ai-pop-bubble strong {
  color: var(--text-primary);
  font-weight: 600;
}

.ai-pop-bubble ul,
.ai-pop-bubble ol {
  margin: 6px 0;
  padding-left: 20px;
}

.ai-pop-bubble li {
  margin-bottom: 4px;
}

.ai-pop-body .hi-green {
  color: #10b981;
  font-weight: 600;
}

.ai-pop-body .hi-red {
  color: #ef4444;
  font-weight: 600;
}

.ai-pop-body .hi-yellow {
  color: #f59e0b;
  font-weight: 600;
}

.ai-pop-cursor {
  display: inline-block;
  width: 1.5px;
  height: 0.9em;
  background: var(--purple-light);
  margin-left: 1px;
  vertical-align: middle;
  animation: aioAiBlink .7s step-end infinite;
}

@keyframes aioAiBlink {
  50% {
    opacity: 0;
  }
}

.ai-pop-input-wrap {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: var(--surface-panel-strong);
  border-top: 1px solid var(--border);
}

.ai-pop-input {
  flex: 1;
  background: var(--surface-input);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 0.825rem;
  outline: none;
  transition: all 0.15s;
}

.ai-pop-input::placeholder {
  color: var(--text-muted);
}

.ai-pop-input:focus {
  border-color: var(--purple-light);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}

.ai-pop-send-btn {
  background: linear-gradient(135deg, var(--purple), #5b21b6);
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
}

.ai-pop-send-btn:hover {
  opacity: 0.95;
}

.ai-pop-footer {
  padding: 10px 12px 14px;
  display: flex;
  gap: 8px;
  background: var(--surface-panel-modal);
  border-top: 1px solid var(--border);
  border-bottom-left-radius: 15px;
  border-bottom-right-radius: 15px;
}

.ai-pop-quota-info {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-align: center;
  display: none;
  padding: 2px 0;
}

/* ── Quota exceeded card (inside AI bubble) ── */
.ai-pop-quota-exceeded {
  position: relative;
  overflow: hidden;
  padding: 16px 14px 14px;
  border-radius: 12px;
  text-align: center;
  background: linear-gradient(145deg, rgba(124, 58, 237, .1), rgba(239, 68, 68, .06));
  border: 1px solid rgba(239, 68, 68, .22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}

.ai-pop-qe-glow {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  width: 140px;
  height: 80px;
  background: radial-gradient(ellipse, rgba(124, 58, 237, .35), transparent 70%);
  pointer-events: none;
}

.ai-pop-qe-icon-wrap {
  position: relative;
  z-index: 1;
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  color: #fbbf24;
  background: linear-gradient(135deg, rgba(239, 68, 68, .18), rgba(124, 58, 237, .22));
  border: 1px solid rgba(239, 68, 68, .28);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
}

.ai-pop-qe-title {
  position: relative;
  z-index: 1;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #fca5a5;
  margin-bottom: 6px;
  line-height: 1.35;
}

.ai-pop-qe-desc {
  position: relative;
  z-index: 1;
  font-size: 0.6875rem;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.5;
  margin-bottom: 14px;
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
}

.ai-pop-qe-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.ai-pop-qe-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 0.6875rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform .15s, opacity .15s, box-shadow .15s;
  white-space: nowrap;
}

.ai-pop-qe-btn:hover {
  transform: translateY(-1px);
  opacity: .92;
}

.ai-pop-qe-btn.primary {
  background: linear-gradient(135deg, var(--purple, #7c3aed), #5b21b6);
  color: #fff;
  box-shadow: 0 4px 14px rgba(124, 58, 237, .35);
}

.ai-pop-qe-btn.secondary {
  background: var(--surface-hover, rgba(255, 255, 255, .06));
  border-color: var(--border-glow, rgba(124, 58, 237, .35));
  color: var(--text-primary, #e2e8f0);
}

.ai-pop-qe-btn.secondary:hover {
  background: rgba(124, 58, 237, .12);
  border-color: rgba(124, 58, 237, .5);
}

.ai-pop-act {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--text3);
  cursor: pointer;
  font-size: 0.75rem;
  font-family: inherit;
  transition: all .15s;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.ai-pop-act:hover {
  border-color: var(--border-glow);
  color: var(--text-primary);
  background: var(--purple-dim);
}

.ai-pop-act.primary {
  background: linear-gradient(135deg, var(--purple), #5b21b6);
  border-color: transparent;
  color: #fff;
}

#aiInsightPop .pai-bubble-text {
  color: var(--text-primary);
}

#aiInsightPop .pai-bubble-text code {
  background: var(--surface-hover);
  color: var(--text-primary);
}

#aiInsightPop .pai-bubble-text pre {
  background: var(--surface-card-soft);
  border: 1px solid var(--border);
}

#aiInsightPop .pai-bubble-text th {
  background: var(--purple-dim);
  color: var(--purple-light);
}

#aiInsightPop .pai-bubble-text th,
#aiInsightPop .pai-bubble-text td {
  border-color: var(--border);
  color: var(--text-primary);
}

#aiInsightPop .deep-process-thinking {
  background: var(--surface-card-faint) !important;
  border-left-color: var(--purple) !important;
}

#aiInsightPop .deep-thinking-body {
  color: var(--text-secondary) !important;
}

#aiInsightPop .deep-process-thinking-label {
  color: var(--purple-light) !important;
}

.deep-process-thinking {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.deep-process-thinking-label {
  color: var(--purple-light, #c084fc);
  font-weight: 600;
  font-size: 0.625rem;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.deep-process-thinking-label .fa-spin {
  color: var(--yellow, #fbbf24);
  font-size: 0.5625rem;
}

/* Loading spinners inside AI pop — independent of FA CDN / reduce-motion killing FA keyframes */
@keyframes aioAiPopFaSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

#aiInsightPop .fa-spin,
#aiActiveBubble .fa-spin,
#aioAiInsightPortal .fa-spin,
.ai-pop-bubble .fa-spin,
.ai-content-body .fa-spin,
.pai-bubble-text .fa-spin {
  display: inline-block !important;
  animation: aioAiPopFaSpin 0.85s linear infinite !important;
  transform-origin: center center !important;
}

@media (prefers-reduced-motion: reduce) {
  #aiInsightPop .fa-spin,
  #aiActiveBubble .fa-spin,
  #aioAiInsightPortal .fa-spin,
  .ai-pop-bubble .fa-spin,
  .ai-content-body .fa-spin,
  .pai-bubble-text .fa-spin {
    /* Keep motion for loading affordance — only slow it down */
    animation-duration: 1.4s !important;
  }
}

.deep-thinking-body {
  color: var(--text-muted, #94a3b8);
  line-height: 1.5;
  max-height: 160px;
  overflow-y: auto;
  font-style: italic;
}

.rag-cite-anchor {
  position: relative;
  display: inline;
  vertical-align: baseline;
}

.rag-cite-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.15rem;
  margin: 0 2px;
  padding: 0 5px;
  border: 1px solid rgba(245, 158, 11, .45);
  border-radius: 999px;
  background: rgba(245, 158, 11, .14);
  color: #fbbf24;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  vertical-align: super;
  font-family: inherit;
  transition: background .15s, border-color .15s, transform .12s;
  pointer-events: auto;
}

.rag-cite-chip:hover,
.rag-cite-chip.is-active {
  background: rgba(245, 158, 11, .28);
  border-color: #f59e0b;
  transform: translateY(-1px);
}

.rag-cite-popover {
  position: fixed;
  z-index: 100050;
  width: min(300px, calc(100vw - 24px));
  border-radius: 10px;
  overflow: hidden;
  animation: aioRagPopoverIn .14s ease;
  --rag-arrow-left: 50%;
  --rag-pop-bg: #0e0e2a;
  --rag-pop-border: rgba(245, 158, 11, .48);
  --rag-pop-shadow: 0 10px 32px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .06);
  --rag-pop-snippet-bg: rgba(255, 255, 255, .05);
  --rag-pop-snippet-border: rgba(245, 158, 11, .42);
  background: var(--rag-pop-bg);
  border: 1px solid var(--rag-pop-border);
  box-shadow: var(--rag-pop-shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.rag-cite-popover::after {
  content: '';
  position: absolute;
  left: var(--rag-arrow-left);
  bottom: -6px;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--rag-pop-border);
}

.rag-cite-popover::before {
  content: '';
  position: absolute;
  left: var(--rag-arrow-left);
  bottom: -5px;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--rag-pop-bg);
}

.rag-cite-popover.is-below::after {
  bottom: auto;
  top: -6px;
  border-top-color: transparent;
  border-bottom-color: var(--rag-pop-border);
}

.rag-cite-popover.is-below::before {
  bottom: auto;
  top: -5px;
  border-top-color: transparent;
  border-bottom-color: var(--rag-pop-bg);
}

@keyframes aioRagPopoverIn {
  from {
    opacity: 0;
    transform: translateY(4px) scale(.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.rag-cite-popover-inner {
  padding: 10px 12px;
  background: var(--rag-pop-bg);
  color: var(--text-primary);
}

.rag-cite-popover-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.rag-cite-popover-close {
  margin-left: auto;
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-hover);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  padding: 0;
}

.rag-cite-popover-close:hover {
  background: rgba(239, 68, 68, .18);
  border-color: rgba(239, 68, 68, .45);
  color: #f87171;
}

.rag-cite-popover-label {
  flex: 1;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.rag-cite-popover-meta {
  font-size: 0.64rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  line-height: 1.35;
}

.rag-cite-popover-snippet {
  max-height: 140px;
  overflow-y: auto;
  font-size: 0.7rem;
  line-height: 1.5;
  color: var(--text-secondary);
  padding: 7px 9px;
  border-left: 2px solid var(--rag-pop-snippet-border);
  background: var(--rag-pop-snippet-bg);
  border-radius: 0 6px 6px 0;
  white-space: pre-wrap;
}

.rag-source-cite-id {
  background: rgba(245, 158, 11, .15);
  color: #fbbf24;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.6rem;
  font-weight: 800;
}

:root[data-mockup-theme-resolved="light"] #aiInsightPop {
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12), 0 0 0 1px var(--border);
}

:root[data-mockup-theme-resolved="light"] .ai-pop-header {
  background: linear-gradient(90deg, rgba(124, 58, 237, .07) 0%, rgba(6, 182, 212, .04) 100%);
}

:root[data-mockup-theme-resolved="light"] .ai-ribbon-tag {
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}

:root[data-mockup-theme-resolved="light"] .ai-pop-bubble.ai {
  background: var(--surface-card-faint);
  border-color: var(--border2);
}

:root[data-mockup-theme-resolved="light"] .rag-cite-chip {
  background: rgba(217, 119, 6, 0.1);
  border-color: rgba(217, 119, 6, 0.45);
  color: #b45309;
}

:root[data-mockup-theme-resolved="light"] .rag-cite-chip:hover,
:root[data-mockup-theme-resolved="light"] .rag-cite-chip.is-active {
  background: rgba(217, 119, 6, 0.22);
  border-color: #d97706;
  color: #78350f;
}

:root[data-mockup-theme-resolved="light"] .rag-cite-popover {
  --rag-pop-bg: #ffffff;
  --rag-pop-border: rgba(217, 119, 6, 0.35);
  --rag-pop-shadow: 0 10px 32px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(15, 23, 42, 0.06);
  --rag-pop-snippet-bg: rgba(241, 245, 249, 0.95);
}

:root[data-mockup-theme-resolved="light"] .ai-pop-quota-exceeded {
  background: linear-gradient(145deg, rgba(124, 58, 237, .06), rgba(239, 68, 68, .04));
  border-color: rgba(239, 68, 68, .2);
}

:root[data-mockup-theme-resolved="light"] .ai-pop-qe-title {
  color: #dc2626;
}

:root[data-mockup-theme-resolved="light"] .ai-pop-qe-btn.secondary {
  background: #f8fafc;
  border-color: rgba(124, 58, 237, .25);
  color: #0f172a;
}

/* ═══ Deep mini-chart side-car (Phase 1.5 enhancer) ═══ */
.ai-pop-minichart {
  position: absolute;
  right: calc(100% + 10px);
  top: 0;
  width: 380px;
  height: 100%;
  background: var(--surface-panel-modal, #0d0d1e);
  border: 1px solid var(--border-glow, rgba(124, 58, 237, 0.35));
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
  z-index: 100050;
  overflow: hidden;
  animation: aioMinichartPopIn .18s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes aioMinichartPopIn {
  from {
    opacity: 0;
    transform: scale(.95) translateX(8px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateX(0);
  }
}

.mini-chart-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: linear-gradient(90deg, rgba(124, 58, 237, .12) 0%, rgba(6, 182, 212, .06) 100%);
  border-bottom: 1px solid var(--border);
  border-top-left-radius: 15px;
  border-top-right-radius: 15px;
}

.mini-chart-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}

.mini-chart-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
  border-radius: 4px;
  transition: all .15s;
  line-height: 1;
}

.mini-chart-close:hover {
  color: var(--text-primary);
  background: var(--surface-hover-strong);
}

.mini-chart-canvas {
  flex: 1;
  position: relative;
  background: var(--surface-chart);
  overflow: hidden;
}

#aiMiniChartCanvas>div {
  background: transparent !important;
}

:root[data-mockup-theme-resolved="light"] .ai-pop-minichart {
  background: var(--surface-panel-modal);
  border-color: var(--border);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12), 0 0 0 1px var(--border);
}

:root[data-mockup-theme-resolved="light"] .mini-chart-header {
  background: linear-gradient(90deg, rgba(124, 58, 237, .07) 0%, rgba(6, 182, 212, .04) 100%);
  border-bottom-color: var(--border);
}

:root[data-mockup-theme-resolved="light"] .mini-chart-title {
  color: var(--text-primary);
}

:root[data-mockup-theme-resolved="light"] .mini-chart-canvas {
  background: var(--surface-chart);
}

/* ═══ Global AI FAB (Phase 2) ═══ */
#aioAiFab.aio-ai-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50000;
  width: 58px;
  height: 58px;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
  transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), opacity .22s, visibility .22s;
  -webkit-tap-highlight-color: transparent;
}

#aioAiFab.aio-ai-fab.aio-ai-fab-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(.82) translateY(8px);
}

#aioAiFab .aio-ai-fab-glow {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(from 210deg, rgba(124, 58, 237, .55), rgba(6, 182, 212, .45), rgba(124, 58, 237, .55));
  filter: blur(6px);
  opacity: .75;
  animation: aioFabGlow 3.2s ease-in-out infinite;
}

#aioAiFab .aio-ai-fab-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(145deg, #7c3aed 0%, #5b21b6 55%, #4c1d95 100%);
  border: 1px solid rgba(255, 255, 255, .18);
  box-shadow: 0 10px 28px rgba(124, 58, 237, .42), 0 2px 8px rgba(0, 0, 0, .35);
  color: #fff;
  transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), box-shadow .2s;
}

#aioAiFab .aio-ai-fab-inner i {
  font-size: 1.15rem;
  line-height: 1;
}

#aioAiFab .aio-ai-fab-label {
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1;
  opacity: .92;
}

#aioAiFab.aio-ai-fab:hover .aio-ai-fab-inner {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(124, 58, 237, .5), 0 4px 12px rgba(0, 0, 0, .35);
}

#aioAiFab.aio-ai-fab:active .aio-ai-fab-inner {
  transform: translateY(0) scale(.96);
}

@keyframes aioFabGlow {

  0%,
  100% {
    opacity: .55;
    transform: scale(1);
  }

  50% {
    opacity: .9;
    transform: scale(1.06);
  }
}

@media (max-width: 1024px) {
  #aioAiFab.aio-ai-fab {
    right: 16px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    width: 54px;
    height: 54px;
  }
}

:root[data-mockup-theme-resolved="light"] #aioAiFab .aio-ai-fab-inner {
  box-shadow: 0 10px 28px rgba(124, 58, 237, .28), 0 2px 8px rgba(15, 23, 42, .12);
}

/* ═══ FAB standby welcome (mirrors chat #msgWelcome) ═══ */
#aiPopBody.ai-pop-body-welcome {
  justify-content: center;
  align-items: center;
  padding: 16px 14px 20px;
}

#aiInsightPop .ai-pop-welcome.member-welcome {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  text-align: center;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

#aiInsightPop .ai-pop-welcome .mw-hero {
  margin-bottom: 18px;
  padding: 4px 0;
  animation: aioMwFadeInDown .45s ease-out;
}

#aiInsightPop .ai-pop-welcome .mw-eyebrow {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0 0 8px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

#aiInsightPop .ai-pop-welcome .mw-title {
  font-size: clamp(1.2rem, 4.5vw, 1.55rem);
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
  color: var(--text-primary);
  letter-spacing: -.02em;
}

#aiInsightPop .ai-pop-welcome .mw-chips-container {
  width: 100%;
  animation: aioMwFadeInUp .5s ease-out .06s both;
}

#aiInsightPop .ai-pop-welcome .mw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 0 auto;
}

#aiInsightPop .ai-pop-welcome .mw-chip {
  background: var(--surface-card, rgba(255, 255, 255, .04));
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}

#aiInsightPop .ai-pop-welcome .mw-chip:hover {
  background: var(--surface-hover-strong, rgba(255, 255, 255, .08));
  border-color: var(--border-glow, rgba(124, 58, 237, .35));
  color: var(--text-primary);
}

#aiInsightPop .ai-pop-welcome .mw-chip i {
  font-size: 0.78rem;
  opacity: .92;
}

@keyframes aioMwFadeInDown {
  from {
    opacity: 0;
    transform: translateY(-14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes aioMwFadeInUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

:root[data-mockup-theme-resolved="light"] #aiInsightPop .ai-pop-welcome .mw-chip:hover {
  border-color: rgba(124, 58, 237, .28);
}