#assistantHost {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ai-theme: var(--assistant-theme, var(--theme, #1558b0));
  --ai-soft: color-mix(in srgb, var(--ai-theme) 10%, #ffffff);
}

.sync-status {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 70;
  max-width: min(360px, calc(100vw - 120px));
  padding: 9px 12px;
  border-radius: 999px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, .16);
  font-size: 12px;
  font-weight: 900;
  color: #0f172a;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, .12);
}

.sync-status.offline {
  color: #7f1d1d;
  background: #fff1f2;
  border-color: #fecdd3;
}

.sync-status.queued.online {
  color: #854d0e;
  background: #fffbeb;
  border-color: #fde68a;
}

.ai-fab {
  width: 68px;
  height: 68px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(145deg, color-mix(in srgb, var(--ai-theme) 82%, #000), var(--ai-theme));
  box-shadow: 0 18px 40px color-mix(in srgb, var(--ai-theme) 30%, transparent);
  display: grid;
  place-items: center;
  gap: 0;
  font-weight: 900;
}

.ai-fab span {
  display: block;
  line-height: 1;
}

.ai-fab .ai-shield {
  font-size: 11px;
  letter-spacing: .06em;
}

.ai-panel {
  position: absolute;
  right: 0;
  bottom: 82px;
  width: min(420px, calc(100vw - 28px));
  height: min(680px, calc(100vh - 116px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--ai-theme) 16%, #ffffff);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 26px 80px rgba(7, 25, 22, .24);
}

.ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  color: #fff;
  background: linear-gradient(135deg, color-mix(in srgb, var(--ai-theme) 82%, #000), var(--ai-theme));
}

.ai-head b {
  font-size: 15px;
}

.ai-sub {
  margin-top: 2px;
  color: rgba(255, 255, 255, .78);
  font-size: 12px;
  font-weight: 600;
}

.ai-head .x {
  color: #fff;
  background: rgba(255, 255, 255, .14);
  border-color: rgba(255, 255, 255, .18);
}

.ai-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-mini {
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  padding: 7px 9px;
  color: #fff;
  background: rgba(255, 255, 255, .14);
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
}

.ai-mini:hover,
.ai-head .x:hover {
  background: rgba(255, 255, 255, .22);
}

.ai-body {
  display: block;
  height: 100%;
  overflow-y: scroll;
  overscroll-behavior: contain;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--ai-theme) 45%, #b6c4d6) transparent;
  padding: 14px;
  background: color-mix(in srgb, var(--ai-theme) 5%, #f8fafc);
}

.ai-body::-webkit-scrollbar {
  width: 10px;
}

.ai-body::-webkit-scrollbar-track {
  background: transparent;
}

.ai-body::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ai-theme) 48%, #b6c4d6);
  background-clip: content-box;
}

.ai-body::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--ai-theme) 62%, #8da0ba);
  background-clip: content-box;
}

.ai-msg {
  max-width: 92%;
  margin: 0 0 10px;
  padding: 11px 12px;
  border-radius: 12px;
  color: #111827;
  background: #fff;
  border: 1px solid color-mix(in srgb, var(--ai-theme) 9%, #ffffff);
  font-size: 13px;
  line-height: 1.48;
  white-space: normal;
}

.ai-turn {
  flex: 0 0 auto;
  margin: 0 0 10px;
  border: 1px solid color-mix(in srgb, var(--ai-theme) 12%, #ffffff);
  border-radius: 13px;
  background: rgba(255, 255, 255, .78);
  overflow: hidden;
}

.ai-turn:not([open]) {
  margin-bottom: 6px;
  background: rgba(255, 255, 255, .58);
}

.ai-turn.current {
  border-color: color-mix(in srgb, var(--ai-theme) 26%, #ffffff);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--ai-theme) 10%, transparent);
}

.ai-turn summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  cursor: pointer;
  list-style: none;
}

.ai-turn:not([open]) summary {
  padding-block: 7px;
}

.ai-turn summary::-webkit-details-marker {
  display: none;
}

.ai-turn summary span {
  padding: 3px 7px;
  border-radius: 999px;
  color: color-mix(in srgb, var(--ai-theme) 86%, #111827);
  background: color-mix(in srgb, var(--ai-theme) 10%, #ffffff);
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
}

.ai-turn summary b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #253348;
  font-size: 12px;
}

.ai-turn-body {
  padding: 0 9px 10px;
}

.ai-turn-body .ai-msg {
  max-width: 100%;
  margin-bottom: 0;
}

.ai-turn:not([open]) summary::after {
  content: "+";
  color: var(--ai-theme);
  font-weight: 950;
}

.ai-turn[open] summary::after {
  content: "-";
  color: var(--ai-theme);
  font-weight: 950;
}

.ai-text p {
  margin: 0 0 10px;
}

.ai-text p:last-child {
  margin-bottom: 0;
}

.ai-gap {
  height: 8px;
}

.ai-steps {
  margin: 6px 0 12px;
  padding-left: 22px;
}

.ai-bullets {
  margin: 6px 0 12px;
  padding-left: 0;
  list-style: none;
}

.ai-steps li,
.ai-bullets li {
  margin: 0 0 8px;
  padding-left: 2px;
}

.ai-bullets li {
  position: relative;
  padding-left: 16px;
}

.ai-bullets li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .68em;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--ai-theme);
}

.ai-field {
  margin: 0 0 10px;
}

.ai-field b {
  color: color-mix(in srgb, var(--ai-theme) 86%, #111827);
  margin-right: 4px;
}

.ai-section {
  margin: 10px 0 8px;
}

.ai-section b {
  display: block;
  margin-bottom: 3px;
  color: color-mix(in srgb, var(--ai-theme) 88%, #111827);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .01em;
}

.ai-section span {
  display: block;
}

.ai-cursor {
  display: inline-block;
  width: 7px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -2px;
  border-radius: 999px;
  background: var(--ai-theme);
  animation: aiBlink 1s steps(2, start) infinite;
}

@keyframes aiBlink {
  50% { opacity: .25; }
}

.ai-msg.user {
  margin-left: auto;
  color: #fff;
  background: var(--ai-theme);
}

.ai-msg.pending {
  color: color-mix(in srgb, var(--ai-theme) 82%, #111827);
  background: color-mix(in srgb, var(--ai-theme) 10%, #ffffff);
  border-style: dashed;
}

.ai-sources {
  margin-top: 10px;
}

.ai-sources summary {
  cursor: pointer;
  color: color-mix(in srgb, var(--ai-theme) 82%, #111827);
  font-size: 11px;
  font-weight: 900;
}

.ai-sources div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.ai-sources span {
  padding: 4px 7px;
  border-radius: 999px;
  color: color-mix(in srgb, var(--ai-theme) 82%, #111827);
  background: color-mix(in srgb, var(--ai-theme) 10%, #ffffff);
  font-size: 11px;
  font-weight: 800;
}

.history-list,
.history-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border, #d9e2ef);
  border-radius: 12px;
  padding: 11px;
  background: #fff;
}

.history-item b {
  display: block;
  font-size: 13px;
}

.history-actions {
  display: flex;
  gap: 6px;
}

.history-preview {
  max-height: 58vh;
  overflow: auto;
  margin-bottom: 12px;
  padding-right: 4px;
}

.ai-confidence {
  display: inline-flex;
  margin-top: 9px;
  padding: 4px 7px;
  border-radius: 999px;
  color: color-mix(in srgb, var(--ai-theme) 82%, #111827);
  background: color-mix(in srgb, var(--ai-theme) 9%, #ffffff);
  font-size: 11px;
  font-weight: 900;
  text-transform: capitalize;
}

.ai-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 2px 0 4px;
}

.ai-quick button {
  border: 1px solid color-mix(in srgb, var(--ai-theme) 18%, #ffffff);
  border-radius: 999px;
  padding: 7px 9px;
  color: color-mix(in srgb, var(--ai-theme) 86%, #111827);
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.ai-quick button:hover {
  background: color-mix(in srgb, var(--ai-theme) 9%, #ffffff);
}

.ai-foot {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
  background: #fff;
  border-top: 1px solid color-mix(in srgb, var(--ai-theme) 12%, #ffffff);
}

.ai-foot textarea {
  min-height: 46px;
  max-height: 110px;
  resize: vertical;
}

@media (max-width: 640px) {
  #assistantHost {
    right: 12px;
    bottom: 12px;
  }

  .ai-panel {
    right: -4px;
    bottom: 78px;
    width: calc(100vw - 16px);
    height: calc(100vh - 104px);
    border-radius: 12px;
  }
}

/* Conversation-mode assistant fixes: chronological chat bubbles + auto-scroll friendly layout. */
.ai-panel {
  display: flex;
  flex-direction: column;
  height: min(720px, calc(100vh - 96px));
  max-height: calc(100vh - 96px);
}

.ai-body.gss-ai-messages {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 14px;
}

.ai-foot {
  flex: 0 0 auto;
}

.ai-message-row {
  display: flex;
  width: 100%;
}

.ai-message-row.user {
  justify-content: flex-end;
}

.ai-message-row.bot {
  justify-content: flex-start;
}

.ai-message-row .ai-msg {
  max-width: min(88%, 340px);
  margin: 0;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .08);
}

.ai-message-row .ai-msg.bot {
  border-top-left-radius: 6px;
}

.ai-message-row .ai-msg.user {
  border-top-right-radius: 6px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--ai-theme) 88%, #000), var(--ai-theme));
}

.ai-msg-label {
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 950;
  letter-spacing: .05em;
  text-transform: uppercase;
  opacity: .72;
}

.ai-msg.user .ai-msg-label {
  color: rgba(255,255,255,.82);
}

.ai-msg.bot .ai-msg-label {
  color: color-mix(in srgb, var(--ai-theme) 72%, #334155);
}

.ai-msg.user .ai-text,
.ai-msg.user .ai-text p,
.ai-msg.user .ai-section b,
.ai-msg.user .ai-section span {
  color: #fff;
}

.ai-msg.user .ai-bullets li::before {
  background: #fff;
}

.ai-cited {
  margin-top: 8px;
  font-size: 10px;
  font-weight: 800;
  color: color-mix(in srgb, var(--ai-theme) 70%, #475569);
}

.ai-msg.user .ai-cited {
  color: rgba(255,255,255,.8);
}

@media (max-width: 640px) {
  .ai-panel {
    height: calc(100vh - 96px);
    max-height: calc(100vh - 96px);
  }

  .ai-message-row .ai-msg {
    max-width: 92%;
  }

  .ai-body.gss-ai-messages {
    padding: 12px;
  }
}

.ai-suggestions {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--ai-theme) 12%, #ffffff);
}

.ai-suggestions b {
  font-size: 11px;
  color: color-mix(in srgb, var(--ai-theme) 78%, #334155);
}

.ai-suggestions button {
  text-align: left;
  border: 1px solid color-mix(in srgb, var(--ai-theme) 16%, #ffffff);
  border-radius: 10px;
  background: #fff;
  color: color-mix(in srgb, var(--ai-theme) 86%, #111827);
  padding: 7px 9px;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.ai-suggestions button:hover {
  background: color-mix(in srgb, var(--ai-theme) 8%, #ffffff);
}

/* Final assistant UX stability + modern launcher refinements. */
.ai-fab {
  position: relative;
  width: 78px;
  height: 78px;
  border-radius: 26px;
  overflow: hidden;
  isolation: isolate;
  grid-template-rows: 1fr auto;
  gap: 3px;
  background:
    radial-gradient(circle at 28% 24%, rgba(255,255,255,.34), transparent 34%),
    linear-gradient(145deg, color-mix(in srgb, var(--ai-theme) 92%, #020617), color-mix(in srgb, var(--ai-theme) 70%, #111827));
  box-shadow:
    0 22px 55px color-mix(in srgb, var(--ai-theme) 32%, transparent),
    inset 0 1px 0 rgba(255,255,255,.22),
    inset 0 -18px 40px rgba(2,6,23,.18);
}

.ai-fab::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 20px;
  z-index: -1;
}

.ai-fab::after {
  content: "";
  position: absolute;
  width: 44px;
  height: 44px;
  right: -16px;
  top: -14px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  filter: blur(.2px);
  z-index: -1;
}

.ai-fab-orbit {
  position: absolute;
  inset: 9px;
  border-radius: 22px;
  border: 1px dashed rgba(255,255,255,.22);
  opacity: .82;
  pointer-events: none;
}

.ai-fab-core {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-top: 8px;
  border-radius: 16px;
  background: rgba(255,255,255,.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22);
  position: relative;
}

.ai-fab-shield {
  font-size: 20px;
  line-height: 1;
  transform: rotate(45deg);
  color: rgba(255,255,255,.94);
}

.ai-fab-spark {
  position: absolute;
  right: 5px;
  top: 3px;
  color: #dbeafe;
  font-size: 13px;
  text-shadow: 0 0 16px rgba(219,234,254,.9);
}

.ai-fab-text {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-width: 50px;
  margin-bottom: 8px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  color: #fff;
  font-size: 10px;
  font-weight: 950;
  letter-spacing: .07em;
  line-height: 1;
}

.ai-fab:hover {
  transform: translateY(-2px);
  box-shadow:
    0 26px 64px color-mix(in srgb, var(--ai-theme) 38%, transparent),
    inset 0 1px 0 rgba(255,255,255,.24),
    inset 0 -18px 40px rgba(2,6,23,.18);
}

.ai-panel {
  width: min(460px, calc(100vw - 28px));
}

.ai-body.gss-ai-messages {
  scroll-behavior: auto;
  overflow-anchor: auto;
  contain: content;
}

.ai-message-row .ai-msg {
  max-width: min(92%, 390px);
}

.ai-msg.typing,
.ai-msg.pending {
  will-change: contents;
}

.ai-msg.typing .ai-text {
  min-height: 1.45em;
}

.ai-msg.pending .ai-text p {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0;
  font-weight: 850;
}

.ai-msg.pending .ai-text p::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 10px 0 0 currentColor, 20px 0 0 currentColor;
  opacity: .65;
}

@media (prefers-reduced-motion: reduce) {
  .ai-fab,
  .ai-cursor {
    animation: none !important;
    transition: none !important;
  }
}

/* Keep the floating assistant from covering page action buttons. */
#assistantHost {
  right: 1px;
  bottom: 1px;
}

.ai-fab {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  grid-template-rows: 1fr;
  box-shadow:
    0 12px 28px color-mix(in srgb, var(--ai-theme) 24%, transparent),
    inset 0 1px 0 rgba(255,255,255,.22),
    inset 0 -12px 28px rgba(2,6,23,.16);
}

.ai-fab::before {
  inset: 6px;
  border-radius: 14px;
}

.ai-fab::after,
.ai-fab-orbit,
.ai-fab-text {
  display: none !important;
}

.ai-fab-core {
  width: 30px;
  height: 30px;
  margin-top: 0;
  border-radius: 12px;
}

.ai-fab-shield {
  font-size: 15px;
}

.ai-fab-spark {
  right: 3px;
  top: 1px;
  font-size: 10px;
}

.ai-panel {
  right: 0;
  bottom: 62px;
}

@media (max-width: 640px) {
  #assistantHost {
    right: 1px;
    bottom: 1px;
  }

  .ai-panel {
    right: 0;
    bottom: 60px;
  }
}
