/* ═══════════════════════════════════════════
   HighPex AI Assistant — Chat Widget
   ═══════════════════════════════════════════ */

/* Chat Button */
.ai-chat-button {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99,102,241,0.95), rgba(168,85,247,0.95));
  border: 1px solid rgba(255,255,255,0.25);
  box-shadow: 0 4px 24px rgba(99,102,241,0.4), 0 0 0 1px rgba(255,255,255,0.1) inset;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 99999;
  color: #fff;
  font-size: 24px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* breathing ring so the launcher reads as live without being noisy */
.ai-chat-button::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid rgba(168,85,247,0.5);
  animation: aiChatRing 2.8s ease-out infinite;
  pointer-events: none;
}

@keyframes aiChatRing {
  0% { transform: scale(0.92); opacity: 0.7; }
  70%, 100% { transform: scale(1.22); opacity: 0; }
}

.ai-chat-button:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 32px rgba(99,102,241,0.5), 0 0 0 1px rgba(255,255,255,0.15) inset;
}

.ai-chat-button:active {
  transform: scale(0.92);
}

.ai-chat-button.active {
  display: none;
}

/* Chat Container */
.ai-chat-container {
  position: fixed;
  bottom: 100px;
  right: 32px;
  width: 400px;
  height: 600px;
  background: rgba(14,12,26,0.93);
  backdrop-filter: blur(30px) saturate(190%);
  -webkit-backdrop-filter: blur(30px) saturate(190%);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 22px;
  box-shadow:
    0 24px 70px rgba(0,0,0,0.62),
    0 8px 28px rgba(99,102,241,0.18),
    0 0 0 1px rgba(255,255,255,0.06) inset;
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  animation: chatOpen 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes chatOpen {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ai-chat-container.active {
  display: flex;
}

/* Glass shine effect */
.ai-chat-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 5%, rgba(255,255,255,0.2) 25%, rgba(255,255,255,0.25) 50%, rgba(255,255,255,0.2) 75%, transparent 95%);
  pointer-events: none;
}

.ai-chat-container::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.01) 30%, transparent 60%);
  pointer-events: none;
}

/* Chat Header */
.ai-chat-header {
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  /* above .ai-chat-messages / .ai-chat-welcome (both z-index 1 and later in DOM),
     otherwise the kebab dropdown paints behind the transcript */
  z-index: 5;
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(99,102,241,0.16), rgba(99,102,241,0));
}

.ai-chat-header::after {
  content: '';
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.14) 20%, rgba(255,255,255,0.14) 80%, transparent);
}

.ai-chat-header-title {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.ai-chat-avatar {
  position: relative;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.92rem;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  border: 1px solid rgba(255,255,255,0.22);
  box-shadow: 0 4px 14px rgba(99,102,241,0.45), inset 0 1px 0 rgba(255,255,255,0.28);
}

/* presence dot rides the avatar edge; the ring matches the header backdrop so it
   reads as cut out of it rather than floating */
.ai-chat-avatar::after {
  content: '';
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #16132b;
  box-shadow: 0 0 8px rgba(34,197,94,0.7);
}

.ai-chat-id {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ai-chat-name {
  font-family: 'Sora', sans-serif;
  font-size: 0.94rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-chat-header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.ai-chat-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: rgba(255,255,255,0.6);
  font-size: 14px;
}

.ai-chat-close:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.ai-chat-reset {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  margin-right: 8px;
}

.ai-chat-reset:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  transform: rotate(180deg);
}

/* ── Kebab menu ── */
.ai-chat-menu-wrap {
  position: relative;
  display: flex;
}

/* nothing in the menu applies before a conversation exists */
.ai-chat-container:not(.started) .ai-chat-menu-wrap { display: none; }

.ai-chat-menu-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  color: rgba(255,255,255,0.6);
  font-size: 14px;
}

.ai-chat-menu-btn:hover,
.ai-chat-menu-wrap.open .ai-chat-menu-btn {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.ai-chat-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 170px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(24,20,44,0.98);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 16px 40px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.06);
  z-index: 12;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.97);
  transform-origin: 90% 0;
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.34,1.4,0.64,1), visibility 0.18s;
}

.ai-chat-menu-wrap.open .ai-chat-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.ai-chat-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
  color: rgba(255,255,255,0.8);
  transition: background 0.16s ease, color 0.16s ease;
}

.ai-chat-dropdown-item i { font-size: 0.8rem; }

.ai-chat-dropdown-item:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
}

.ai-chat-dropdown-item.danger { color: rgba(252,165,165,0.9); }

.ai-chat-dropdown-item.danger:hover {
  background: rgba(239,68,68,0.16);
  color: #fecaca;
}

/* ── Confirm dialog ── */
.ai-modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(6,5,14,0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s;
}

.ai-modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.ai-modal {
  width: 100%;
  max-width: 306px;
  padding: 22px 20px 18px;
  border-radius: 18px;
  text-align: center;
  background: rgba(20,17,38,0.98);
  border: 1px solid rgba(255,255,255,0.13);
  box-shadow: 0 24px 60px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.08);
  transform: translateY(10px) scale(0.95);
  transition: transform 0.28s cubic-bezier(0.16,1,0.3,1);
}

.ai-modal-overlay.show .ai-modal { transform: translateY(0) scale(1); }

.ai-modal-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 13px;
  border-radius: 14px;
  font-size: 1.02rem;
  color: #fcd34d;
  background: rgba(245,158,11,0.14);
  border: 1px solid rgba(245,158,11,0.28);
}

.ai-modal-title {
  margin: 0 0 8px;
  font-family: 'Sora', sans-serif;
  font-size: 1.04rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
}

.ai-modal-text {
  margin: 0 0 18px;
  font-family: 'Inter', sans-serif;
  font-size: 0.81rem;
  line-height: 1.6;
  color: rgba(255,255,255,0.62);
}

.ai-modal-actions {
  display: flex;
  gap: 9px;
}

.ai-modal-btn {
  flex: 1;
  padding: 11px 14px;
  border-radius: 11px;
  font-family: 'Inter', sans-serif;
  font-size: 0.83rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.ai-modal-btn:active { transform: scale(0.97); }

.ai-modal-btn.cancel {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.78);
}

.ai-modal-btn.cancel:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.ai-modal-btn.confirm {
  background: linear-gradient(135deg, rgba(239,68,68,0.9), rgba(190,24,93,0.85));
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 6px 20px rgba(239,68,68,0.34), inset 0 1px 0 rgba(255,255,255,0.26);
}

.ai-modal-btn.confirm:hover {
  filter: brightness(1.1);
  box-shadow: 0 9px 26px rgba(239,68,68,0.46), inset 0 1px 0 rgba(255,255,255,0.32);
}

/* ── AI-generated temp article card ── */
.ai-temp-card {
  padding: 15px 16px 14px;
  border-radius: 15px;
  background: linear-gradient(160deg, rgba(168,85,247,0.12), rgba(99,102,241,0.07));
  border: 1px solid rgba(168,85,247,0.28);
  box-shadow: 0 6px 22px rgba(88,28,135,0.22), inset 0 1px 0 rgba(255,255,255,0.08);
}

.ai-temp-flag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 9px;
  padding: 4px 9px;
  border-radius: 100px;
  font-family: 'Inter', sans-serif;
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #e9d5ff;
  background: rgba(168,85,247,0.2);
  border: 1px solid rgba(168,85,247,0.36);
}

.ai-temp-flag i { font-size: 0.6rem; }

.ai-temp-title {
  font-family: 'Sora', sans-serif;
  font-size: 0.93rem;
  font-weight: 700;
  line-height: 1.35;
  color: #fff;
}

.ai-temp-excerpt {
  margin-top: 5px;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  line-height: 1.5;
  color: rgba(255,255,255,0.6);
}

.ai-temp-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  padding: 9px 16px;
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  background: linear-gradient(135deg, rgba(99,102,241,0.9), rgba(168,85,247,0.85));
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 4px 16px rgba(99,102,241,0.34), inset 0 1px 0 rgba(255,255,255,0.24);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.ai-temp-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(168,85,247,0.46), inset 0 1px 0 rgba(255,255,255,0.3);
}

.ai-temp-link i { font-size: 0.7rem; }

.ai-temp-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 11px;
  font-family: 'Inter', sans-serif;
  font-size: 0.68rem;
  line-height: 1.45;
  color: rgba(252,211,77,0.78);
}

.ai-temp-note i { margin-top: 2px; font-size: 0.64rem; }

/* ── Post-chat actions ── */
.ai-chat-end-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
  align-self: stretch;
  padding: 4px 2px 6px;
  animation: messageSlideIn 0.4s cubic-bezier(0.4,0,0.2,1);
}

.ai-end-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 18px;
  border-radius: 13px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.ai-end-btn i { font-size: 0.8rem; }

.ai-end-btn:active { transform: scale(0.98); }

.ai-end-btn.primary {
  background: linear-gradient(135deg, rgba(99,102,241,0.9), rgba(168,85,247,0.85));
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 6px 20px rgba(99,102,241,0.36), inset 0 1px 0 rgba(255,255,255,0.28);
}

.ai-end-btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(168,85,247,0.46), inset 0 1px 0 rgba(255,255,255,0.34);
}

.ai-end-btn.ghost {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.13);
  color: rgba(255,255,255,0.72);
}

.ai-end-btn.ghost:hover {
  background: rgba(255,255,255,0.09);
  color: #fff;
}

/* ── Welcome screen (pre-conversation) ── */
.ai-chat-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  text-align: left;
  position: relative;
  overflow: hidden;
  z-index: 1;
}

/* padding lives on the body, so .ai-chat-powered's border can span edge to edge */
.ai-welcome-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 28px 24px 4px;
  position: relative;
  z-index: 1;
  overflow-y: auto;
}

.ai-welcome-body::-webkit-scrollbar { width: 6px; }
.ai-welcome-body::-webkit-scrollbar-track { background: transparent; }
.ai-welcome-body::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}

/* ── Decorative backdrop ── */
.ai-welcome-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.ai-welcome-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.045) 1px, transparent 1px);
  background-size: 30px 30px;
  /* fades the grid out downward so it never competes with the History card */
  -webkit-mask-image: radial-gradient(120% 78% at 12% 0%, #000 0%, transparent 72%);
  mask-image: radial-gradient(120% 78% at 12% 0%, #000 0%, transparent 72%);
}

.ai-welcome-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(34px);
}

.ai-welcome-orb-1 {
  top: -58px;
  right: -46px;
  width: 190px;
  height: 190px;
  background: radial-gradient(circle, rgba(168,85,247,0.5), transparent 68%);
  animation: aiOrbFloat 11s ease-in-out infinite;
}

.ai-welcome-orb-2 {
  top: 96px;
  left: -70px;
  width: 176px;
  height: 176px;
  background: radial-gradient(circle, rgba(99,102,241,0.42), transparent 68%);
  animation: aiOrbFloat 14s ease-in-out -5s infinite reverse;
}

@keyframes aiOrbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(-14px, 18px) scale(1.12); }
}

/* one state class on the container drives both panes, so they can never both
   claim flex:1 at the same time */
.ai-chat-container:not(.started) .ai-chat-messages,
.ai-chat-container:not(.started) .ai-chat-input-area,
.ai-chat-container.started .ai-chat-welcome { display: none; }

.ai-chat-welcome-title {
  margin: 0;
  font-family: 'Sora', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  background: linear-gradient(100deg, #fff 0%, #e9deff 45%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  /* text-shadow does nothing through background-clip:text */
  filter: drop-shadow(0 2px 14px rgba(168,85,247,0.4));
}

.ai-chat-welcome-sub {
  margin: 9px 0 0;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  line-height: 1.55;
  color: rgba(255,255,255,0.6);
}

/* ── Liquid glass button ── */
.ai-chat-start-btn {
  position: relative;
  overflow: hidden;
  display: flex;
  align-self: stretch;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 22px;
  padding: 15px 24px;
  border-radius: 15px;
  font-family: 'Inter', sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, rgba(99,102,241,0.5), rgba(168,85,247,0.42));
  border: 1px solid rgba(255,255,255,0.2);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  box-shadow:
    0 8px 28px rgba(99,102,241,0.34),
    inset 0 1px 0 rgba(255,255,255,0.34),
    inset 0 -1px 0 rgba(0,0,0,0.16);
  transition: transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1),
              box-shadow 0.22s ease,
              background 0.22s ease;
}

/* upper-half specular sheen, the "liquid" read */
.ai-chat-start-btn::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 52%;
  border-radius: 14px 14px 46% 46% / 14px 14px 100% 100%;
  background: linear-gradient(180deg, rgba(255,255,255,0.3), rgba(255,255,255,0.04) 64%, transparent);
  pointer-events: none;
}

/* highlight that sweeps across on hover */
.ai-chat-start-btn::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -60%;
  width: 45%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.34), transparent);
  transform: skewX(-18deg);
  pointer-events: none;
  transition: left 0.6s ease;
}

.ai-chat-start-btn:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, rgba(99,102,241,0.68), rgba(168,85,247,0.58));
  box-shadow:
    0 12px 34px rgba(168,85,247,0.46),
    inset 0 1px 0 rgba(255,255,255,0.42),
    inset 0 -1px 0 rgba(0,0,0,0.16);
}

.ai-chat-start-btn:hover::after { left: 120%; }

.ai-chat-start-btn:active { transform: translateY(0) scale(0.98); }

.ai-chat-start-btn i { font-size: 0.85rem; }

/* ── History card ── */
.ai-welcome-section {
  align-self: stretch;
  margin-top: 26px;
}

.ai-welcome-section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 11px;
  font-family: 'Inter', sans-serif;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.34);
}

/* hairline that fills whatever width the label leaves */
.ai-welcome-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(255,255,255,0.12), transparent);
}

.ai-welcome-history {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 18px 16px;
  border-radius: 15px;
  text-align: center;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.08);
}

.ai-welcome-history-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  font-size: 0.82rem;
  color: rgba(196,181,253,0.9);
  background: rgba(168,85,247,0.14);
  border: 1px solid rgba(168,85,247,0.24);
}

.ai-welcome-history-text {
  margin: 0;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  line-height: 1.5;
  color: rgba(255,255,255,0.58);
}

.ai-welcome-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.16);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.ai-welcome-login-btn:hover {
  background: rgba(168,85,247,0.2);
  border-color: rgba(168,85,247,0.45);
  transform: translateY(-1px);
}

.ai-welcome-login-btn i { font-size: 0.72rem; }

/* signed-in state: green instead of purple, so the box reads as "history is on" */
.ai-welcome-history-icon.signed {
  color: rgba(134,239,172,0.9);
  background: rgba(34,197,94,0.14);
  border-color: rgba(34,197,94,0.26);
}

.ai-welcome-resume-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, rgba(99,102,241,0.85), rgba(168,85,247,0.8));
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 4px 16px rgba(99,102,241,0.3), inset 0 1px 0 rgba(255,255,255,0.24);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ai-welcome-resume-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(168,85,247,0.42), inset 0 1px 0 rgba(255,255,255,0.3);
}

.ai-welcome-resume-btn:active { transform: translateY(0) scale(0.98); }

.ai-welcome-resume-btn i { font-size: 0.72rem; }

.ai-welcome-temp {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.68rem;
  line-height: 1.4;
  color: rgba(255,255,255,0.3);
}

.ai-welcome-temp i { font-size: 0.66rem; }

/* margin-top:auto pushes it to the floor of the welcome pane, so it reads as a
   footer of the box rather than trailing the button */
.ai-chat-powered {
  margin-top: auto;
  align-self: stretch;
  padding: 13px 0 15px;
  text-align: center;
  font-family: 'Inter', sans-serif;
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.28);
  border-top: 1px solid rgba(255,255,255,0.06);
}

.ai-chat-powered sup {
  font-size: 0.72em;
  margin-left: 1px;
}

/* Chat Messages Area */
.ai-chat-messages {
  flex: 1;
  padding: 20px 18px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: relative;
  z-index: 1;
  scroll-behavior: smooth;
}

.ai-chat-messages::-webkit-scrollbar {
  width: 6px;
}

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

.ai-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.15);
}

/* Message Bubble */
.ai-message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: messageSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  border: 1px solid rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-size: 11px;
  box-shadow: 0 3px 10px rgba(99,102,241,0.4);
}

/* the user's own turn needs no avatar — the right-alignment already says who spoke */
.user-message .ai-message-avatar { display: none; }

.ai-message-content {
  flex: 1;
  min-width: 0;
}

.ai-message-sender {
  display: block;
  margin: 0 0 5px 2px;
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(196,181,253,0.85);
}

/* system/handoff notices sit centred between the two speakers */
.ai-chat-notice {
  align-self: center;
  max-width: 90%;
  padding: 8px 14px;
  border-radius: 100px;
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.45;
  text-align: center;
  color: rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  animation: messageSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* assistant turns are bubble-less prose (Claude/ChatGPT read) — only the user's
   own turn gets a container, which is what makes the transcript scan as a document */
.ai-message-bubble {
  padding: 0;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  line-height: 1.65;
  color: rgba(255,255,255,0.9);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* pre-wrap is only right while raw text streams in; once markdown is parsed the
   block elements own the spacing and pre-wrap would double every gap */
.ai-message-bubble.md { white-space: normal; }

/* user messages mirror to the right so the two speakers read apart */
.user-message {
  flex-direction: row-reverse;
}

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

.user-message .ai-message-bubble {
  padding: 10px 15px;
  border-radius: 16px 16px 5px 16px;
  background: linear-gradient(135deg, rgba(99,102,241,0.34), rgba(168,85,247,0.28));
  border: 1px solid rgba(99,102,241,0.42);
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
  color: #fff;
  max-width: 88%;
}

/* ── Rich text inside an assistant turn ── */
.ai-message-bubble p { margin: 0 0 10px; }
.ai-message-bubble > *:last-child { margin-bottom: 0; }

.ai-message-bubble strong { font-weight: 700; color: #fff; }

.ai-message-bubble ul,
.ai-message-bubble ol {
  margin: 0 0 10px;
  padding-left: 20px;
}

.ai-message-bubble li { margin: 3px 0; }

.ai-message-bubble a {
  color: #c4b5fd;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ai-message-bubble code {
  padding: 2px 6px;
  border-radius: 5px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.82em;
  color: #e9d5ff;
  background: rgba(168,85,247,0.14);
  border: 1px solid rgba(168,85,247,0.22);
}

.ai-message-bubble pre {
  margin: 10px 0;
  padding: 12px 14px;
  border-radius: 11px;
  background: rgba(0,0,0,0.42);
  border: 1px solid rgba(255,255,255,0.09);
  overflow-x: auto;
  white-space: pre;
}

.ai-message-bubble pre code {
  padding: 0;
  border: none;
  background: none;
  color: rgba(255,255,255,0.88);
  font-size: 0.8rem;
  line-height: 1.6;
}

/* blinking caret while a reply is still streaming in */
.ai-message-bubble.streaming::after {
  content: '';
  display: inline-block;
  width: 7px;
  height: 15px;
  margin-left: 3px;
  vertical-align: -2px;
  border-radius: 2px;
  background: #c084fc;
  animation: aiCaret 1s steps(2, end) infinite;
}

@keyframes aiCaret {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ── Per-turn action row ── */
.ai-message-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.ai-message:hover .ai-message-actions,
.ai-message-actions:focus-within { opacity: 1; }

.ai-msg-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 7px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.45);
  font-family: 'Inter', sans-serif;
  font-size: 0.66rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.ai-msg-action:hover {
  color: #fff;
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.2);
}

.ai-msg-action.copied {
  color: #86efac;
  border-color: rgba(34,197,94,0.4);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(99,102,241,0.6);
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
  animation-delay: 0s;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Chat Input Area */
.ai-chat-input-area {
  padding: 14px 16px 16px;
  position: relative;
  z-index: 1;
  display: none;
  flex-shrink: 0;
}

.ai-chat-input-area::before {
  content: '';
  position: absolute;
  left: 16px;
  right: 16px;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12) 50%, transparent);
}

.ai-chat-input-area.active {
  display: block;
}

.ai-chat-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 6px 6px 6px 8px;
  background: rgba(255,255,255,0.045);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.ai-chat-input-wrapper:focus-within {
  background: rgba(255,255,255,0.06);
  border-color: rgba(99,102,241,0.45);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.ai-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 9px 6px;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #fff;
  resize: none;
  max-height: 120px;
  min-height: 36px;
}

.ai-chat-input:focus {
  outline: none;
}

.ai-chat-input::placeholder {
  color: rgba(255,255,255,0.38);
}

.ai-chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  border: 1px solid rgba(255,255,255,0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  color: #fff;
  font-size: 13px;
  flex-shrink: 0;
}

.ai-chat-send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.12);
  box-shadow: 0 5px 18px rgba(99,102,241,0.5);
}

.ai-chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Thinking Indicator - Gemini Style */
.ai-thinking-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(168,85,247,0.9);
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  padding: 12px 16px;
}

.ai-thinking-status i {
  color: rgba(168,85,247,0.8);
  animation: pulse 1.5s ease-in-out infinite;
}

.thinking-dots {
  display: inline-block;
}

.thinking-dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% { content: ''; }
  40% { content: '.'; }
  60% { content: '..'; }
  80%, 100% { content: '...'; }
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* AI Thinking Indicator */
.ai-thinking {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(168,85,247,0.8);
  font-size: 0.85rem;
  font-style: italic;
  margin-top: 4px;
}

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

/* Knowledge Base Articles */
.kb-articles-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(168,85,247,0.08);
  border: 1px solid rgba(168,85,247,0.15);
  border-radius: 10px;
  margin-bottom: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  color: rgba(168,85,247,0.9);
}

.kb-articles-header i {
  font-size: 0.9rem;
}

.kb-articles-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kb-article-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 14px 16px;
  transition: all 0.2s ease;
}

.kb-article-card:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(99,102,241,0.3);
  transform: translateX(2px);
}

.kb-article-title {
  font-family: 'Sora', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 8px;
  line-height: 1.4;
}

.kb-article-excerpt {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  line-height: 1.5;
  color: rgba(255,255,255,0.6);
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kb-article-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(168,85,247,0.15));
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: #a5b4fc;
  text-decoration: none;
  transition: all 0.2s ease;
}

.kb-article-link:hover {
  background: linear-gradient(135deg, rgba(99,102,241,0.25), rgba(168,85,247,0.25));
  border-color: rgba(99,102,241,0.5);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(99,102,241,0.2);
}

.kb-article-link i {
  font-size: 0.75rem;
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .ai-chat-container {
    width: calc(100vw - 24px);
    height: calc(100vh - 96px);
    bottom: 12px;
    right: 12px;
    border-radius: 18px;
  }

  .ai-chat-container::after {
    border-radius: 18px;
  }

  .ai-chat-button {
    bottom: 16px;
    right: 16px;
  }
}

/* ═══════════════════════════════════════════
   Teaser card — chat invite
   ═══════════════════════════════════════════ */

.ai-teaser {
  position: fixed;
  right: 32px;
  bottom: 108px;
  width: 272px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(14,12,26,0.93);
  backdrop-filter: blur(26px) saturate(180%);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  box-shadow:
    0 20px 50px rgba(0,0,0,0.55),
    0 6px 20px rgba(99,102,241,0.18),
    inset 0 1px 0 rgba(255,255,255,0.07);
  cursor: pointer;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px) scale(0.97);
  /* grows out of / retracts into the launcher sitting below-right */
  transform-origin: 90% 100%;
  z-index: 99998;
  /* transform and opacity are driven by the keyframes below, so they stay out of
     the transition — otherwise the two fight over the same properties on hover */
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ai-teaser.show {
  pointer-events: auto;
  animation: aiTeaserIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* must follow .show — same specificity, so source order decides which wins
   during the frame where both classes are present */
.ai-teaser.hiding {
  pointer-events: none;
  animation: aiTeaserOut 0.34s ease forwards;
}

@keyframes aiTeaserIn {
  0%   { opacity: 0; transform: translateY(16px) scale(0.94); }
  65%  { opacity: 1; transform: translateY(-2px) scale(1.02); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes aiTeaserOut {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(12px) scale(0.9); }
}

.ai-teaser:hover,
.ai-teaser:focus-visible {
  border-color: rgba(168,85,247,0.45);
  box-shadow:
    0 24px 60px rgba(0,0,0,0.6),
    0 8px 26px rgba(168,85,247,0.32),
    inset 0 1px 0 rgba(255,255,255,0.1);
  outline: none;
}

/* top sheen, same glass treatment as the chat panel */
.ai-teaser::before {
  content: '';
  position: absolute;
  left: 18px;
  right: 18px;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.22) 50%, transparent);
  pointer-events: none;
}

/* rotated square, so only the two outer edges carry a border */
.ai-teaser-tail {
  position: absolute;
  right: 26px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: rgba(14,12,26,0.93);
  border-right: 1px solid rgba(255,255,255,0.12);
  border-bottom: 1px solid rgba(255,255,255,0.12);
  border-bottom-right-radius: 3px;
  transform: rotate(45deg);
  pointer-events: none;
}

.ai-teaser-head {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 12px;
}

.ai-teaser-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 4px 14px rgba(99,102,241,0.45), inset 0 1px 0 rgba(255,255,255,0.28);
}

/* ring colour matches the card, so the dot reads as cut out of the avatar */
.ai-teaser-avatar::after {
  content: '';
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #151228;
  box-shadow: 0 0 8px rgba(34,197,94,0.7);
}

.ai-teaser-id {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.ai-teaser-name {
  font-family: 'Sora', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: #fff;
}

.ai-teaser-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: 'Inter', sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1;
  color: rgba(134,239,172,0.9);
}

.ai-teaser-status::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34,197,94,0.8);
}

.ai-teaser-msg {
  margin: 0;
  padding: 11px 13px;
  border-radius: 12px 12px 12px 4px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  line-height: 1.5;
  color: rgba(255,255,255,0.82);
}

/* looks like a button, deliberately inert — the whole card is the hit area */
.ai-teaser-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 16px;
  border-radius: 11px;
  pointer-events: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, rgba(99,102,241,0.95), rgba(168,85,247,0.95));
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: 0 4px 14px rgba(99,102,241,0.4), inset 0 1px 0 rgba(255,255,255,0.22);
}

.ai-teaser-cta i { font-size: 0.72rem; }

.ai-teaser-close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(24,20,44,0.96);
  border: 1px solid rgba(255,255,255,0.16);
  color: rgba(255,255,255,0.6);
  font-size: 9px;
  line-height: 1;
  cursor: pointer;
  z-index: 3;
  transition: background 0.2s ease, color 0.2s ease;
}

.ai-teaser-close:hover {
  background: rgba(168,85,247,0.55);
  color: #fff;
}

@media (max-width: 480px) {
  .ai-teaser {
    right: 16px;
    bottom: 88px;
    width: calc(100vw - 84px);
    max-width: 252px;
  }
}

/* decorative only — the typing/thinking indicators stay, they convey state */
@media (prefers-reduced-motion: reduce) {
  .ai-chat-button::after {
    animation: none;
  }
  /* keep the end states so the card still appears and still auto-dismisses */
  .ai-teaser.show {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .ai-teaser.hiding {
    animation: none;
    opacity: 0;
  }
}
