.leo-opinions-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 8px;
  border: 1px solid rgba(78, 179, 255, .22);
  border-radius: 6px;
  background: rgba(4, 13, 26, .85);
}

.leo-opinions-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #4eb3ff;
  margin-right: 4px;
}

.leo-opinion-chip {
  border: 1px solid #1a3a5c;
  border-radius: 999px;
  background: #07111f;
  color: #9ec9e8;
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
}

.leo-opinion-chip.actionable { border-color: #22c55e; color: #86efac; }
.leo-opinion-chip.watch { border-color: #f5a623; color: #fcd34d; }
.leo-opinion-chip.wait { border-color: #64748b; color: #94a3b8; }

body.leo-chat-mounted {
  --leo-chat-launcher-size: 52px;
  --leo-chat-launcher-gap: 18px;
  --leo-chat-launcher-bottom: 18px;
  --leo-chat-safe-area: calc(var(--leo-chat-launcher-size) + var(--leo-chat-launcher-bottom) + var(--leo-chat-launcher-gap) + env(safe-area-inset-bottom, 0px));
  padding-bottom: max(var(--leo-chat-safe-area), env(safe-area-inset-bottom, 0px));
}

body.leo-chat-mounted main,
body.leo-chat-mounted .main-panel,
body.leo-chat-mounted .ms-workspace-body,
body.leo-chat-mounted .ms-workspace-main,
body.leo-chat-mounted [class*="table-scroll"],
body.leo-chat-mounted [class*="table-wrap"],
body.leo-chat-mounted [class*="scroll-panel"],
body.leo-chat-mounted [class*="results-list"],
body.leo-chat-mounted [class*="data-list"] {
  box-sizing: border-box;
  scroll-padding-bottom: var(--leo-chat-safe-area);
}

body.leo-chat-mounted [class*="table-scroll"],
body.leo-chat-mounted [class*="table-wrap"],
body.leo-chat-mounted [class*="scroll-panel"] {
  padding-bottom: max(var(--leo-chat-safe-area), 88px);
}

body.leo-chat-mounted:has(#la-cookie-bar) {
  --leo-chat-launcher-bottom: 72px;
}

body.leo-chat-mounted:has(#linealgo-api-usage-tracker) {
  --leo-chat-launcher-bottom: 54px;
}

body.leo-chat-mounted:has(#la-cookie-bar):has(#linealgo-api-usage-tracker) {
  --leo-chat-launcher-bottom: 108px;
}

.leo-chat-launcher {
  position: fixed;
  right: 18px;
  bottom: calc(var(--leo-chat-launcher-bottom, 18px) + env(safe-area-inset-bottom, 0px));
  z-index: 1000003;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: var(--leo-chat-launcher-size, 52px);
  min-width: var(--leo-chat-launcher-size, 52px);
  height: var(--leo-chat-launcher-size, 52px);
  min-height: var(--leo-chat-launcher-size, 52px);
  padding: 0;
  border: 1px solid rgba(78, 179, 255, .56);
  border-radius: 999px;
  background: linear-gradient(180deg, #1763ff, #0c43bf);
  box-shadow: 0 18px 42px rgba(0, 0, 0, .42), 0 0 0 1px rgba(255, 255, 255, .06) inset;
  color: transparent;
  font-size: 0;
  font-weight: 950;
  letter-spacing: .03em;
  text-transform: uppercase;
  overflow: visible;
  transition: width .18s ease, min-width .18s ease, border-radius .18s ease, opacity .16s ease, transform .16s ease, color .16s ease, font-size .16s ease;
}

.leo-chat-launcher::before {
  content: "LEO";
  display: inline-grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: rgba(7, 17, 31, .92);
  color: #bff0ff;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 950;
  box-shadow: inset 0 0 0 1px rgba(125, 211, 252, .26);
}

@media (hover: hover) and (pointer: fine) {
  .leo-chat-launcher:hover,
  .leo-chat-launcher:focus-visible {
    width: 132px;
    min-width: 132px;
    justify-content: flex-start;
    gap: 8px;
    padding-right: 14px;
    border-radius: 999px;
    color: #fff;
    font-size: 12px;
  }

  .leo-chat-launcher:hover::before,
  .leo-chat-launcher:focus-visible::before {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    margin-left: 4px;
  }
}

body.leo-chat-is-scrolling .leo-chat-launcher[aria-expanded="false"] {
  opacity: .14;
  pointer-events: none;
  transform: translateY(12px) scale(.78);
}

body.ms-body .leo-chat-launcher {
  right: 18px !important;
  bottom: calc(var(--leo-chat-launcher-bottom, 18px) + env(safe-area-inset-bottom, 0px)) !important;
}

body.ms-body.ms-grok-gil-visible .leo-chat-launcher {
  --leo-chat-launcher-bottom: 76px;
}

body.ms-body.ms-strategy-dock-visible .leo-chat-launcher {
  --leo-chat-launcher-bottom: 92px;
  right: 12px !important;
}

body.ms-body.ms-grok-gil-visible.ms-strategy-dock-visible .leo-chat-launcher {
  --leo-chat-launcher-bottom: 156px;
}

body.leo-chat-mounted .ms-grok-gil-status {
  padding-right: calc(var(--leo-chat-launcher-size, 52px) + 20px) !important;
}

.leo-chat-panel {
  position: fixed;
  right: 18px;
  bottom: calc(var(--leo-chat-launcher-size, 52px) + 30px);
  z-index: 1000004;
  display: grid;
  grid-template-rows: auto minmax(180px, 1fr) auto;
  width: min(420px, calc(100vw - 24px));
  height: min(620px, calc(100vh - 104px));
  overflow: hidden;
  border: 1px solid rgba(78, 179, 255, .42);
  border-radius: 8px;
  background: #07111f;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .58);
}

.leo-chat-panel[hidden],
.leo-chat-launcher[hidden] {
  display: none;
}

/* Stay above cookie consent + API usage tracker overlays */
body:has(#la-cookie-bar) .leo-chat-launcher {
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}

body:has(#la-cookie-bar) .leo-chat-panel {
  bottom: calc(130px + env(safe-area-inset-bottom, 0px));
}

body:has(#linealgo-api-usage-tracker) .leo-chat-launcher {
  bottom: calc(54px + env(safe-area-inset-bottom, 0px));
}

body:has(#linealgo-api-usage-tracker) .leo-chat-panel {
  bottom: calc(112px + env(safe-area-inset-bottom, 0px));
}

body:has(#la-cookie-bar):has(#linealgo-api-usage-tracker) .leo-chat-launcher {
  bottom: calc(108px + env(safe-area-inset-bottom, 0px));
}

body:has(#la-cookie-bar):has(#linealgo-api-usage-tracker) .leo-chat-panel {
  bottom: calc(166px + env(safe-area-inset-bottom, 0px));
}

.leo-chat-guide {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #7dd3fc;
  text-decoration: none;
  padding: 4px 8px;
  border: 1px solid rgba(125, 211, 252, .35);
  border-radius: 6px;
  align-self: center;
}

.leo-chat-guide:hover {
  background: rgba(78, 179, 255, .12);
}

.leo-chat-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid rgba(78, 179, 255, .24);
  background: linear-gradient(180deg, #0e1b30, #081321);
}

.leo-chat-title {
  display: grid;
  gap: 4px;
}

.leo-chat-title strong {
  color: #fff;
  font-size: 16px;
  font-weight: 950;
}

.leo-chat-context {
  color: #a8c7e8;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.35;
}

.leo-chat-ops-host {
  display: grid;
  gap: 4px;
}

.leo-chat-ops-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  margin: 0;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: #7eb8e8;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
}

.leo-chat-ops-toggle:hover,
.leo-chat-ops-toggle:focus-visible {
  color: #b8dcff;
  outline: none;
}

.leo-chat-ops-chevron {
  font-size: 11px;
  line-height: 1;
}

.leo-chat-ops-panel {
  color: #8fb0d8;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  line-height: 1.4;
  padding: 6px 8px;
  border: 1px solid rgba(78, 179, 255, .18);
  border-radius: 6px;
  background: rgba(4, 13, 26, .72);
}

.leo-chat-ops-panel[hidden] {
  display: none;
}

.leo-chat-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 6px;
  background: rgba(255, 255, 255, .04);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
}

.leo-chat-log {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow-y: auto;
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(78, 179, 255, .05), transparent 220px),
    #07111f;
}

.leo-chat-msg {
  max-width: 92%;
  padding: 10px 11px;
  border: 1px solid rgba(78, 179, 255, .18);
  border-radius: 8px;
  background: rgba(255, 255, 255, .05);
  color: #edf6ff;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.leo-chat-msg.user {
  justify-self: end;
  border-color: rgba(217, 164, 65, .38);
  background: rgba(217, 164, 65, .14);
  color: #fff6d8;
}

.leo-chat-msg.system {
  max-width: 100%;
  border-color: rgba(64, 224, 208, .25);
  background: rgba(64, 224, 208, .08);
}

.leo-chat-proof {
  display: grid;
  gap: 3px;
  margin-top: 8px;
  color: #8fb0d8;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
}

.leo-chat-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid rgba(78, 179, 255, .24);
  background: #081321;
}

.leo-chat-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.leo-chat-prompts[hidden] {
  display: none;
}

.leo-chat-prompt-chip {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(78, 179, 255, .34);
  border-radius: 999px;
  background: rgba(78, 179, 255, .1);
  color: #d8ecff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .01em;
  cursor: pointer;
}

.leo-chat-prompt-chip:hover {
  border-color: rgba(64, 224, 208, .55);
  background: rgba(64, 224, 208, .14);
  color: #fff;
}

.leo-chat-form textarea {
  width: 100%;
  min-height: 76px;
  max-height: 150px;
  resize: vertical;
  border: 1px solid rgba(78, 179, 255, .28);
  border-radius: 8px;
  background: #0d1628;
  color: #fff;
  padding: 10px;
  font: 600 13px/1.4 "Space Grotesk", system-ui, sans-serif;
}

.leo-chat-form textarea:focus {
  outline: 2px solid rgba(78, 179, 255, .35);
}

.leo-chat-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.leo-chat-send {
  min-height: 38px;
  border: 1px solid rgba(78, 179, 255, .75);
  border-radius: 7px;
  background: linear-gradient(180deg, #1a73e8, #0f4fb8);
  color: #ffffff;
  padding: 0 14px;
  font-weight: 950;
  text-transform: uppercase;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .35);
}

.leo-chat-send:disabled {
  cursor: wait;
  opacity: .58;
}

.leo-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #b8d4f2;
}

.leo-chat-spinner {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(78, 179, 255, .22);
  border-top-color: #4eb3ff;
  border-radius: 50%;
  animation: leo-chat-spin .75s linear infinite;
}

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

/* Mastery toasts — position is set in JS (mastery-components.js) to clear Ask LEO + trackers */

@media (max-width: 720px) {
  .leo-chat-panel {
    inset: auto 8px calc(var(--leo-chat-launcher-size, 52px) + 28px + env(safe-area-inset-bottom, 0px)) 8px;
    width: auto;
    height: min(560px, calc(100vh - 132px));
  }

  .leo-chat-launcher {
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
}
