/* Entity links share the conversation's typography and stay secondary to the answer. */
.fxm-ai-ui .fxm-ai-entities {
  min-width: 0;
  margin-block: 12px;
  color: var(--color-on-surface);
  font-family: var(--font-body);
  container-type: inline-size;
}
.fxm-ai-ui .fxm-ai-entities-title {
  margin: 0 0 10px;
  color: var(--ai-ink, #2f2658);
  font: 600 13px/1.6 var(--font-body);
}
.fxm-ai-ui .fxm-ai-entity-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.fxm-ai-ui .fxm-ai-entity-grid > li {
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.fxm-ai-ui .fxm-ai-entity-card {
  display: flex;
  align-items: center;
  gap: 14px;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 76px;
  height: 100%;
  padding: 12px 14px 12px 12px;
  border: 1px solid var(--ai-card-line, color-mix(in srgb, var(--color-on-surface) 9%, var(--color-surface)));
  border-radius: 16px;
  background: #fff;
  color: var(--color-on-surface);
  font: 13px/1.55 var(--font-body);
  text-align: start;
  text-decoration: none;
  box-shadow: 0 1px 2px rgb(24 20 51 / 3%), 0 8px 20px -18px rgb(47 38 88 / 40%);
}
.fxm-ai-ui a.fxm-ai-entity-card {
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .2s ease, transform .2s ease;
}
.fxm-ai-ui a.fxm-ai-entity-card:hover {
  border-color: color-mix(in srgb, var(--color-primary) 22%, var(--color-surface));
  background: #fff;
  color: var(--color-on-surface);
  text-decoration: none;
  box-shadow: var(--ai-card-shadow, 0 10px 24px -16px rgb(79 52 217 / 45%));
  transform: translateY(-1px);
}
.fxm-ai-ui a.fxm-ai-entity-card:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}
/* Logos read at a glance: a landscape tile fits broker wordmarks and
 * regulator emblems alike without cropping either. */
.fxm-ai-ui .fxm-ai-entity-media {
  position: relative;
  display: inline-flex;
  align-items: center;
  align-self: center;
  justify-content: center;
  flex: 0 0 84px;
  box-sizing: border-box;
  width: 84px;
  height: 52px;
  overflow: hidden;
  border: 1px solid var(--ai-tile-line, color-mix(in srgb, var(--color-on-surface) 8%, var(--color-surface)));
  border-radius: 12px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--color-primary) 7%, var(--color-surface)), color-mix(in srgb, #14b8a6 6%, var(--color-surface)));
  color: var(--color-primary);
}
.fxm-ai-ui .fxm-ai-entity-media--logo { background: #fff; }
/* No logo or cover: a small type icon instead of an empty landscape tile. */
.fxm-ai-ui .fxm-ai-entity-media:not(.fxm-ai-entity-media--logo) { flex-basis: 44px; width: 44px; height: 44px; border: 0; }
.fxm-ai-ui .fxm-ai-entity-media:not(.fxm-ai-entity-media--logo) svg { width: 20px; height: 20px; }
.fxm-ai-ui .fxm-ai-entity-placeholder { display: inline-flex; }
.fxm-ai-ui .fxm-ai-entity-media svg { width: 22px; height: 22px; }
.fxm-ai-ui .fxm-ai-entity-media > img {
  position: absolute;
  inset: 0;
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: 6px 8px;
  background: #fff;
  object-fit: contain;
}
.fxm-ai-ui .fxm-ai-entity-media > img[hidden] { display: none; }
.fxm-ai-ui .fxm-ai-entity-card[data-entity-type="NEWS"] .fxm-ai-entity-media--logo {
  flex-basis: 96px;
  width: 96px;
  height: 64px;
  border: 0;
  border-radius: 10px;
}
.fxm-ai-ui .fxm-ai-entity-card[data-entity-type="NEWS"] .fxm-ai-entity-media > img { padding: 0; object-fit: cover; }
.fxm-ai-ui a.fxm-ai-entity-card[data-entity-type="NEWS"] { align-items: flex-start; }
.fxm-ai-ui a.fxm-ai-entity-card[data-entity-type="NEWS"] .fxm-ai-entity-name {
  display: -webkit-box;
  overflow: hidden;
  font-size: 13px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.fxm-ai-ui .fxm-ai-entity-content { display: block; flex: 1; min-width: 0; }
.fxm-ai-ui .fxm-ai-entity-kind {
  display: block;
  margin-bottom: 2px;
  color: var(--ai-data-muted, var(--color-on-surface));
  font: 400 11px/1.45 var(--font-body);
}
.fxm-ai-ui .fxm-ai-entity-name {
  display: block;
  color: #2f2658;
  font: 600 14px/1.5 var(--font-body);
  overflow-wrap: anywhere;
  word-break: normal;
}
.fxm-ai-ui .fxm-ai-entity-meta {
  display: block;
  margin-top: 4px;
  color: var(--ai-data-muted, var(--color-on-surface));
  font: 400 11px/1.6 var(--font-body);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.fxm-ai-ui .fxm-ai-entity-refs {
  display: block;
  margin-top: 4px;
  color: var(--color-primary);
  font: 400 10px/1.6 var(--font-body);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.fxm-ai-ui .fxm-ai-entity-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  align-self: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--color-primary) 6%, var(--color-surface));
  color: var(--color-primary);
  transition: background-color .15s ease, color .15s ease;
}
.fxm-ai-ui .fxm-ai-entity-arrow > svg { width: 14px; height: 14px; }
.fxm-ai-ui a.fxm-ai-entity-card:hover .fxm-ai-entity-arrow { background: var(--color-primary); color: var(--color-on-primary, #fff); }
.fxm-ai-ui .fxm-ai-entity-card:not(a) .fxm-ai-entity-arrow { display: none; }

/* Curated entity card (unified doc v10.10 §6.10, design spec §5.22): rows
 * stack in template order and a missing key drops its row. The title row is
 * the detail link, so the card itself is not one (link pills sit inside). */
/* Same surface as the subject card, without the map: soft gradient, purple
 * lift and the short accent tab. */
.fxm-ai-ui .fxm-ai-entity-card--full {
  position: relative;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  min-height: 0;
  overflow: hidden;
  padding: 18px 18px 16px;
  border-color: var(--ai-card-line, color-mix(in srgb, var(--color-on-surface) 9%, var(--color-surface)));
  border-radius: 18px;
  background: linear-gradient(120deg, #fff 0%, #fbfbfd 55%, #f5f5fa 100%);
  box-shadow: var(--ai-card-shadow, 0 1px 2px rgb(24 20 51 / 3%));
  container-type: inline-size;
}
.fxm-ai-ui .fxm-ai-entities--subject .fxm-ai-entity-card--full::after { position: absolute; top: 0; left: 18px; width: 56px; height: 3px; border-radius: 0 0 999px 999px; background: linear-gradient(90deg, #4f34d9, #6b55f8 55%, #89dfd7); content: ""; }
.fxm-ai-ui .fxm-ai-entity-card--full .fxm-ai-entity-media--logo { box-shadow: var(--ai-tile-shadow, none); }
.fxm-ai-ui .fxm-ai-entity-card--full .fxm-ai-entity-name { font-size: 15px; }
.fxm-ai-ui .fxm-ai-entity-head {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
}
.fxm-ai-ui .fxm-ai-entity-head:hover { color: inherit; text-decoration: none; }
.fxm-ai-ui .fxm-ai-entity-head:hover .fxm-ai-entity-name { color: var(--color-primary); }
.fxm-ai-ui .fxm-ai-entity-head:hover .fxm-ai-entity-arrow { background: var(--color-primary); color: var(--color-on-primary, #fff); }
.fxm-ai-ui .fxm-ai-entity-head:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; }
.fxm-ai-ui .fxm-ai-entity-subtitle {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: #6b6f7d;
  font: 400 12px/1.5 var(--font-body);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.fxm-ai-ui .fxm-ai-entity-card--full .fxm-ai-entity-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.fxm-ai-ui .fxm-ai-entity-card--full[data-entity-type="NEWS"] .fxm-ai-entity-name {
  display: -webkit-box;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.fxm-ai-ui .fxm-ai-entity-summary {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: #6b6f7d;
  font: 400 12px/1.6 var(--font-body);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
/* One score, one fixed brand colour: the bar never turns red or green. */
.fxm-ai-ui .fxm-ai-entity-metric { display: flex; align-items: center; gap: 10px; min-width: 0; }
.fxm-ai-ui .fxm-ai-entity-metric-label { color: #6b6f7d; font: 400 12px/1.5 var(--font-body); white-space: nowrap; }
.fxm-ai-ui .fxm-ai-entity-metric-value {
  color: #2f2658;
  font: 600 15px/1.3 var(--font-body);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.fxm-ai-ui .fxm-ai-entity-metric-max { margin-left: 2px; color: #9a9eaa; font: 400 11px/1.3 var(--font-body); }
.fxm-ai-ui .fxm-ai-entity-meter {
  flex: 1 1 auto;
  max-width: 220px;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-primary) 12%, var(--color-surface));
}
.fxm-ai-ui .fxm-ai-entity-meter > span { display: block; height: 100%; border-radius: inherit; background: var(--color-primary); }
.fxm-ai-ui .fxm-ai-entity-badges,
.fxm-ai-ui .fxm-ai-entity-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; }
.fxm-ai-ui .fxm-ai-entity-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: #f4f4f7;
  color: #5b6070;
  font: 500 11px/1 var(--font-body);
  white-space: nowrap;
}
.fxm-ai-ui .fxm-ai-entity-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.fxm-ai-ui .fxm-ai-entity-badge--positive { background: #f0fdf4; color: #166534; }
.fxm-ai-ui .fxm-ai-entity-badge--caution { background: #fffbeb; color: #92400e; }
/* Facts keep the server's order: label left, value right; a wide card lays
 * the (at most three) facts out as tiles. */
.fxm-ai-ui .fxm-ai-entity-facts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin: 0; }
.fxm-ai-ui .fxm-ai-entity-fact { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-width: 0; }
.fxm-ai-ui .fxm-ai-entity-fact dt { flex: none; color: #6b6f7d; font: 400 12px/1.5 var(--font-body); white-space: nowrap; }
.fxm-ai-ui .fxm-ai-entity-fact dd {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--color-on-surface);
  font: 500 12px/1.5 var(--font-body);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
  text-overflow: ellipsis;
}
/* Narrow: a white label/value list; wide: white tiles like the KPI cards. */
.fxm-ai-ui .fxm-ai-entity-card--full .fxm-ai-entity-facts { gap: 0; padding: 2px 12px; border: 1px solid var(--ai-tile-line, #ece9f5); border-radius: 12px; background: #fff; }
.fxm-ai-ui .fxm-ai-entity-card--full .fxm-ai-entity-fact { padding: 7px 0; }
.fxm-ai-ui .fxm-ai-entity-card--full .fxm-ai-entity-fact + .fxm-ai-entity-fact { border-top: 1px solid var(--ai-tile-line, #ece9f5); }
@container (min-width: 520px) {
  .fxm-ai-ui .fxm-ai-entity-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .fxm-ai-ui .fxm-ai-entity-fact { flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 2px; padding: 8px 10px; border-radius: 8px; background: #f8f7fc; }
  .fxm-ai-ui .fxm-ai-entity-fact dd { font-size: 13px; text-align: left; }
  .fxm-ai-ui .fxm-ai-entity-card--full .fxm-ai-entity-facts { padding: 0; border: 0; background: transparent; }
  .fxm-ai-ui .fxm-ai-entity-card--full .fxm-ai-entity-fact { padding: 10px 14px; border: 1px solid var(--ai-tile-line, #ece9f5); border-radius: 12px; background: #fff; box-shadow: var(--ai-tile-shadow, none); }
  .fxm-ai-ui .fxm-ai-entity-card--full .fxm-ai-entity-fact + .fxm-ai-entity-fact { border-top: 1px solid var(--ai-tile-line, #ece9f5); }
  .fxm-ai-ui .fxm-ai-entity-card--full .fxm-ai-entity-fact dd { color: var(--ai-ink, #2f2658); font-size: 14px; font-weight: 600; }
}
.fxm-ai-ui .fxm-ai-entity-link {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  height: 24px;
  padding: 0 8px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--color-on-surface) 12%, var(--color-surface));
  border-radius: 6px;
  color: var(--color-on-surface);
  font: 500 11px/1 var(--font-body);
  text-decoration: none;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}
.fxm-ai-ui .fxm-ai-entity-link:hover {
  border-color: color-mix(in srgb, var(--color-primary) 32%, var(--color-surface));
  background: color-mix(in srgb, var(--color-primary) 5%, var(--color-surface));
  color: var(--color-primary);
  text-decoration: none;
}
.fxm-ai-ui .fxm-ai-entity-link:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.fxm-ai-ui .fxm-ai-entity-more { display: inline-flex; align-items: center; height: 24px; color: #9a9eaa; font: 400 11px/1 var(--font-body); }
.fxm-ai-ui .fxm-ai-entity-foot { margin: 0; line-height: 1; }
.fxm-ai-ui .fxm-ai-entity-foot .fxm-ai-entity-refs { margin-top: 0; }
/* One subject card spans the row; compare heads sit side by side. */
.fxm-ai-ui .fxm-ai-entities--full .fxm-ai-entity-grid { grid-template-columns: minmax(0, 1fr); }
/* Related entities: the toggle sits on the title line and swaps the
 * compact cards for the full ones. */
.fxm-ai-ui .fxm-ai-entities--mentioned { position: relative; }
.fxm-ai-ui .fxm-ai-entities-expand > summary {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--color-primary);
  font: 500 12px/1.6 var(--font-body);
  cursor: pointer;
  list-style: none;
}
.fxm-ai-ui .fxm-ai-entities-expand > summary::-webkit-details-marker { display: none; }
.fxm-ai-ui .fxm-ai-entities-expand > summary:focus-visible { border-radius: 4px; outline: 2px solid var(--color-primary); outline-offset: 2px; }
.fxm-ai-ui .fxm-ai-entities-expand > summary svg { width: 12px; height: 12px; transform: rotate(90deg); }
.fxm-ai-ui .fxm-ai-entities-expand[open] > summary svg { transform: rotate(-90deg); }
.fxm-ai-ui .fxm-ai-entities-expand:not([open]) .fxm-ai-when-open,
.fxm-ai-ui .fxm-ai-entities-expand[open] .fxm-ai-when-closed { display: none; }
.fxm-ai-ui .fxm-ai-entities-expand[open] + .fxm-ai-entity-grid { display: none; }

/* Sponsored content (AI chat unified doc §6.13): the server sends structure
 * only, so the "Ad" badge, the answer-level tag and the risk line are ours.
 * The badge is neutral and always legible; it must never be hidden. */
.fxm-ai-ui .fxm-ai-ad-badge {
  display: inline-flex;
  align-items: center;
  margin-inline-start: 6px;
  padding: 0 6px;
  border: 1px solid color-mix(in srgb, #b45309 28%, var(--color-surface));
  border-radius: 4px;
  background: color-mix(in srgb, #f59e0b 10%, var(--color-surface));
  color: #92400e;
  font: 600 10px/1.6 var(--font-body);
  letter-spacing: .02em;
  vertical-align: 1px;
  white-space: nowrap;
}
.fxm-ai-ui .fxm-ai-sponsor-tag { margin: 0 0 8px; line-height: 1; }
.fxm-ai-ui .fxm-ai-sponsor-tag .fxm-ai-ad-badge { margin-inline-start: 0; }
.fxm-ai-ui .fxm-ai-sponsored {
  min-width: 0;
  margin-block: 12px;
  container-type: inline-size;
}
.fxm-ai-ui .fxm-ai-sponsored-card { max-width: 560px; height: auto; }
.fxm-ai-ui .fxm-ai-sponsored-card .fxm-ai-entity-meta {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  color: color-mix(in srgb, var(--color-on-surface) 72%, var(--color-surface));
  font-size: 12px;
}
.fxm-ai-ui .fxm-ai-sponsored-note {
  margin: 6px 2px 0;
  color: var(--ai-data-muted, var(--color-on-surface));
  font: 400 11px/1.6 var(--font-body);
}

/* Clarify candidates (CHOICES): one card per option on the subject card's
 * surface; a candidate shows its logo, and the name-match caution is amber
 * rather than an alarm red. */
.fxm-ai-ui .fxm-ai-choices {
  padding: 16px;
  border: 1px solid var(--ai-card-line, #ece9f5);
  border-radius: 18px;
  background: linear-gradient(120deg, #fff 0%, #fbfbfd 55%, #f5f5fa 100%);
  box-shadow: var(--ai-card-shadow, none);
}
.fxm-ai-ui .fxm-ai-choices-title { color: var(--ai-ink, #2f2658); font-size: 14px; }
.fxm-ai-ui .fxm-ai-choice-card {
  padding: 10px 14px 10px 12px;
  border: 1px solid var(--ai-tile-line, #ece9f5);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--ai-tile-shadow, none);
  transition: border-color .15s ease, box-shadow .2s ease;
}
.fxm-ai-ui .fxm-ai-choice-card:hover { border-color: color-mix(in srgb, var(--color-primary) 26%, var(--color-surface)); box-shadow: var(--ai-card-shadow, none); }
.fxm-ai-ui .fxm-ai-choice-btn--media { display: flex; align-items: center; gap: 12px; }
.fxm-ai-ui .fxm-ai-choice-body { display: block; flex: 1; min-width: 0; }
.fxm-ai-ui .fxm-ai-choice-media {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 64px;
  box-sizing: border-box;
  width: 64px;
  height: 40px;
  overflow: hidden;
  border: 1px solid var(--ai-tile-line, #ece9f5);
  border-radius: 10px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--color-primary) 7%, var(--color-surface)), color-mix(in srgb, #14b8a6 6%, var(--color-surface)));
  color: var(--color-primary);
}
.fxm-ai-ui .fxm-ai-choice-media--logo { background: #fff; }
.fxm-ai-ui .fxm-ai-choice-media > img { position: absolute; inset: 0; display: block; box-sizing: border-box; width: 100%; height: 100%; padding: 5px 6px; background: #fff; object-fit: contain; }
.fxm-ai-ui .fxm-ai-choice-media > img[hidden] { display: none; }
.fxm-ai-ui .fxm-ai-choice-label { color: var(--ai-ink, #2f2658); font-size: 13px; }
.fxm-ai-ui .fxm-ai-choice-btn:hover .fxm-ai-choice-label { color: var(--color-primary); }
.fxm-ai-ui .fxm-ai-choice-desc { color: #8a8f9c; font-size: 12px; overflow-wrap: anywhere; }
.fxm-ai-ui .fxm-ai-choice-warning { border: 1px solid rgb(245 158 11 / 24%); background: #fffbeb; color: #92400e; font-size: 11px; font-weight: 500; }

@container (max-width: 479px) {
  .fxm-ai-ui .fxm-ai-entity-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 639px) {
  .fxm-ai-ui .fxm-ai-entity-grid { grid-template-columns: minmax(0, 1fr); }
  .fxm-ai-ui .fxm-ai-entity-card { gap: 12px; padding: 10px 12px 10px 10px; }
  .fxm-ai-ui .fxm-ai-entity-card--full { gap: 10px; padding: 16px 14px 14px; border-radius: 16px; }
  .fxm-ai-ui .fxm-ai-entities--subject .fxm-ai-entity-card--full::after { left: 14px; }
  .fxm-ai-ui .fxm-ai-entity-head { gap: 12px; }
  .fxm-ai-ui .fxm-ai-entity-media--logo { flex-basis: 72px; width: 72px; height: 46px; }
  .fxm-ai-ui .fxm-ai-entity-card[data-entity-type="NEWS"] .fxm-ai-entity-media--logo { flex-basis: 80px; width: 80px; height: 54px; }
  .fxm-ai-ui .fxm-ai-choices { padding: 14px 12px; border-radius: 16px; }
  .fxm-ai-ui .fxm-ai-choice-card { padding: 10px; }
  .fxm-ai-ui .fxm-ai-choice-media { flex-basis: 56px; width: 56px; height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  .fxm-ai-ui a.fxm-ai-entity-card,
  .fxm-ai-ui .fxm-ai-entity-link,
  .fxm-ai-ui .fxm-ai-entity-arrow,
  .fxm-ai-ui .fxm-ai-choice-card { transition: none; }
  .fxm-ai-ui a.fxm-ai-entity-card:hover { transform: none; }
}
