/* Pixel — AI assistant widget. All classes prefixed .ai- to avoid clashing with style.css */
.ai-launcher,
.ai-panel {
  --a: var(--accent, #00f5ff);
  --bg: #0d1117;
  --bg2: #131920;
  --ln: rgba(255, 255, 255, .08);
  --tx: #e5e7eb;
  --mu: #8b949e;
  font-family: 'JetBrains Mono', monospace
}

/* Launcher */
.ai-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1500;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  background: var(--a);
  color: #06121a;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5), 0 0 0 0 rgba(0, 245, 255, .5);
  animation: ai-ping 2.4s 1.5s 2;
  transition: transform .3s cubic-bezier(.22, 1, .36, 1), opacity .25s ease, visibility 0s
}

.ai-launcher:hover {
  transform: translateY(-2px)
}

.ai-launcher svg {
  width: 25px;
  height: 25px
}

.ai-launcher-tip {
  position: absolute;
  right: 68px;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  background: var(--bg2);
  color: var(--tx);
  border: 1px solid var(--ln);
  border-radius: 8px;
  padding: 5px 9px;
  font: 600 11px inherit;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s
}

.ai-launcher:hover .ai-launcher-tip,
.ai-launcher:focus-visible .ai-launcher-tip {
  opacity: 1
}

.ai-launcher.hidden,
body.modal-open .ai-launcher {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(.6) rotate(-20deg);
  transition: transform .3s cubic-bezier(.22, 1, .36, 1), opacity .2s ease, visibility 0s linear .3s
}

@keyframes ai-ping {
  70% {
    box-shadow: 0 6px 20px rgba(0, 0, 0, .5), 0 0 0 14px rgba(0, 245, 255, 0)
  }
}

/* Panel */
.ai-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1500;
  width: 372px;
  max-width: calc(100vw - 24px);
  height: 550px;
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid rgba(0, 245, 255, .22);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .6);
  opacity: 0;
  visibility: hidden;
  transform: translateY(18px) scale(.92);
  transform-origin: bottom right;
  transition: opacity .3s ease, transform .38s cubic-bezier(.22, 1, .36, 1), visibility 0s linear .38s
}

.ai-panel.open {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .3s ease, transform .38s cubic-bezier(.22, 1, .36, 1), visibility 0s
}

body.modal-open .ai-panel {
  visibility: hidden
}

/* Header */
.ai-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg2);
  border-bottom: 1px solid var(--ln)
}

.ai-avatar {
  position: relative;
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(0, 245, 255, .08);
  border: 1px solid rgba(0, 245, 255, .35);
  color: var(--a);
  font: 700 12px inherit
}

.ai-avatar::after {
  content: "";
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #3fb950;
  border: 2px solid var(--bg2)
}

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

.ai-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--tx)
}

.ai-sub {
  font-size: 10.5px;
  color: var(--mu);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.ai-btn {
  background: transparent;
  color: var(--mu);
  border: 1px solid var(--ln);
  border-radius: 6px;
  padding: 4px 8px;
  font: 600 10.5px inherit;
  cursor: pointer;
  transition: .2s
}

.ai-btn:hover {
  color: var(--a);
  border-color: var(--a)
}

/* Messages */
.ai-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #2a323d transparent
}

.ai-msg {
  max-width: 88%;
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  animation: ai-in .2s ease-out
}

.ai-msg.bot {
  align-self: flex-start;
  padding: 10px 13px;
  border-radius: 2px 12px 12px 12px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--ln);
  box-shadow: inset 3px 0 0 rgba(0, 245, 255, .55);
  color: var(--tx)
}

.ai-msg.user {
  align-self: flex-end;
  padding: 10px 13px;
  border-radius: 12px 12px 2px 12px;
  background: rgba(0, 245, 255, .12);
  border: 1px solid rgba(0, 245, 255, .28);
  color: #e5fdff
}

.ai-msg.error {
  border-color: rgba(248, 113, 113, .45);
  box-shadow: inset 3px 0 0 #f87171;
  color: #fecaca
}

.ai-msg p+p,
.ai-msg p+ul,
.ai-msg ul+p {
  margin-top: 7px
}

.ai-msg ul {
  padding-left: 16px
}

.ai-msg a {
  color: var(--a);
  text-underline-offset: 2px
}

.ai-msg code {
  background: rgba(255, 255, 255, .08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px
}

.ai-acts {
  display: flex;
  gap: 6px;
  margin-top: 8px
}

@keyframes ai-in {
  from {
    opacity: 0;
    transform: translateY(5px)
  }
}

/* Suggestions */
.ai-chips {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-top: 2px
}

.ai-chip {
  background: transparent;
  color: var(--a);
  border: 1px solid rgba(0, 245, 255, .35);
  border-radius: 8px;
  padding: 8px 12px;
  font: 500 12px inherit;
  text-align: left;
  cursor: pointer;
  transition: .2s
}

.ai-chip::before {
  content: "$ ";
  opacity: .55
}

.ai-chip:hover {
  background: rgba(0, 245, 255, .1)
}

/* Typing */
.ai-typing {
  display: flex;
  gap: 5px;
  padding: 14px 15px
}

.ai-typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--a);
  opacity: .3;
  animation: ai-blink 1.1s infinite
}

.ai-typing i:nth-child(2) {
  animation-delay: .18s
}

.ai-typing i:nth-child(3) {
  animation-delay: .36s
}

@keyframes ai-blink {
  40% {
    opacity: 1
  }
}

/* Input */
.ai-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--bg2);
  border-top: 1px solid var(--ln)
}

.ai-input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--ln);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--tx);
  font: 13px inherit;
  outline: none;
  transition: .2s
}

.ai-input::placeholder {
  color: #6b7280
}

.ai-input:focus {
  border-color: var(--a);
  box-shadow: 0 0 0 3px rgba(0, 245, 255, .1)
}

.ai-send {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--a);
  color: #06121a;
  cursor: pointer;
  transition: .2s
}

.ai-send svg {
  width: 16px;
  height: 16px
}

.ai-send:disabled {
  opacity: .35;
  cursor: not-allowed
}

.ai-foot {
  padding: 0 14px 10px;
  background: var(--bg2);
  font-size: 9.5px;
  color: #6b7280
}

.ai-launcher:focus-visible,
.ai-btn:focus-visible,
.ai-chip:focus-visible,
.ai-send:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px
}

@media (max-width:600px) {
  .ai-launcher {
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: 54px;
    height: 54px
  }

  .ai-launcher-tip {
    display: none
  }

  /* Large chat window, nearly full screen */
  .ai-panel {
    right: 8px;
    left: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
    height: calc(100dvh - 80px);
    max-height: calc(100dvh - 80px);
    border-radius: 16px;
    transform-origin: bottom right
  }

  .ai-input {
    font-size: 16px
  }
}

@media (prefers-reduced-motion:reduce) {

  .ai-panel,
  .ai-launcher,
  .ai-log {
    transition: none !important;
    scroll-behavior: auto
  }

  .ai-launcher,
  .ai-msg {
    animation: none
  }

  .ai-typing i {
    animation: none;
    opacity: .7
  }
}