/* AgentLode chat widget */
.al-chat-root {
  --al-chat-bg: #121214;
  --al-chat-panel: #18181b;
  --al-chat-border: #27272a;
  --al-chat-text: #fafafa;
  --al-chat-muted: #a1a1aa;
  --al-chat-accent: #2dd4bf;
  --al-chat-accent-ink: #042f2e;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
}

.al-chat-launcher {
  position: relative;
  width: 64px;
  height: 64px;
  border: 0;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  background: radial-gradient(circle at 30% 25%, #2a2a2e, #0c0c0e 70%);
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(45, 212, 191, 0.35),
    0 0 28px rgba(45, 212, 191, 0.25);
  display: grid;
  place-items: center;
  will-change: transform;
  transition: box-shadow 0.2s ease;
  /* transform driven by JS magnetic sticky */
}
.al-chat-launcher.is-sticky {
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(45, 212, 191, 0.6),
    0 0 40px rgba(45, 212, 191, 0.4);
}
.al-chat-launcher.is-returning {
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s ease;
}
.al-chat-launcher:focus-visible {
  outline: 2px solid var(--al-chat-accent);
  outline-offset: 3px;
}
.al-chat-launcher img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  animation: al-bob 2.8s ease-in-out infinite;
}
.al-chat-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(45, 212, 191, 0.45);
  animation: al-pulse 2.2s ease-out infinite;
  pointer-events: none;
}
.al-chat-pulse.delay {
  animation-delay: 0.7s;
}
@keyframes al-pulse {
  0% { transform: scale(0.92); opacity: 0.85; }
  100% { transform: scale(1.35); opacity: 0; }
}
@keyframes al-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
.al-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--al-chat-accent);
  color: var(--al-chat-accent-ink);
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.al-chat-panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: min(360px, calc(100vw - 28px));
  height: min(520px, calc(100vh - 120px));
  background: var(--al-chat-panel);
  border: 1px solid var(--al-chat-border);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.al-chat-root.open .al-chat-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.al-chat-root.open .al-chat-launcher img {
  animation: none;
}

.al-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--al-chat-border);
  background: linear-gradient(180deg, rgba(45, 212, 191, 0.08), transparent);
}
.al-chat-header img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.35);
}
.al-chat-header h3 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--al-chat-text);
  letter-spacing: -0.02em;
}
.al-chat-header p {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: var(--al-chat-muted);
}
.al-chat-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.al-chat-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--al-chat-accent);
  box-shadow: 0 0 0 0 rgba(45, 212, 191, 0.5);
  animation: al-dot 1.8s ease infinite;
}
@keyframes al-dot {
  0% { box-shadow: 0 0 0 0 rgba(45, 212, 191, 0.45); }
  70% { box-shadow: 0 0 0 7px rgba(45, 212, 191, 0); }
  100% { box-shadow: 0 0 0 0 rgba(45, 212, 191, 0); }
}
.al-chat-close {
  margin-left: auto;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--al-chat-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.al-chat-close:hover {
  background: rgba(255,255,255,0.06);
  color: var(--al-chat-text);
}

.al-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #0c0c0e;
}
.al-msg {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--al-chat-text);
  animation: al-msg-in 0.22s ease both;
}
@keyframes al-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.al-msg.bot {
  align-self: flex-start;
  background: #1c1c20;
  border: 1px solid var(--al-chat-border);
  border-bottom-left-radius: 5px;
}
.al-msg.user {
  align-self: flex-end;
  background: rgba(45, 212, 191, 0.16);
  border: 1px solid rgba(45, 212, 191, 0.35);
  border-bottom-right-radius: 5px;
  color: #ecfeff;
}
.al-msg a { color: var(--al-chat-accent); }

.al-chat-form {
  border-top: 1px solid var(--al-chat-border);
  padding: 12px;
  display: grid;
  gap: 8px;
  background: var(--al-chat-bg);
}
.al-chat-form input,
.al-chat-form textarea {
  width: 100%;
  border: 1px solid var(--al-chat-border);
  background: #0c0c0e;
  color: var(--al-chat-text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.9rem;
  resize: none;
}
.al-chat-form input:focus,
.al-chat-form textarea:focus {
  outline: none;
  border-color: rgba(45, 212, 191, 0.55);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.12);
}
.al-chat-form textarea { min-height: 72px; }
.al-chat-send-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.al-chat-hint {
  font-size: 0.72rem;
  color: var(--al-chat-muted);
}
.al-chat-send {
  border: 0;
  border-radius: 999px;
  height: 38px;
  padding: 0 16px;
  background: var(--al-chat-accent);
  color: var(--al-chat-accent-ink);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
}
.al-chat-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.al-chat-send:hover:not(:disabled) {
  filter: brightness(1.05);
}

@media (max-width: 480px) {
  .al-chat-root { right: 14px; bottom: 14px; }
  .al-chat-panel {
    width: calc(100vw - 28px);
    height: min(70vh, 520px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .al-chat-launcher img,
  .al-chat-pulse,
  .al-chat-status i {
    animation: none !important;
  }
}

.al-chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}
.al-chat-compose textarea {
  min-height: 44px;
  max-height: 120px;
}
.al-need-email {
  border-color: rgba(45, 212, 191, 0.7) !important;
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
}
.al-typing {
  display: inline-flex !important;
  gap: 5px;
  align-items: center;
  padding: 12px 14px !important;
}
.al-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5eead4;
  opacity: 0.35;
  animation: al-type 1.1s ease-in-out infinite;
}
.al-typing span:nth-child(2) { animation-delay: 0.15s; }
.al-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes al-type {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

.al-think {
  align-self: flex-start;
  max-width: 92%;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px dashed rgba(45, 212, 191, 0.35);
  background: rgba(45, 212, 191, 0.06);
  color: #99f6e4;
  font-size: 0.78rem;
  line-height: 1.4;
  animation: al-msg-in 0.22s ease both;
}
.al-think-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: var(--al-chat-accent);
  margin-bottom: 4px;
}
.al-think-label .spin {
  width: 10px;
  height: 10px;
  border: 2px solid rgba(45,212,191,0.25);
  border-top-color: var(--al-chat-accent);
  border-radius: 50%;
  animation: al-spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes al-spin { to { transform: rotate(360deg); } }
.al-chat-status.thinking-mode i {
  background: #fbbf24;
  box-shadow: none;
  animation: al-type 1s ease infinite;
}
