/**
 * MSI Chat Widget — styles
 * ------------------------------------------------------------------
 * All brand values live in the CSS custom properties below. Swap those
 * once the real logo/colors/fonts are confirmed — nothing else in this
 * file needs to change.
 *
 * Everything is scoped under #msi-chat-root so host-theme CSS can't
 * bleed in and the widget can't leak out.
 * ------------------------------------------------------------------
 */

/* ================================================================= */
/* Tokens                                                            */
/* ================================================================= */

#msi-chat-root {
  /*
   * Brand palette. Primary Blue is #005796 — sampled from the live
   * production site and confirmed by the client at the 2026-08-20 staging
   * review. This supersedes the concept board's #0A2D56, which was only an
   * approximation of the real site colour.
   *
   * White on #005796 is ~7.5:1: clears WCAG AA (4.5:1) for normal text and
   * AAA (7:1) as well, so the same value is safe on solid fills AND as
   * text on the light surfaces.
   */
  --msi-navy: #005796;        /* primary — header, launcher, user bubble */
  --msi-navy-dark: #003F6C;   /* hover / pressed — same hue, ~28% darker */
  --msi-accent: #1E88E5;      /* accent — rules, highlights, badge, borders */

  /*
   * --msi-cta used to be a separately darkened shade, because the old
   * primary's partner accent (#1E88E5) is only ~3.7:1 on white and failed
   * AA on solid CTA buttons. #005796 clears AA/AAA on its own, so the CTA
   * no longer needs its own hex — these deliberately converge on the
   * primary, and the pair is kept only so a future divergence is a
   * one-line change rather than a find-and-replace.
   */
  --msi-cta: #005796;
  --msi-cta-dark: #003F6C;

  /*
   * Neutrals.
   *
   * The brand's Steel Gray is #6B7280, which is ~4.83:1 on white — fine —
   * but only ~4.46:1 on --msi-bg (#F4F6F8), and muted text sits on that
   * surface in several places (citation "Source" label, form intro). That
   * is below the 4.5:1 AA threshold for normal-size text, so this token is
   * darkened just enough to clear AA on BOTH surfaces (~4.82:1 on
   * --msi-bg, ~5.22:1 on white).
   *
   * Visually indistinguishable from #6B7280 at text sizes. (--msi-cta used
   * to carry the same "keep the brand value for non-text, darken it for
   * text" split; #005796 passes on both counts, so only this neutral still
   * needs it.)
   */
  --msi-bg: #F4F6F8;
  --msi-surface: #FFFFFF;
  --msi-surface-alt: #FAFBFC;
  --msi-text: #16212B;
  --msi-text-muted: #656D7A;
  --msi-border: #DDE3E8;
  --msi-border-strong: #C3CCD4;

  /* Status */
  --msi-success: #14663F;
  --msi-success-bg: #E8F6EF;
  --msi-error: #A32316;
  --msi-error-bg: #FCEDEB;
  --msi-error-border: #F2C9C3;
  --msi-online: #34D399;

  /* Focus ring — used everywhere, never removed */
  --msi-focus: #0B5FFF;
  --msi-focus-on-dark: #FFFFFF;

  /* Shape & motion */
  --msi-radius: 16px;
  --msi-radius-sm: 10px;
  --msi-shadow-lg: 0 18px 48px -12px rgba(13, 30, 44, 0.32), 0 4px 12px rgba(13, 30, 44, 0.10);
  --msi-shadow-btn: 0 6px 18px -4px rgba(13, 30, 44, 0.38);
  --msi-ease: cubic-bezier(0.22, 1, 0.36, 1);

  /*
   * Matches the site's typography (U1). The theme already loads Manrope
   * globally — a hardcoded Google Fonts <link> in header.php, not a
   * wp_enqueue_style — so this only has to *reference* the family. The
   * plugin deliberately does not enqueue a font of its own: that would be
   * a second loading mechanism for a face the page already has, and would
   * make the widget fetch a webfont on sites that don't use Manrope.
   *
   * The system stack stays as the fallback, so the widget still looks
   * right in preview.html and on any site without Manrope loaded.
   */
  --msi-font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  position: fixed;
  z-index: 999999;
  bottom: 0;
  right: 0;
  font-family: var(--msi-font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--msi-text);
  text-align: left;
  -webkit-font-smoothing: antialiased;
}

/* ================================================================= */
/* Expanded-layout-viewport correction (U2)                          */
/*                                                                   */
/* If ANY element on the host page overflows horizontally, mobile     */
/* browsers widen the LAYOUT viewport to the content width instead of */
/* clipping — and they scale the height with it. On a 393x852 phone a */
/* single 1100px-wide theme element makes the layout viewport         */
/* 1101x2385. Every position:fixed element resolves against THAT, so  */
/* `bottom: 16px; right: 16px` puts the launcher at (321, 2313) —     */
/* off the bottom of the screen and untappable — and the full-screen  */
/* window becomes wider than the display, which is what produced the  */
/* horizontal scrolling and the cut-off header buttons on iOS.        */
/*                                                                    */
/* We can't fix the host theme from in here, and overflowing pages    */
/* are common enough that the widget has to survive them. `transform` */
/* makes #msi-chat-root a containing block for its position:fixed     */
/* descendants, so the launcher and window resolve against root's box */
/* — which the JS pins to the VISUAL viewport (what the user actually */
/* sees). One mechanism corrects both axes.                           */
/*                                                                    */
/* Applied only when syncViewportInsets() measures a real discrepancy, */
/* so well-behaved pages keep the plain fixed positioning and none of  */
/* the tuned iOS keyboard behaviour below changes.                     */
/* ================================================================= */

#msi-chat-root.msi-vv-x {
  left: var(--msi-vvx-left, 0px);
  top: var(--msi-vvx-top, 0px);
  right: auto;
  bottom: auto;
  width: var(--msi-vvx-width);
  height: var(--msi-vvx-height);
  transform: translateZ(0);
  /*
   * Root now spans the whole screen at z-index 999999. Without this it
   * would swallow every click on the page behind it — the children below
   * opt back in individually.
   */
  pointer-events: none;
}

#msi-chat-root.msi-vv-x .msi-launcher,
#msi-chat-root.msi-vv-x .msi-window {
  pointer-events: auto;
}

/*
 * Root's box already tracks the visual viewport, including the shrink when
 * the on-screen keyboard opens, so `inset: 0` on the mobile window is
 * enough. Neutralise the keyboard rule's own offsets here or they apply a
 * second time on top of root's.
 */
#msi-chat-root.msi-vv-x.msi-vv-active .msi-window {
  top: 0;
  height: 100%;
}

/* ================================================================= */
/* Scoped reset — host themes style buttons/inputs aggressively       */
/* ================================================================= */

#msi-chat-root *,
#msi-chat-root *::before,
#msi-chat-root *::after {
  box-sizing: border-box;
}

/*
 * Author `display` declarations beat the UA's [hidden] { display: none },
 * so every component that sets display would otherwise ignore the hidden
 * attribute. One rule closes the whole class of bug.
 */
#msi-chat-root [hidden] {
  display: none !important;
}

#msi-chat-root div,
#msi-chat-root p,
#msi-chat-root span,
#msi-chat-root label,
#msi-chat-root h1,
#msi-chat-root h2 {
  margin: 0;
  padding: 0;
}

#msi-chat-root button,
#msi-chat-root input,
#msi-chat-root textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  letter-spacing: normal;
  text-transform: none;
  color: inherit;
  margin: 0;
}

#msi-chat-root button {
  -webkit-appearance: none;
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: inherit;
  box-shadow: none;
  min-height: 0;
  min-width: 0;
  text-decoration: none;
}

#msi-chat-root input,
#msi-chat-root textarea {
  -webkit-appearance: none;
  appearance: none;
  background: var(--msi-surface);
  box-shadow: none;
}

#msi-chat-root a {
  text-decoration: none;
  color: inherit;
  box-shadow: none;
}

#msi-chat-root img {
  max-width: 100%;
  height: auto;
  border: 0;
  display: block;
}

#msi-chat-root svg {
  display: block;
  flex-shrink: 0;
}

/* Visible focus everywhere (U13) */
#msi-chat-root :focus-visible {
  outline: 2px solid var(--msi-focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ...switched to white on the dark header/footer bars */
#msi-chat-root .msi-header :focus-visible,
#msi-chat-root .msi-form-header :focus-visible,
#msi-chat-root .msi-launcher:focus-visible {
  outline-color: var(--msi-focus-on-dark);
  outline-offset: 3px;
}

/* Fallback focus containment for browsers without `inert` */
#msi-chat-root [data-msi-inert] {
  pointer-events: none;
  user-select: none;
}

@media (prefers-reduced-motion: reduce) {
  #msi-chat-root *,
  #msi-chat-root *::before,
  #msi-chat-root *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ================================================================= */
/* Launcher (U1)                                                     */
/* ================================================================= */

#msi-chat-root .msi-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--msi-navy);
  color: #fff;
  box-shadow: var(--msi-shadow-btn);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.22s var(--msi-ease), box-shadow 0.22s var(--msi-ease);
}

#msi-chat-root .msi-launcher:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 10px 26px -4px rgba(13, 30, 44, 0.45);
}

#msi-chat-root .msi-launcher:active {
  transform: translateY(0) scale(0.98);
}

#msi-chat-root .msi-launcher__icon {  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s var(--msi-ease), transform 0.28s var(--msi-ease);
}

#msi-chat-root .msi-launcher__icon svg {  width: 27px;
  height: 27px;
}

#msi-chat-root .msi-launcher__icon--close {  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}

/*
 * Compound, not descendant: `msi-is-open` is set on #msi-chat-root itself
 * (openWidget() in msi-chatbot.js), so `#msi-chat-root .msi-is-open` would
 * look for a *child* carrying the class and never match.
 */
#msi-chat-root.msi-is-open .msi-launcher__icon--chat {  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

#msi-chat-root.msi-is-open .msi-launcher__icon--close {  opacity: 1;
  transform: rotate(0) scale(1);
}

#msi-chat-root .msi-launcher__badge {  position: absolute;
  top: 2px;
  right: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--msi-accent);
  border: 2px solid var(--msi-surface);
  box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.25);
}

/* ================================================================= */
/* Window (U1 / U2)                                                  */
/* ================================================================= */

#msi-chat-root .msi-window {  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: min(640px, calc(100vh - 132px));
  background: var(--msi-bg);
  border: 1px solid var(--msi-border);
  border-radius: var(--msi-radius);
  box-shadow: var(--msi-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: msi-window-in 0.28s var(--msi-ease) both;
}

@keyframes msi-window-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 480px) {
  #msi-chat-root .msi-window {    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    height: 100dvh; /* keeps the composer above the on-screen keyboard */
    border: 0;
    border-radius: 0;
    animation-name: msi-window-in-mobile;
  }


  /*
   * iOS keyboard fallback (U2).
   *
   * `dvh` tracks browser chrome, NOT the on-screen keyboard. iOS Safari
   * shrinks the VISUAL viewport when the keyboard opens while leaving the
   * layout viewport — and therefore 100dvh — at full height, so a
   * position:fixed panel keeps its composer behind the keyboard. Chromium
   * and Android resize the layout viewport instead, which is why this is
   * only observable on iOS.
   *
   * When window.visualViewport exists, the JS tracks its height/offset
   * into these custom properties and adds .msi-vv-active; this rule then
   * wins over the cascade above. Browsers without visualViewport never
   * get the class, so the dvh/% values above stay untouched — additive,
   * not a replacement.
   *
   * Deliberately a separate class-gated rule rather than
   * `height: var(--msi-vv-height, 100dvh)` inline above: on a browser
   * with var() but no dvh (e.g. Safari 15.0–15.3) that fallback is
   * invalid at computed-value time and would collapse height to auto.
   */
  #msi-chat-root.msi-vv-active .msi-window {    height: var(--msi-vv-height);
    top: var(--msi-vv-top, 0px);
    bottom: auto;
  }
  @keyframes msi-window-in-mobile {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  #msi-chat-root .msi-launcher {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }
  /* The full-screen window covers it; keep it out of the tab order too.
     Compound selector — see the note on the icon rules above. */
  #msi-chat-root.msi-is-open .msi-launcher {    display: none;
  }
  /* Stop the page behind from scrolling under the full-screen widget. */
  html.msi-chat-open,
  html.msi-chat-open body {
    overflow: hidden;
  }
}

/* ================================================================= */
/* Header (U3)                                                       */
/* ================================================================= */

#msi-chat-root .msi-header {  background: var(--msi-navy);
  color: #fff;
  padding: 14px 14px 14px 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
  position: relative;
}

/* Thin brand rule under the header */
#msi-chat-root .msi-header::after {  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--msi-accent), rgba(30, 136, 229, 0));
}

/*
 * Sized for the client wordmark (205x91), not a square mark: fixed height,
 * width follows the logo's aspect ratio, capped so a longer logo can never
 * crowd out the assistant name.
 *
 * The white plate is deliberate — the MSI artwork is dark navy on
 * transparent and would disappear against the navy header without it.
 * Swap back to `rgba(255, 255, 255, 0.14)` if a light/knockout logo is
 * ever supplied.
 */
#msi-chat-root .msi-header__logo {  height: 34px;
  min-width: 34px;
  max-width: 116px;
  padding: 0 7px;
  border-radius: 9px;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* contain, never stretch — the intrinsic aspect ratio is preserved
   whatever logo gets dropped in here later. */
#msi-chat-root .msi-header__logo img {  width: auto;
  height: 22px;
  max-width: 100%;
  object-fit: contain;
}

#msi-chat-root .msi-header__meta {  flex: 1;
  min-width: 0;
}

#msi-chat-root .msi-header__name {  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#msi-chat-root .msi-header__status {  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.82);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
}

#msi-chat-root .msi-header__dot {  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--msi-online);
  flex-shrink: 0;
}

#msi-chat-root .msi-header__actions {  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

#msi-chat-root .msi-icon-btn {
  color: rgba(255, 255, 255, 0.88);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, opacity 0.15s ease;
}

#msi-chat-root .msi-icon-btn:hover:not([disabled]) {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

#msi-chat-root .msi-icon-btn[disabled] {
  opacity: 0.35;
  cursor: default;
}

#msi-chat-root .msi-icon-btn svg {
  width: 17px;
  height: 17px;
}

/* First-open notice (U14). Kept as a warm caution color deliberately —
   this is a universal "notice/caution" signal independent of the brand
   accent, not something that should follow the blue palette. */
#msi-chat-root .msi-notice {  background: #FFF8EC;
  border-bottom: 1px solid #F3E0C0;
  color: #6B4310;
  font-size: 12px;
  line-height: 1.45;
  padding: 9px 14px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex-shrink: 0;
}

#msi-chat-root .msi-notice__icon svg {  width: 14px;
  height: 14px;
  margin-top: 1px;
  color: #A9701C;
}

#msi-chat-root .msi-notice__text {  flex: 1;
}

#msi-chat-root .msi-notice__dismiss {
  color: #6B4310;
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ================================================================= */
/* Message list (U5)                                                 */
/* ================================================================= */

#msi-chat-root .msi-body {  flex: 1;
  overflow-y: auto;
  /* Belt-and-braces: bubbles already break long words, but a citation
     title or a pasted URL should never be able to widen the transcript. */
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 16px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--msi-border-strong) transparent;
}

#msi-chat-root .msi-body::-webkit-scrollbar {  width: 8px;
}

#msi-chat-root .msi-body::-webkit-scrollbar-thumb {  background: var(--msi-border-strong);
  border-radius: 99px;
  border: 2px solid var(--msi-bg);
}

#msi-chat-root .msi-body::-webkit-scrollbar-track {  background: transparent;
}

#msi-chat-root .msi-msg {  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: msi-msg-in 0.26s var(--msi-ease) both;
}

@keyframes msi-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

#msi-chat-root .msi-msg--user {  align-self: flex-end;
  align-items: flex-end;
}

#msi-chat-root .msi-msg--assistant {  align-self: flex-start;
  align-items: flex-start;
}

#msi-chat-root .msi-msg--greeting {  max-width: 94%;
}

/* ================================================================= */
/* Assistant avatar                                                  */
/* ================================================================= */

/*
 * Grid rather than a flex row + wrapper div: the avatar is pinned to
 * column 1 and everything else is pushed to column 2, so the bubble,
 * citations and starter chips keep stacking exactly as before. That
 * matters because appendAssistantMessage() appends the follow-up chip
 * with insertAdjacentHTML() straight onto .msi-msg — a wrapper element
 * would have silently moved that insertion point.
 */
#msi-chat-root .msi-msg--avatar {  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 8px;
  align-items: start;
}

#msi-chat-root .msi-msg--avatar > .msi-avatar {  grid-column: 1;
  grid-row: 1;
}

#msi-chat-root .msi-msg--avatar > *:not(.msi-avatar) {  grid-column: 2;
}

#msi-chat-root .msi-avatar {  width: 28px;
  height: 28px;
  border-radius: 50%;
  /* White ground for the same reason as the header plate: the brand mark
     is dark navy artwork and would vanish on a tinted circle. */
  background: #FFFFFF;
  border: 1px solid var(--msi-border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  /* optically centre the circle against the first line of the bubble
     rather than against the bubble's top padding */
  margin-top: 3px;
}

/*
 * The brand asset is a 205x91 wordmark WITH a tagline, and no square
 * monogram has been supplied. Fitting the whole thing into a 28px circle
 * renders the tagline as ~2px of unreadable microtext, which reads as a
 * smudge rather than a logo.
 *
 * So crop to the primary mark: `cover` + `object-position: top` on a box
 * whose ratio matches the "MSI" lettering alone (roughly the top 78% of
 * the source, 205x71), which drops the tagline and lets the letterforms
 * use the full width. Swap this back to a plain `contain` if a square
 * monogram is ever supplied — see the note in CLAUDE.md.
 */
#msi-chat-root .msi-avatar img {  width: 23px;
  height: 8px;
  object-fit: cover;
  object-position: top center;
}

@media (forced-colors: active) {
  #msi-chat-root .msi-avatar {    border: 1px solid canvastext;
  }
}

#msi-chat-root .msi-bubble {  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#msi-chat-root .msi-msg--user .msi-bubble {  background: var(--msi-navy);
  color: #fff;
  border-bottom-right-radius: 5px;
}

#msi-chat-root .msi-msg--assistant .msi-bubble {  background: var(--msi-surface);
  border: 1px solid var(--msi-border);
  color: var(--msi-text);
  border-bottom-left-radius: 5px;
  box-shadow: 0 1px 2px rgba(13, 30, 44, 0.04);
}

#msi-chat-root .msi-bubble a {  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

#msi-chat-root .msi-msg--assistant .msi-bubble a {  color: var(--msi-cta);
}

/* Citations (U6) */
#msi-chat-root .msi-citations {  margin-top: 7px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 100%;
}

#msi-chat-root .msi-citations__label {  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--msi-text-muted);
  margin-bottom: 1px;
}

#msi-chat-root .msi-citation {  font-size: 11.5px;
  color: var(--msi-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--msi-surface);
  border: 1px solid var(--msi-border);
  border-radius: 8px;
  max-width: 100%;
  transition: border-color 0.15s ease, color 0.15s ease;
}

#msi-chat-root .msi-citation:hover {  border-color: var(--msi-navy);
  color: var(--msi-navy);
}

#msi-chat-root .msi-citation svg {  width: 12px;
  height: 12px;
}

#msi-chat-root .msi-citation span {  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Typing indicator */
#msi-chat-root .msi-typing {  display: flex;
  align-items: center;
  gap: 4px;
  padding: 13px 15px;
  background: var(--msi-surface);
  border: 1px solid var(--msi-border);
  border-radius: 16px;
  border-bottom-left-radius: 5px;
  width: fit-content;
}

#msi-chat-root .msi-typing i {  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--msi-text-muted);
  animation: msi-bounce 1.3s infinite ease-in-out;
}

#msi-chat-root .msi-typing i:nth-child(3) { animation-delay: 0.16s; }#msi-chat-root .msi-typing i:nth-child(4) { animation-delay: 0.32s; }
@keyframes msi-bounce {
  0%, 62%, 100% { transform: translateY(0); opacity: 0.45; }
  31%           { transform: translateY(-4px); opacity: 1; }
}

/* Starter prompts + response chips (U4) */
#msi-chat-root .msi-starters {  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

#msi-chat-root .msi-starter {
  background: var(--msi-surface);
  border: 1px solid var(--msi-border);
  color: var(--msi-navy);
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.3;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

#msi-chat-root .msi-starter:hover {
  border-color: var(--msi-accent);
  background: #EAF3FC;
  transform: translateY(-1px);
}

#msi-chat-root .msi-starter:active {
  transform: translateY(0);
}

/*
 * While a request is in flight the send guard rejects clicks, so the chips
 * shouldn't keep looking actionable.
 */
#msi-chat-root .msi-is-sending .msi-starter {
  opacity: 0.5;
  pointer-events: none;
}

/* Fallback contact card (U7) — phone + quote CTA, never an email address */
#msi-chat-root .msi-contact-card {  align-self: flex-start;
  max-width: 88%;
  background: var(--msi-surface);
  border: 1px solid var(--msi-border);
  border-left: 3px solid var(--msi-accent);
  border-radius: 12px;
  padding: 13px 14px;
  box-shadow: 0 1px 2px rgba(13, 30, 44, 0.04);
  animation: msi-msg-in 0.26s var(--msi-ease) both;
}

#msi-chat-root .msi-contact-card__title {  font-weight: 600;
  font-size: 13px;
  color: var(--msi-navy);
  margin-bottom: 4px;
}

#msi-chat-root .msi-contact-card__text {  font-size: 12.5px;
  line-height: 1.5;
  color: var(--msi-text-muted);
}

#msi-chat-root .msi-contact-card__meta {  font-size: 12px;
  color: var(--msi-text-muted);
  margin-top: 6px;
}

#msi-chat-root .msi-contact-card__hours {  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  font-size: 12px;
  color: var(--msi-text-muted);
  line-height: 1.5;
}

#msi-chat-root .msi-citation--doc {  cursor: default;
}

#msi-chat-root .msi-contact-card__row {  display: flex;
  gap: 8px;
  margin-top: 11px;
  flex-wrap: wrap;
}

/* Buttons */
#msi-chat-root .msi-btn {
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  line-height: 1.3;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

#msi-chat-root .msi-btn svg {
  width: 14px;
  height: 14px;
}

#msi-chat-root .msi-btn--primary {
  background: var(--msi-cta);
  color: #fff;
}

#msi-chat-root .msi-btn--primary:hover:not([disabled]) {
  background: var(--msi-cta-dark);
}

#msi-chat-root .msi-btn--secondary {
  background: var(--msi-surface);
  border: 1px solid var(--msi-border-strong);
  color: var(--msi-navy);
}

#msi-chat-root .msi-btn--secondary:hover:not([disabled]) {
  border-color: var(--msi-navy);
  background: var(--msi-surface-alt);
}

#msi-chat-root .msi-btn--full {
  width: 100%;
  padding: 12px 16px;
  font-size: 13.5px;
}

#msi-chat-root .msi-btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Error banners (U12) */
#msi-chat-root .msi-error-banner {  align-self: stretch;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--msi-error-bg);
  border: 1px solid var(--msi-error-border);
  color: var(--msi-error);
  font-size: 12.5px;
  line-height: 1.45;
  padding: 10px 12px;
  border-radius: 10px;
  animation: msi-msg-in 0.26s var(--msi-ease) both;
}

#msi-chat-root .msi-error-banner__icon svg {  width: 15px;
  height: 15px;
  margin-top: 1px;
}

#msi-chat-root .msi-error-banner__text {  flex: 1;
  min-width: 140px;
}

#msi-chat-root .msi-error-banner__retry {
  border: 1px solid currentColor;
  color: var(--msi-error);
  border-radius: 7px;
  padding: 5px 11px;
  font-size: 11.5px;
  font-weight: 600;
  transition: background 0.15s ease;
}

#msi-chat-root .msi-error-banner__retry:hover {
  background: rgba(163, 35, 22, 0.08);
}

/* ================================================================= */
/* Composer                                                          */
/* ================================================================= */

#msi-chat-root .msi-composer-wrap {  flex-shrink: 0;
  background: var(--msi-surface);
  border-top: 1px solid var(--msi-border);
  padding: 10px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  /* anchor for the emoji popover */
  position: relative;
}

/* ================================================================= */
/* Emoji picker — DISABLED                                           */
/*                                                                   */
/* The feature is switched off via `ENABLE_EMOJI` in msi-chatbot.js, */
/* so none of the markup these rules target is rendered and every    */
/* selector below currently matches nothing. Kept in place so        */
/* re-enabling stays a one-line change in the JS; delete this block  */
/* only if the feature is dropped for good.                          */
/* ================================================================= */

#msi-chat-root .msi-emoji-btn {  width: 34px;
  height: 34px;
  margin-bottom: 3px;
  border-radius: 9px;
  color: var(--msi-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

#msi-chat-root .msi-emoji-btn svg {  width: 21px;
  height: 21px;
}

#msi-chat-root .msi-emoji-btn:hover {  background: var(--msi-bg);
  color: var(--msi-navy);
}

#msi-chat-root .msi-emoji-btn[aria-expanded="true"] {  background: var(--msi-bg);
  color: var(--msi-navy);
}

/* Sits above the composer, anchored to its right edge like the toggle. */
#msi-chat-root .msi-emoji-pop {  position: absolute;
  bottom: calc(100% - 4px);
  right: 12px;
  left: 12px;
  background: var(--msi-surface);
  border: 1px solid var(--msi-border);
  border-radius: var(--msi-radius-sm);
  box-shadow: var(--msi-shadow-lg);
  padding: 8px;
  z-index: 3;
  animation: msi-emoji-in 0.15s var(--msi-ease) both;
}

@keyframes msi-emoji-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

#msi-chat-root .msi-emoji-grid {  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}

#msi-chat-root .msi-emoji {  aspect-ratio: 1;
  min-height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Explicit emoji stack: --msi-font is a text stack, and on some
     Windows/Linux builds the first matching family renders these as
     monochrome glyphs without it. */
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
  font-size: 19px;
  line-height: 1;
  transition: background 0.12s ease, transform 0.12s ease;
}

#msi-chat-root .msi-emoji:hover {  background: var(--msi-bg);
  transform: scale(1.12);
}

#msi-chat-root .msi-emoji:active {  transform: scale(0.96);
}

@media (max-width: 380px) {
  #msi-chat-root .msi-emoji-grid {    grid-template-columns: repeat(6, 1fr);
  }
}

@media (forced-colors: active) {
  #msi-chat-root .msi-emoji-pop {    border: 1px solid canvastext;
  }
  #msi-chat-root .msi-emoji:focus-visible {    outline: 2px solid canvastext;
  }
}

#msi-chat-root .msi-composer {  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#msi-chat-root .msi-composer textarea {  flex: 1;
  resize: none;
  border: 1px solid var(--msi-border-strong);
  border-radius: 11px;
  padding: 10px 13px;
  font-size: 13.5px;
  line-height: 1.45;
  max-height: 110px;
  color: var(--msi-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#msi-chat-root .msi-composer textarea::placeholder {  color: #8A97A2;
  opacity: 1;
}

#msi-chat-root .msi-composer textarea:focus {  border-color: var(--msi-navy);
  box-shadow: 0 0 0 3px rgba(28, 58, 82, 0.10);
}

#msi-chat-root .msi-send-btn {
  background: var(--msi-navy);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}

#msi-chat-root .msi-send-btn:hover:not([disabled]) {
  background: var(--msi-navy-dark);
  transform: translateY(-1px);
}

#msi-chat-root .msi-send-btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}

#msi-chat-root .msi-send-btn svg {
  width: 17px;
  height: 17px;
}

#msi-chat-root .msi-composer-foot {  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 4px 0;
  min-height: 15px;
}

#msi-chat-root .msi-composer-hint,#msi-chat-root .msi-char-count {  font-size: 10.5px;
  color: var(--msi-text-muted);
  line-height: 1.3;
}

#msi-chat-root .msi-char-count {  margin-left: auto;
  white-space: nowrap;
}

#msi-chat-root .msi-char-count.is-low {  color: var(--msi-error);
  font-weight: 600;
}

@media (max-width: 380px) {
  #msi-chat-root .msi-composer-hint { display: none; }}

/* ================================================================= */
/* Structured form panels (U8 / U9 / U10)                            */
/* ================================================================= */

#msi-chat-root .msi-form-panel {  position: absolute;
  inset: 0;
  background: var(--msi-bg);
  display: flex;
  flex-direction: column;
  z-index: 2;
  animation: msi-panel-in 0.24s var(--msi-ease) both;
}

@keyframes msi-panel-in {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

#msi-chat-root .msi-form-header {  background: var(--msi-navy);
  color: #fff;
  padding: 13px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#msi-chat-root .msi-form-header__title {  font-size: 14.5px;
  font-weight: 600;
  flex: 1;
  text-align: center;
}

#msi-chat-root .msi-form-body {  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--msi-border-strong) transparent;
}

#msi-chat-root .msi-form-intro {  font-size: 12.5px;
  color: var(--msi-text-muted);
  line-height: 1.55;
  margin-bottom: 14px;
}

#msi-chat-root .msi-form-alert {  background: var(--msi-error-bg);
  border: 1px solid var(--msi-error-border);
  color: var(--msi-error);
  font-size: 12.5px;
  line-height: 1.45;
  padding: 9px 12px;
  border-radius: 9px;
  margin-bottom: 14px;
}

#msi-chat-root .msi-field {  margin-bottom: 13px;
}

#msi-chat-root .msi-field label {  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--msi-text);
  margin-bottom: 5px;
}

#msi-chat-root .msi-required {  color: var(--msi-error);
}

#msi-chat-root .msi-field input,#msi-chat-root .msi-field textarea {  width: 100%;
  border: 1px solid var(--msi-border-strong);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--msi-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#msi-chat-root .msi-field input:focus,#msi-chat-root .msi-field textarea:focus {  border-color: var(--msi-navy);
  box-shadow: 0 0 0 3px rgba(28, 58, 82, 0.10);
}

#msi-chat-root .msi-field textarea {  resize: vertical;
  min-height: 84px;
}

#msi-chat-root .msi-field-error {  color: var(--msi-error);
  font-size: 11.5px;
  line-height: 1.4;
  margin-top: 5px;
  display: none;
}

#msi-chat-root .msi-field.msi-invalid input,#msi-chat-root .msi-field.msi-invalid textarea {  border-color: var(--msi-error);
  background: #FFFCFC;
}

#msi-chat-root .msi-field.msi-invalid input:focus,#msi-chat-root .msi-field.msi-invalid textarea:focus {  box-shadow: 0 0 0 3px rgba(163, 35, 22, 0.12);
}

#msi-chat-root .msi-field.msi-invalid .msi-field-error {  display: block;
}

#msi-chat-root .msi-form-doclink {  font-size: 12.5px;
  margin-top: 2px;
}

#msi-chat-root .msi-form-doclink a {  color: var(--msi-cta);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Honeypot — off-screen but still in the DOM for bots (U8) */
#msi-chat-root .msi-hp {  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

#msi-chat-root .msi-form-footer {  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--msi-border);
  background: var(--msi-surface);
  flex-shrink: 0;
}

/* Success state */
#msi-chat-root .msi-success {  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 26px 16px;
  gap: 11px;
}

#msi-chat-root .msi-success__icon {  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--msi-success-bg);
  color: var(--msi-success);
  display: flex;
  align-items: center;
  justify-content: center;
}

#msi-chat-root .msi-success__icon svg {  width: 25px;
  height: 25px;
}

#msi-chat-root .msi-success__title {  font-size: 16px;
  font-weight: 600;
}

#msi-chat-root .msi-success__ref {  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--msi-surface);
  border: 1px dashed var(--msi-border-strong);
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--msi-navy);
  user-select: all;
}

#msi-chat-root .msi-success__desc {  font-size: 12.5px;
  line-height: 1.55;
  color: var(--msi-text-muted);
  max-width: 270px;
}

/* ================================================================= */
/* Utilities                                                         */
/* ================================================================= */

#msi-chat-root .msi-visually-hidden {  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Forced-colors / Windows High Contrast */
@media (forced-colors: active) {
  #msi-chat-root .msi-window,  #msi-chat-root .msi-launcher,
  #msi-chat-root .msi-bubble,  #msi-chat-root .msi-starter,
  #msi-chat-root .msi-btn,
  #msi-chat-root .msi-contact-card,  #msi-chat-root .msi-field input,  #msi-chat-root .msi-field textarea {    border: 1px solid CanvasText;
  }
  #msi-chat-root :focus-visible {
    outline: 2px solid Highlight;
  }
}
