/* Sage Guided Chat v1.2.0 — dark theme matching the approved mockup.
   Serif: Roboto Slab (message text, greeting popup). Sans: Libre Franklin (UI chrome).
   Every rule scoped under #aip-sage-chat so theme styles cannot override it. */
#aip-sage-chat { font-family: "Libre Franklin", -apple-system, "Segoe UI", sans-serif; }
#aip-sage-chat div, #aip-sage-chat button, #aip-sage-chat a { box-sizing: border-box; }

/* ---------- launcher ---------- */
#aip-sage-chat .aip-sage-launcher {
  position: fixed; right: 24px; bottom: 24px; z-index: 99990;
  width: 62px; height: 62px; border-radius: 50%; border: none; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  margin: 0; padding: 0;
  background: linear-gradient(145deg, #bd9070 0%, #a97f69 45%, #966e58 100%);
  color: #2b211c;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255,255,255,0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  font: inherit; line-height: 1;
}
#aip-sage-chat .aip-sage-launcher:hover { transform: scale(1.06); background: linear-gradient(145deg, #bd9070 0%, #a97f69 45%, #966e58 100%); border: none; box-shadow: 0 10px 32px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.25); }
#aip-sage-chat .aip-sage-launcher:focus-visible { outline: 3px solid #d9b48f; outline-offset: 2px; }
#aip-sage-chat .aip-sage-launcher svg { width: 30px; height: 30px; display: block; }

/* ---------- greeting teaser popup ---------- */
#aip-sage-chat .aip-sage-teaser {
  position: fixed; right: 24px; bottom: 100px; z-index: 99989;
  width: 340px; max-width: calc(100vw - 32px);
  background: #232326; border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px; padding: 16px 42px 16px 18px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.5);
  display: none; margin: 0; text-align: left;
}
#aip-sage-chat .aip-sage-teaser.aip-sage-show { display: block; }
#aip-sage-chat .aip-sage-teaser p {
  font-family: "Roboto Slab", Georgia, serif; font-size: 16.5px; line-height: 1.55;
  color: #fafaf7; margin: 0; padding: 0;
}
#aip-sage-chat .aip-sage-teaser p strong { font-weight: 700; }
#aip-sage-chat .aip-sage-teaser-close {
  position: absolute; top: 8px; right: 8px;
  -webkit-appearance: none; appearance: none;
  background: transparent; border: none; color: #a7a7ad;
  font-size: 18px; line-height: 1; cursor: pointer; padding: 6px 8px; border-radius: 6px;
  margin: 0; font-family: inherit;
}
#aip-sage-chat .aip-sage-teaser-close:hover { color: #fafaf7; background: rgba(255,255,255,0.08); border: none; }

/* ---------- panel ---------- */
#aip-sage-chat .aip-sage-panel {
  position: fixed; right: 24px; bottom: 102px; z-index: 99991;
  width: 400px; max-width: calc(100vw - 32px); height: 620px; max-height: calc(100vh - 140px);
  background: #232326; border-radius: 18px; overflow: hidden;
  display: none; flex-direction: column;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.09);
  margin: 0; padding: 0; text-align: left;
}
#aip-sage-chat .aip-sage-panel.aip-sage-open { display: flex; }

/* ---------- header ---------- */
#aip-sage-chat .aip-sage-header {
  background: #1e1e21; color: #fafaf7; padding: 14px 16px;
  display: flex; align-items: center; gap: 10px; flex: 0 0 auto;
  border: none; border-bottom: 1px solid rgba(255,255,255,0.07); margin: 0;
}
#aip-sage-chat .aip-sage-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto;
  background: linear-gradient(145deg, #bd9070 0%, #966e58 100%);
  display: flex; align-items: center; justify-content: center;
  margin: 0; padding: 0;
}
#aip-sage-chat .aip-sage-avatar svg { width: 22px; height: 22px; display: block; }
#aip-sage-chat .aip-sage-title {
  font-family: "Roboto Slab", Georgia, serif;
  font-size: 19px; font-weight: 600; line-height: 1.2; color: #fafaf7; margin: 0; padding: 0;
}
#aip-sage-chat .aip-sage-status { font-size: 11px; color: #a7a7ad; display: flex; align-items: center; gap: 5px; margin: 0; padding: 0; }
#aip-sage-chat .aip-sage-status::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: #35d07f; display: inline-block;
  margin: 0; padding: 0;
}
#aip-sage-chat .aip-sage-header-spacer { flex: 1 1 auto; }
#aip-sage-chat .aip-sage-newconv {
  -webkit-appearance: none; appearance: none;
  background: transparent; border: 1px solid rgba(255,255,255,0.28); color: #e8e4dc;
  font-size: 12px; font-weight: 500; padding: 7px 12px; border-radius: 999px; cursor: pointer;
  margin: 0; font-family: "Libre Franklin", sans-serif; text-transform: none; letter-spacing: normal; line-height: 1.4;
}
#aip-sage-chat .aip-sage-newconv:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.28); color: #fafaf7; }
#aip-sage-chat .aip-sage-close {
  -webkit-appearance: none; appearance: none;
  background: transparent; border: none; color: #c9c5bd; font-size: 22px; line-height: 1;
  cursor: pointer; padding: 4px 8px; border-radius: 6px; margin: 0; font-family: inherit;
}
#aip-sage-chat .aip-sage-close:hover { background: rgba(255,255,255,0.08); color: #fafaf7; border: none; }

/* ---------- disclosure ---------- */
#aip-sage-chat .aip-sage-disclosure {
  flex: 0 0 auto; background: #1e1e21; color: #8e8e94;
  font-size: 11px; line-height: 1.4; padding: 8px 16px; text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.06); margin: 0;
}

/* ---------- messages ---------- */
#aip-sage-chat .aip-sage-messages {
  flex: 1 1 auto; overflow-y: auto; padding: 18px 18px;
  display: flex; flex-direction: column; gap: 12px; background: #232326; margin: 0;
  scrollbar-width: thin; scrollbar-color: #4a4a50 transparent;
}
#aip-sage-chat .aip-sage-messages::-webkit-scrollbar { width: 6px; }
#aip-sage-chat .aip-sage-messages::-webkit-scrollbar-thumb { background: #4a4a50; border-radius: 3px; }
#aip-sage-chat .aip-sage-row { display: flex; margin: 0; padding: 0; }
#aip-sage-chat .aip-sage-row-user { justify-content: flex-end; }
#aip-sage-chat .aip-sage-bubble-bot {
  font-family: "Libre Franklin", -apple-system, "Segoe UI", sans-serif;
  font-size: 16px; line-height: 1.6; color: #fafaf7; margin: 0; padding: 0;
  max-width: 100%;
}
#aip-sage-chat .aip-sage-bubble-user {
  font-family: "Libre Franklin", sans-serif;
  font-size: 14px; line-height: 1.5; color: #241c15;
  background: linear-gradient(145deg, #bd9070, #a97f69);
  border-radius: 16px; border-bottom-right-radius: 4px;
  padding: 10px 16px; margin: 0; max-width: 85%;
}
#aip-sage-chat .aip-sage-typing { display: flex; gap: 6px; align-items: center; padding: 6px 0; }
#aip-sage-chat .aip-sage-typing span {
  width: 8px; height: 8px; border-radius: 50%; background: #a97f69; display: inline-block;
  animation: aip-sage-blink 1.2s infinite; margin: 0; padding: 0;
}
#aip-sage-chat .aip-sage-typing span:nth-child(2) { animation-delay: 0.2s; }
#aip-sage-chat .aip-sage-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aip-sage-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* ---------- quick replies ---------- */
#aip-sage-chat .aip-sage-replies {
  flex: 0 0 auto; padding: 14px 16px 18px; background: #232326;
  border-top: 1px solid rgba(255,255,255,0.07); display: flex; flex-wrap: wrap; gap: 9px; margin: 0;
}
#aip-sage-chat .aip-sage-reply {
  -webkit-appearance: none; appearance: none;
  border: 1px solid #a97f69; background: transparent; color: #ecdfd2;
  font-family: "Libre Franklin", sans-serif;
  font-size: 13.5px; font-weight: 600; padding: 10px 18px; border-radius: 999px;
  cursor: pointer; text-decoration: none;
  margin: 0; text-transform: none; letter-spacing: normal; line-height: 1.4;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  display: inline-block;
}
#aip-sage-chat .aip-sage-reply:hover { background: rgba(169,127,105,0.16); border-color: #bd9070; color: #faf3ea; }
#aip-sage-chat .aip-sage-reply-primary {
  background: linear-gradient(145deg, #bd9070, #a97f69); border-color: #a97f69; color: #241c15;
}
#aip-sage-chat .aip-sage-reply-primary:hover { background: linear-gradient(145deg, #c89a78, #b0866d); border-color: #bd9070; color: #1e1712; }
#aip-sage-chat .aip-sage-reply:focus-visible { outline: 3px solid #d9b48f; outline-offset: 2px; }

@media (max-width: 480px) {
  #aip-sage-chat .aip-sage-panel { right: 12px; left: 12px; bottom: 94px; width: auto; }
  #aip-sage-chat .aip-sage-launcher { right: 16px; bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  #aip-sage-chat .aip-sage-launcher, #aip-sage-chat .aip-sage-reply { transition: none; }
  #aip-sage-chat .aip-sage-typing span { animation: none; opacity: 0.6; }
}
