/* Michael Chatbot — floating launcher + side drawer (grant: chatbot) */
.michael-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 550;
  width: 72px;
  height: 72px;
  border-radius: 9999px;
  border: 3px solid rgba(219, 226, 234, 0.95);
  padding: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  /* Light default — matches portal lightSurface / lightBg so Michael’s art stays vivid */
  background: radial-gradient(circle at 40% 30%, #ffffff 0%, #f3f5f9 52%, #e8eef6 100%);
  box-shadow:
    0 0 0 2px rgba(47, 129, 247, 0.22),
    0 10px 28px -6px rgba(15, 23, 42, 0.18),
    0 0 18px -4px rgba(249, 115, 22, 0.22);
  /* visible so the unread badge can sit outside the avatar circle */
  overflow: visible;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease, background 0.2s ease, border-color 0.2s ease;
}
html.dark .michael-launcher {
  border-color: rgba(36, 50, 71, 0.95);
  background: radial-gradient(circle at 40% 30%, #334155 0%, #1e293b 55%, #0f172a 100%);
  box-shadow:
    0 0 0 2px rgba(47, 129, 247, 0.35),
    0 10px 28px -6px rgba(0, 0, 0, 0.45),
    0 0 20px -4px rgba(249, 115, 22, 0.3);
}
.michael-launcher:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow:
    0 0 0 2px rgba(47, 129, 247, 0.4),
    0 14px 32px -6px rgba(15, 23, 42, 0.22),
    0 0 22px -2px rgba(249, 115, 22, 0.35);
}
html.dark .michael-launcher:hover {
  box-shadow:
    0 0 0 2px rgba(47, 129, 247, 0.5),
    0 14px 32px -6px rgba(0, 0, 0, 0.55),
    0 0 24px -2px rgba(249, 115, 22, 0.45);
}
.michael-launcher.michael-launcher--dragging,
.michael-launcher.michael-launcher--dragging:hover {
  cursor: grabbing;
  transform: scale(1.06);
  transition: none;
  box-shadow:
    0 0 0 2px rgba(47, 129, 247, 0.55),
    0 18px 36px -6px rgba(0, 0, 0, 0.35),
    0 0 28px -2px rgba(249, 115, 22, 0.5);
}
.michael-launcher.michael-launcher--placed {
  right: auto;
  bottom: auto;
}
.michael-launcher:focus-visible {
  outline: 3px solid #2f81f7;
  outline-offset: 3px;
}
.michael-launcher img {
  width: 92%;
  height: 92%;
  object-fit: contain;
  object-position: center center;
  display: block;
  margin: 4% auto;
  pointer-events: none;
  border-radius: 9999px;
  /* Keep pixel-art edges sharp when scaled into the circle */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
}
html.dark .michael-launcher img {
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}
.michael-launcher[aria-expanded="true"] {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.88);
}
.michael-launcher-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 9999px;
  border: 2px solid rgba(249, 115, 22, 0.4);
  animation: michaelPulse 2.5s ease-out infinite;
  pointer-events: none;
  z-index: 0;
}
.michael-notify-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  z-index: 6;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 5px;
  border-radius: 9999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1.35rem;
  text-align: center;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.95);
  pointer-events: none;
}
html.dark .michael-notify-badge {
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.95);
}
.michael-drawer-notify-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 1rem;
  height: 1rem;
  padding: 0 4px;
  border-radius: 9999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1rem;
  text-align: center;
}
.michael-notifications-btn.is-active {
  background: rgba(249, 115, 22, 0.15);
  color: #c2410c;
}
html.dark .michael-notifications-btn.is-active {
  color: #fdba74;
}
.michael-notify-panel {
  display: none;
}
.michael-notify-panel.open {
  display: flex;
}
.michael-notify-panel.hidden {
  display: none !important;
}
.michael-notify-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.michael-notify-toolbar h3 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: inherit;
}
.michael-notify-card {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
html.dark .michael-notify-card {
  background: rgba(24, 35, 56, 0.85);
  border-color: rgba(100, 116, 139, 0.45);
}
.michael-notify-card.is-read {
  opacity: 0.72;
}
.michael-notify-card-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: inherit;
  margin: 0;
}
.michael-notify-card-meta {
  font-size: 0.7rem;
  color: #64748b;
}
html.dark .michael-notify-card-meta {
  color: #94a3b8;
}
.michael-notify-card-body {
  font-size: 0.78rem;
  line-height: 1.4;
  margin: 0;
  color: inherit;
}
.michael-notify-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
@keyframes michaelPulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* Theme-tinted launcher / drawer avatar rings (Michael art stays full color) */
html.theme-light-blue .michael-launcher,
html.theme-light-blue .michael-drawer-avatar {
  background: radial-gradient(circle at 40% 30%, #ffffff 0%, #e7f0fb 55%, #d4e4f7 100%);
  border-color: rgba(185, 204, 229, 0.95);
}
html.theme-light-purple .michael-launcher,
html.theme-light-purple .michael-drawer-avatar {
  background: radial-gradient(circle at 40% 30%, #ffffff 0%, #f3eefb 55%, #e6dcf5 100%);
  border-color: rgba(205, 190, 230, 0.95);
}
html.theme-light-green .michael-launcher,
html.theme-light-green .michael-drawer-avatar {
  background: radial-gradient(circle at 40% 30%, #ffffff 0%, #eefaf3 55%, #d8f3e4 100%);
  border-color: rgba(180, 220, 200, 0.95);
}
html.theme-light-pink .michael-launcher,
html.theme-light-pink .michael-drawer-avatar {
  background: radial-gradient(circle at 40% 30%, #ffffff 0%, #fbf0f5 55%, #f3dde8 100%);
  border-color: rgba(230, 195, 210, 0.95);
}
html.theme-qm.dark .michael-launcher,
html.theme-qm.dark .michael-drawer-avatar {
  background: radial-gradient(circle at 40% 30%, #2a3a55 0%, #1a2740 55%, #0f1828 100%);
}
html.theme-dark-purple.dark .michael-launcher,
html.theme-dark-purple.dark .michael-drawer-avatar {
  background: radial-gradient(circle at 40% 30%, #3a3158 0%, #2a2248 55%, #1a1430 100%);
  border-color: rgba(90, 70, 140, 0.75);
}
html.theme-dark-green.dark .michael-launcher,
html.theme-dark-green.dark .michael-drawer-avatar {
  background: radial-gradient(circle at 40% 30%, #244838 0%, #183528 55%, #0a1712 100%);
  border-color: rgba(60, 120, 90, 0.7);
}
html.theme-dark-pink.dark .michael-launcher,
html.theme-dark-pink.dark .michael-drawer-avatar {
  background: radial-gradient(circle at 40% 30%, #3d2c36 0%, #2f222a 55%, #140d11 100%);
  border-color: rgba(140, 80, 110, 0.7);
}
html.theme-neon-pink.dark .michael-launcher,
html.theme-neon-pink.dark .michael-drawer-avatar {
  background: radial-gradient(circle at 40% 30%, #3a1530 0%, #2a0a1d 55%, #100409 100%);
  border-color: rgba(236, 72, 153, 0.55);
  box-shadow:
    0 0 0 2px rgba(236, 72, 153, 0.35),
    0 10px 28px -6px rgba(0, 0, 0, 0.5),
    0 0 22px -2px rgba(249, 115, 22, 0.35);
}
html.theme-cyber.dark .michael-launcher,
html.theme-cyber.dark .michael-drawer-avatar {
  background: radial-gradient(circle at 40% 30%, #1c1c22 0%, #141418 55%, #000000 100%);
  border-color: rgba(34, 211, 238, 0.45);
}
html.theme-glass.dark .michael-launcher,
html.theme-glass.dark .michael-drawer-avatar {
  background: radial-gradient(circle at 40% 30%, rgba(50, 90, 150, 0.95) 0%, rgba(26, 48, 92, 0.95) 60%, rgba(16, 39, 74, 1) 100%);
  border-color: rgba(120, 170, 230, 0.45);
}
html.theme-arctic-teal.dark .michael-launcher,
html.theme-arctic-teal.dark .michael-drawer-avatar {
  background: radial-gradient(circle at 40% 30%, rgba(30, 120, 130, 0.95) 0%, rgba(10, 72, 82, 0.95) 60%, #053036 100%);
  border-color: rgba(45, 212, 191, 0.45);
}
html.theme-aurora.dark .michael-launcher,
html.theme-aurora.dark .michael-drawer-avatar {
  background: radial-gradient(circle at 40% 30%, rgba(50, 90, 150, 0.95) 0%, rgba(22, 48, 88, 0.95) 60%, #0a1428 100%);
  border-color: rgba(129, 140, 248, 0.45);
}
html.theme-ember-glass.dark .michael-launcher,
html.theme-ember-glass.dark .michael-drawer-avatar {
  background: radial-gradient(circle at 40% 30%, rgba(140, 70, 45, 0.95) 0%, rgba(48, 26, 16, 0.95) 60%, #2a0f08 100%);
  border-color: rgba(251, 146, 60, 0.5);
}
html.theme-hc .michael-launcher,
html.theme-hc .michael-drawer-avatar {
  background: #000;
  border-color: #fff;
  box-shadow: 0 0 0 2px #fff, 0 10px 24px rgba(0, 0, 0, 0.5);
}

@media (max-width: 420px) {
  .michael-clear-label { display: none; }
}

.michael-backdrop {
  position: fixed;
  inset: 0;
  z-index: 560;
  background: rgba(11, 18, 32, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.michael-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.michael-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 570;
  width: min(400px, 94vw);
  height: 100%;
  display: flex;
  flex-direction: column;
  transform: translateX(105%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: -16px 0 48px rgba(0, 0, 0, 0.35);
}
.michael-drawer.open {
  transform: translateX(0);
}

.michael-drawer-avatar {
  width: 44px;
  height: 44px;
  border-radius: 9999px;
  overflow: hidden;
  border: 2px solid rgba(249, 115, 22, 0.55);
  background: radial-gradient(circle at 40% 30%, #ffffff 0%, #f3f5f9 55%, #e8eef6 100%);
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
html.dark .michael-drawer-avatar {
  background: radial-gradient(circle at 40% 30%, #334155 0%, #1e293b 60%, #0f172a 100%);
  border-color: rgba(249, 115, 22, 0.65);
}
.michael-drawer-avatar img {
  width: 90%;
  height: 90%;
  object-fit: contain;
  object-position: center center;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}

.michael-msg {
  max-width: 92%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.michael-msg--user { align-self: flex-end; }
.michael-msg--bot { align-self: flex-start; }
.michael-bubble {
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
}
.michael-msg--user .michael-bubble {
  background: #2f81f7;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.michael-msg--bot .michael-bubble {
  border-bottom-left-radius: 4px;
}
.michael-cite-row {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.michael-cms-flag {
  display: inline-block;
  margin: 0 0 8px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #fecaca;
  background: rgba(220, 38, 38, 0.25);
  border: 1px solid rgba(248, 113, 113, 0.55);
}
.michael-citation {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  text-align: left;
}
.michael-citation:hover {
  color: #fb923c;
  text-decoration: underline;
}

.michael-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
  padding: 0 2px;
}
.michael-chip {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(255, 255, 255, 0.85);
  color: #334155;
  font-size: 11.5px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.2;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.michael-chip:hover {
  border-color: rgba(249, 115, 22, 0.65);
  color: #c2410c;
  background: rgba(255, 247, 237, 0.95);
}
html.dark .michael-chip,
.dark .michael-chip {
  background: rgba(30, 41, 59, 0.9);
  color: #e2e8f0;
  border-color: rgba(100, 116, 139, 0.55);
}
html.dark .michael-chip:hover,
.dark .michael-chip:hover {
  border-color: rgba(251, 146, 60, 0.7);
  color: #fdba74;
  background: rgba(67, 20, 7, 0.45);
}

/* Phase A — slim scope bar above the ask box (full-width input) */
.michael-composer {
  display: flex;
  flex-direction: column;
}
.michael-scope-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 0 12px;
  min-height: 0;
}
.michael-scope-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 5px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 1 1 auto;
  min-width: 0;
  padding-bottom: 1px;
  scroll-behavior: smooth;
}
.michael-scope-chips::-webkit-scrollbar {
  display: none;
}
.michael-scope-scroll {
  display: none;
  flex-shrink: 0;
  align-items: center;
  gap: 1px;
  margin-left: 2px;
}
.michael-scope-bar.is-scrollable .michael-scope-scroll {
  display: inline-flex;
}
.michael-scope-scroll-btn {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  line-height: 0;
  transition: color 0.12s ease, background 0.12s ease, opacity 0.12s ease;
}
.michael-scope-scroll-btn .material-symbols-outlined {
  font-size: 16px;
  font-variation-settings: "FILL" 0, "wght" 500, "GRAD" 0, "opsz" 20;
}
.michael-scope-scroll-btn:hover:not(:disabled) {
  color: #c2410c;
  background: rgba(255, 247, 237, 0.85);
}
.michael-scope-scroll-btn:disabled {
  opacity: 0.28;
  cursor: default;
}
html.dark .michael-scope-scroll-btn {
  color: #64748b;
}
html.dark .michael-scope-scroll-btn:hover:not(:disabled) {
  color: #fdba74;
  background: rgba(67, 20, 7, 0.4);
}
.michael-scope-chip {
  appearance: none;
  flex-shrink: 0;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: transparent;
  color: #64748b;
  font-size: 11px;
  font-weight: 650;
  font-family: inherit;
  line-height: 1;
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.michael-scope-chip:hover {
  border-color: rgba(249, 115, 22, 0.45);
  color: #c2410c;
  background: rgba(255, 247, 237, 0.7);
}
.michael-scope-chip.is-active {
  border-color: rgba(249, 115, 22, 0.65);
  background: rgba(255, 247, 237, 0.95);
  color: #c2410c;
}
html.dark .michael-scope-chip {
  color: #94a3b8;
  border-color: rgba(100, 116, 139, 0.45);
}
html.dark .michael-scope-chip:hover {
  border-color: rgba(251, 146, 60, 0.5);
  color: #fdba74;
  background: rgba(67, 20, 7, 0.35);
}
html.dark .michael-scope-chip.is-active {
  border-color: rgba(251, 146, 60, 0.65);
  background: rgba(67, 20, 7, 0.45);
  color: #fdba74;
}

@media (prefers-reduced-motion: reduce) {
  .michael-launcher-pulse { display: none; }
  .michael-launcher,
  .michael-drawer,
  .michael-backdrop { transition: none !important; }
}
