:root {
  --iic-blue: #214fa2;
  --iic-indigo: #252b70;
  --iic-violet: #6755d9;
  --iic-ink: #17213b;
  --iic-muted: #718096;
  --iic-border: #e7eaf2;
  --iic-surface: #ffffff;
}

#iic-innovator-root {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 999999;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--iic-ink);
  line-height: 1.5;
}

#iic-innovator-root *,
#iic-innovator-root *::before,
#iic-innovator-root *::after {
  box-sizing: border-box;
}

.iic-launcher {
  width: 66px;
  height: 66px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, #214fa2 0%, #3c65c6 38%, #6955d9 72%, #8b63dc 100%);
  box-shadow: 0 8px 28px rgba(43, 66, 155, .35);
  transition: transform .2s ease, box-shadow .2s ease;
  position: relative;
}

.iic-launcher:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 12px 34px rgba(43, 66, 155, .43);
}

.iic-launcher::before {
  content: "";
  position: absolute;
  inset: -5px;
  border: 1px solid rgba(83, 98, 205, .28);
  border-radius: inherit;
  animation: iic-pulse 2.6s ease-out infinite;
}

.iic-launcher svg {
  width: 30px;
  height: 30px;
}

.iic-launcher-label {
  position: absolute;
  right: 76px;
  white-space: nowrap;
  color: white;
  background: #202b58;
  padding: 8px 13px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 650;
  box-shadow: 0 3px 14px rgba(0,0,0,.13);
}

.iic-panel {
  position: absolute;
  right: 0;
  bottom: 84px;
  width: min(390px, calc(100vw - 32px));
  height: min(590px, calc(100dvh - 130px));
  min-height: 390px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: var(--iic-surface);
  border: 1px solid rgba(30, 50, 100, .09);
  border-radius: 19px;
  box-shadow: 0 18px 65px rgba(24, 35, 80, .2);
  animation: iic-appear .2s ease-out;
}

.iic-panel.iic-open {
  display: flex;
}

.iic-header {
  padding: 17px 18px;
  color: white;
  background: linear-gradient(115deg, #202b70, #214fa2 65%, #6554cb);
  display: flex;
  align-items: center;
  gap: 12px;
}

.iic-avatar {
  width: 39px;
  height: 39px;
  flex: 0 0 39px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.17);
  border: 1px solid rgba(255,255,255,.2);
  font-size: 18px;
  font-weight: 800;
}

.iic-heading {
  flex: 1;
  min-width: 0;
}

.iic-heading strong {
  display: block;
  font-size: 15px;
  font-weight: 750;
  letter-spacing: -.2px;
  color: white;
}

.iic-heading small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: rgba(255,255,255,.78);
}

.iic-header-actions {
  display: flex;
  gap: 5px;
}

.iic-header button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  color: white;
  background: rgba(255,255,255,.13);
  cursor: pointer;
  font-size: 18px;
}

.iic-header button:hover {
  background: rgba(255,255,255,.25);
}

.iic-status {
  padding: 8px 17px;
  border-bottom: 1px solid #f0f1f6;
  font-size: 10px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 7px;
}

.iic-status-dot {
  width: 7px;
  height: 7px;
  background: #20b47a;
  border-radius: 50%;
}

.iic-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 17px 14px 12px;
  background: #f8f9fc;
  scroll-behavior: smooth;
}

.iic-welcome {
  padding: 8px 2px 15px;
}

.iic-welcome h3 {
  margin: 0 0 7px;
  font-size: 19px;
  line-height: 1.3;
  color: #202b70;
  font-weight: 750;
}

.iic-welcome p {
  margin: 0;
  color: #68758b;
  font-size: 12px;
  line-height: 1.7;
}

.iic-suggestions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 14px;
}

.iic-suggestion {
  padding: 10px 12px;
  border: 1px solid #e2e7f2;
  background: white;
  border-radius: 11px;
  color: #34466f;
  text-align: left;
  font-size: 11px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.iic-suggestion:hover {
  border-color: #7892d5;
  background: #f4f6ff;
}

.iic-message {
  max-width: 88%;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.iic-message.user {
  margin-left: auto;
  align-items: flex-end;
}

.iic-message.assistant {
  margin-right: auto;
}

.iic-bubble {
  padding: 10px 12px;
  border-radius: 13px;
  font-size: 12px;
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.iic-message.user .iic-bubble {
  background: #2854a5;
  color: white;
  border-bottom-right-radius: 4px;
}

.iic-message.assistant .iic-bubble {
  background: white;
  color: #29364d;
  border: 1px solid #edf0f5;
  border-bottom-left-radius: 4px;
}

.iic-message-time {
  font-size: 9px;
  color: #94a0b3;
  padding: 0 4px;
}

.iic-sources {
  margin-top: 5px;
  padding: 8px 10px;
  background: #eef2fb;
  border-radius: 9px;
  font-size: 10px;
  color: #52627d;
}

.iic-sources strong {
  display: block;
  margin-bottom: 4px;
  color: #34466f;
}

.iic-source-item {
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.iic-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 12px;
  background: white;
  border: 1px solid #edf0f5;
  border-radius: 12px;
}

.iic-typing span {
  width: 5px;
  height: 5px;
  background: #7383b4;
  border-radius: 50%;
  animation: iic-dot 1s infinite ease-in-out;
}

.iic-typing span:nth-child(2) { animation-delay: .15s; }
.iic-typing span:nth-child(3) { animation-delay: .3s; }

.iic-composer {
  padding: 11px 12px 8px;
  background: white;
  border-top: 1px solid #edf0f5;
}

.iic-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 6px;
  background: #f5f6fa;
  border: 1px solid #e7eaf1;
  border-radius: 13px;
}

.iic-input-row textarea {
  flex: 1;
  width: 100%;
  min-width: 0;
  max-height: 95px;
  min-height: 36px;
  resize: none;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  color: #24324b !important;
  padding: 8px 7px !important;
  margin: 0 !important;
  font: inherit;
  font-size: 12px;
  line-height: 1.5;
}

.iic-input-row textarea::placeholder {
  color: #98a1b2;
}

.iic-send {
  width: 37px;
  height: 37px;
  flex: 0 0 37px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #214fa2, #6955d9);
  color: white;
  cursor: pointer;
  font-size: 17px;
}

.iic-send:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.iic-footnote {
  text-align: center;
  font-size: 9px;
  color: #9aa4b5;
  padding-top: 7px;
}

.iic-inline-launcher {
  display: none;
}

@keyframes iic-pulse {
  0% { transform: scale(.94); opacity: .8; }
  100% { transform: scale(1.34); opacity: 0; }
}

@keyframes iic-appear {
  from { opacity: 0; transform: translateY(9px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes iic-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 480px) {
  #iic-innovator-root {
    right: 14px;
    bottom: 14px;
  }

  .iic-launcher {
    width: 59px;
    height: 59px;
  }

  .iic-panel {
    position: fixed;
    right: 8px;
    bottom: 8px;
    width: calc(100vw - 16px);
    height: min(690px, calc(100dvh - 16px));
    max-height: calc(100dvh - 16px);
    border-radius: 17px;
  }

  .iic-panel.iic-mobile-full {
    z-index: 1000000;
  }
}

@media (prefers-reduced-motion: reduce) {
  #iic-innovator-root *,
  #iic-innovator-root *::before,
  #iic-innovator-root *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* IIC Innovator UI refinement */
#iic-innovator-root .iic-header-actions {
  align-items: center;
  flex: 0 0 auto;
}

#iic-innovator-root .iic-header button,
#iic-innovator-root .iic-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  vertical-align: middle;
  appearance: none;
  -webkit-appearance: none;
}

#iic-innovator-root .iic-header button {
  width: 36px;
  height: 36px;
  min-width: 36px;
  flex: 0 0 36px;
}

#iic-innovator-root .iic-header button svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#iic-innovator-root .iic-send {
  width: 40px;
  height: 40px;
  min-width: 40px;
  flex: 0 0 40px;
  margin: 0;
}

#iic-innovator-root .iic-send svg {
  display: block;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#iic-innovator-root .iic-send:disabled {
  opacity: .75;
  cursor: wait;
}

#iic-innovator-root .iic-send-spinner {
  width: 17px;
  height: 17px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: white;
  border-radius: 50%;
  animation: iic-spin .7s linear infinite;
}

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

/* Formatted assistant messages */
#iic-innovator-root .iic-bubble p {
  margin: 0 0 9px;
}

#iic-innovator-root .iic-bubble p:last-child {
  margin-bottom: 0;
}

#iic-innovator-root .iic-bubble h3,
#iic-innovator-root .iic-bubble h4 {
  margin: 9px 0 5px;
  color: #202b70;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 750;
}

#iic-innovator-root .iic-bubble h3:first-child,
#iic-innovator-root .iic-bubble h4:first-child {
  margin-top: 0;
}

#iic-innovator-root .iic-bubble ul,
#iic-innovator-root .iic-bubble ol {
  margin: 5px 0 9px;
  padding-left: 20px;
}

#iic-innovator-root .iic-bubble li {
  margin: 3px 0;
  padding-left: 2px;
}

#iic-innovator-root .iic-bubble strong {
  color: #202b70;
  font-weight: 750;
}

#iic-innovator-root .iic-bubble a {
  color: #2455ad;
  text-decoration: underline;
  overflow-wrap: anywhere;
}

#iic-innovator-root .iic-bubble code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #f0f2f8;
  font-size: .92em;
}

#iic-innovator-root .iic-bubble del {
  opacity: .7;
}

#iic-innovator-root .iic-bubble {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}

/* Tablet */
@media (max-width: 768px) {
  #iic-innovator-root {
    right: 18px;
    bottom: 18px;
  }

  #iic-innovator-root .iic-panel {
    width: min(390px, calc(100vw - 36px));
    height: min(620px, calc(100dvh - 112px));
  }
}

/* Mobile: keep the composer above the on-screen keyboard */
@media (max-width: 640px) {
  #iic-innovator-root {
    right: 14px;
    bottom: max(14px, env(safe-area-inset-bottom));
  }

  #iic-innovator-root .iic-launcher {
    width: 58px;
    height: 58px;
  }

  #iic-innovator-root .iic-launcher-label {
    display: none;
  }

  #iic-innovator-root .iic-panel {
    position: fixed;
    inset: auto 8px max(8px, env(safe-area-inset-bottom)) 8px;
    width: auto;
    height: min( min(720px, 82dvh), calc(100dvh - 16px));
    min-height: 320px;
    max-height: calc(100dvh - 16px);
    border-radius: 17px;
  }

  #iic-innovator-root .iic-header {
    padding: 13px 14px;
  }

  #iic-innovator-root .iic-messages {
    padding: 14px 12px 10px;
    -webkit-overflow-scrolling: touch;
  }

  #iic-innovator-root .iic-message {
    max-width: 94%;
  }

  #iic-innovator-root .iic-bubble {
    font-size: 13px;
  }

  #iic-innovator-root .iic-composer {
    padding: 9px 10px max(9px, env(safe-area-inset-bottom));
  }

  #iic-innovator-root .iic-input-row textarea {
    font-size: 16px;
  }

  #iic-innovator-root .iic-status {
    font-size: 10px;
  }
}

@media (max-width: 360px) {
  #iic-innovator-root .iic-header {
    gap: 8px;
  }

  #iic-innovator-root .iic-heading strong {
    font-size: 14px;
  }

  #iic-innovator-root .iic-heading small {
    font-size: 10px;
  }

  #iic-innovator-root .iic-header button {
    width: 32px;
    height: 32px;
    min-width: 32px;
    flex-basis: 32px;
  }
}
