/* Skye — Studio's AI chat bubble.
   Self-contained: scoped under #skye so it never collides with page styles.
   Brand: Instrument Sans, Studio blue (#1264ff). */
@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400..700&display=swap');

#skye {
  --skye-accent: #1264ff;
  --skye-ink: #0c1320;
  --skye-muted: #5a6577;
  --skye-line: #e7eaf0;
  --skye-bg: #ffffff;
  --skye-user: #1264ff;
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 2147483000;
  font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 500; /* base weight for body copy; only headers/bold go heavier */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Launcher ─────────────────────────────────────────────────────── */
.skye-launch {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: var(--skye-accent);
  box-shadow: 0 10px 30px rgba(18, 100, 255, .35), 0 2px 6px rgba(12, 19, 32, .12);
  transition: transform .18s ease, box-shadow .18s ease;
}
.skye-launch:hover { transform: translateY(-2px) scale(1.03); }
.skye-launch:active { transform: translateY(0) scale(.98); }
.skye-launch-av {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  transition: opacity .18s ease, transform .18s ease;
}
.skye-launch-x {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 24px;
  height: 24px;
  color: #fff;
  opacity: 0;
  transform: rotate(-90deg);
  transition: opacity .18s ease, transform .18s ease;
}
/* "Online" presence dot — white outline so it reads cleanly on the avatar. */
.skye-launch-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #25c26e;
  border: 2.5px solid #fff;
  box-shadow: 0 1px 3px rgba(12, 19, 32, .25);
}
#skye.is-open .skye-launch-dot { opacity: 0; }
#skye.has-unread .skye-launch-dot { display: none; }

/* Unread badge: shown when Skye replies while the panel is closed. */
.skye-launch-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #f5334f;
  border: 2.5px solid #fff;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  display: none;
  box-shadow: 0 2px 6px rgba(245, 51, 79, .5);
  animation: skye-badge-pop .25s cubic-bezier(.2, .9, .3, 1.4);
}
@keyframes skye-badge-pop { from { transform: scale(0); } to { transform: scale(1); } }
#skye.has-unread .skye-launch-badge { display: block; }
/* Nudge attention while unread (respects reduced-motion below). */
#skye.has-unread:not(.is-open) .skye-launch { animation: skye-attn 1.8s ease-in-out 2; }
@keyframes skye-attn { 0%, 100% { transform: none; } 25% { transform: rotate(-7deg); } 75% { transform: rotate(7deg); } }

/* Open state: avatar fades to a close (X) icon. */
#skye.is-open .skye-launch-av { opacity: 0; transform: scale(.6); }
#skye.is-open .skye-launch-x { opacity: 1; transform: rotate(0); }
#skye.is-open .skye-launch { background: var(--skye-ink); box-shadow: 0 8px 24px rgba(12, 19, 32, .3); }

/* ── Panel ────────────────────────────────────────────────────────── */
.skye-panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: 374px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  background: var(--skye-bg);
  border: 1px solid var(--skye-line);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(12, 19, 32, .22), 0 4px 14px rgba(12, 19, 32, .1);
  overflow: hidden;
  transform-origin: bottom right;
  animation: skye-pop .2s cubic-bezier(.2, .9, .3, 1.2);
}
/* The class sets display:flex, which would otherwise beat the [hidden]
   attribute — this keeps the panel actually hidden until opened. */
.skye-panel[hidden] { display: none; }
@keyframes skye-pop {
  from { opacity: 0; transform: translateY(10px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

.skye-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 14px 14px 16px;
  border-bottom: 1px solid var(--skye-line);
  background: linear-gradient(180deg, #fbfcff, #fff);
}
.skye-head-av { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.skye-head-id { display: flex; flex-direction: column; line-height: 1.25; flex: 1; min-width: 0; }
.skye-head-id strong { font-size: 15px; color: var(--skye-ink); font-weight: 600; }
.skye-head-id span { font-size: 12px; color: var(--skye-muted); }
.skye-new, .skye-min {
  width: 30px; height: 30px; border: 0; background: transparent; cursor: pointer;
  color: var(--skye-muted); border-radius: 8px; display: grid; place-items: center;
}
.skye-new:hover, .skye-min:hover { background: #f0f2f7; color: var(--skye-ink); }
.skye-new svg { width: 17px; height: 17px; }
.skye-min svg { width: 20px; height: 20px; }

/* ── Message log ──────────────────────────────────────────────────── */
.skye-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
/* A message row: Skye's avatar + her bubble (or just the user's bubble). */
.skye-row { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.skye-row.bot { justify-content: flex-start; }
.skye-row.me { justify-content: flex-end; }
.skye-row-av { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }

.skye-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.skye-msg a { color: var(--skye-accent); text-decoration: underline; }
.skye-msg.me a { color: #fff; }

/* CTA pill button: rendered for [[label](url)] or for links to known CTA URLs
   (e.g. #book-demo). Stands out from inline references. */
.skye-msg .skye-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 6px 6px 2px 0;
  padding: 8px 14px;
  background: var(--skye-accent);
  color: #fff;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  transition: background .15s ease, transform .15s ease;
}
.skye-msg .skye-cta:hover { background: #0d54d6; transform: translateY(-1px); text-decoration: none; }
.skye-msg .skye-cta-arrow { display: inline-block; transition: transform .15s ease; }
.skye-msg .skye-cta:hover .skye-cta-arrow { transform: translateX(2px); }
.skye-msg.bot {
  background: #f1f4f9;
  color: var(--skye-ink);
  border-bottom-left-radius: 5px;
}
.skye-msg.me {
  background: var(--skye-user);
  color: #fff;
  border-bottom-right-radius: 5px;
  white-space: pre-wrap;
}

/* Rendered markdown inside Skye's replies */
.skye-msg p { margin: 0 0 9px; }
.skye-msg > :last-child { margin-bottom: 0; }
.skye-msg ul, .skye-msg ol { margin: 8px 0; padding-left: 18px; }
.skye-msg li { margin: 5px 0; padding-left: 2px; }
.skye-msg li::marker { color: #9aa6b8; }
.skye-msg strong { font-weight: 600; }
.skye-msg em { font-style: italic; }
.skye-msg .skye-h { font-weight: 700; margin: 10px 0 4px; }
.skye-msg .skye-h:first-child { margin-top: 0; }

/* Quick-reply chips on first open (indented to line up under Skye) */
.skye-chips { display: flex; flex-wrap: wrap; gap: 8px; align-self: flex-start; margin: 2px 0 0 34px; }
.skye-chip {
  border: 1px solid var(--skye-line);
  background: #fff;
  color: var(--skye-accent);
  font: inherit;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.skye-chip:hover { background: #f4f8ff; border-color: var(--skye-accent); }

/* Typing dots */
.skye-typing { display: inline-flex; gap: 4px; align-items: center; padding: 13px 14px; }
.skye-typing i {
  width: 7px; height: 7px; border-radius: 50%; background: #b4bdcc;
  animation: skye-blink 1.2s infinite ease-in-out;
}
.skye-typing i:nth-child(2) { animation-delay: .2s; }
.skye-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes skye-blink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ── Composer ─────────────────────────────────────────────────────── */
.skye-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--skye-line);
}
.skye-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.skye-input {
  flex: 1;
  box-sizing: border-box;
  min-height: 44px;
  max-height: 110px;
  border: 1px solid var(--skye-line);
  border-radius: 14px;
  padding: 11px 14px;
  font: inherit;
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--skye-ink);
  resize: none;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.skye-input:focus { border-color: var(--skye-accent); box-shadow: 0 0 0 3px rgba(18, 100, 255, .12); }
.skye-send {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--skye-accent);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: opacity .15s ease, transform .12s ease;
}
.skye-send:hover { transform: translateY(-1px); }
.skye-send:disabled { opacity: .45; cursor: default; transform: none; }
.skye-send svg { width: 18px; height: 18px; }

.skye-foot {
  text-align: center;
  font-size: 11.5px;
  color: var(--skye-muted);
  padding: 0 12px 11px;
}
.skye-foot a { color: var(--skye-accent); text-decoration: none; }
.skye-foot a:hover { text-decoration: underline; }

/* ── Proactive peek ──────────────────────────────────────────────────
   A small "say hi" bubble that floats above the launcher after the visitor
   scrolls or idles for a beat. Body opens the chat, X dismisses it. */
.skye-peek {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: 260px;
  max-width: calc(100vw - 32px);
  background: var(--skye-bg);
  border: 1px solid var(--skye-line);
  border-radius: 16px;
  box-shadow: 0 14px 36px rgba(12, 19, 32, .18), 0 3px 10px rgba(12, 19, 32, .08);
  padding: 14px 40px 14px 16px;
  /* Start off-state; the `.is-in` class transitions to visible, `.is-out`
     transitions back, both on the same easing for a symmetric slide. */
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .5s cubic-bezier(.2, .9, .3, 1.2),
              transform .5s cubic-bezier(.2, .9, .3, 1.2);
}
.skye-peek.is-in  { opacity: 1; transform: none; }
.skye-peek.is-out { opacity: 0; transform: translateY(16px); }
.skye-peek-body {
  cursor: pointer;
  color: var(--skye-ink);
  font-size: 14px;
  line-height: 1.45;
}
.skye-peek-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border: 0;
  background: transparent;
  border-radius: 50%;
  color: var(--skye-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.skye-peek-close:hover { background: #f0f2f7; color: var(--skye-ink); }
.skye-peek-close svg { width: 13px; height: 13px; }
@keyframes skye-peek-in {
  from { opacity: 0; transform: translateY(6px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* ── Lead-capture (lives inside a regular Skye chat bubble) ──────────
   The capture is a normal .skye-row.bot — avatar outside, gray bubble
   inside — with the form inputs + buttons stacked below the message
   text so it reads like part of the conversation, not a separate card. */
.skye-row.skye-capture { align-items: flex-start; } /* avatar pinned to top, not bottom */
.skye-capture-bubble { max-width: 82%; } /* match the regular bot bubble width */
.skye-capture-form {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 10px;
}
.skye-capture-form input[type="text"],
.skye-capture-form input[type="email"] {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--skye-line);
  background: #fff;
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--skye-ink);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.skye-capture-form input:focus {
  border-color: var(--skye-accent);
  box-shadow: 0 0 0 3px rgba(18, 100, 255, .12);
}
.skye-capture-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.skye-capture-send {
  border: 0;
  background: var(--skye-accent);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity .15s ease, transform .12s ease;
}
.skye-capture-send:hover { transform: translateY(-1px); }
.skye-capture-send:disabled { opacity: .55; cursor: default; transform: none; }
.skye-capture-skip {
  border: 0;
  background: transparent;
  color: var(--skye-muted);
  font: inherit;
  font-size: 13.5px;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 6px;
}
.skye-capture-skip:hover { color: var(--skye-ink); background: rgba(255,255,255,.6); }
.skye-capture-err {
  font-size: 13px;
  color: #b32d2e;
  margin-top: 4px;
}

/* "Chat ended" stamp shown after the idle-timeout flow runs. Sits below the
   final goodbye Skye message, then the composer is disabled. */
.skye-ended {
  align-self: center;
  margin: 8px 0;
  padding: 4px 12px;
  font-size: 12.5px;
  color: var(--skye-muted);
  font-style: italic;
  letter-spacing: .2px;
}

@media (max-width: 480px) {
  #skye { right: 14px; bottom: 14px; }
  .skye-panel { bottom: 70px; height: calc(100vh - 96px); }
  .skye-peek { bottom: 70px; }
}
@media (prefers-reduced-motion: reduce) {
  .skye-panel, .skye-launch, .skye-launch-av, .skye-launch-x, .skye-typing i, .skye-launch-badge, .skye-peek { animation: none; transition: none; }
}
