@keyframes kt-fadein { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }
@keyframes kt-dot    { 0%,80%,100%{transform:scale(.7);opacity:.4} 40%{transform:scale(1);opacity:1} }
@keyframes kt-scan   { 0%{top:-10%} 100%{top:110%} }
@keyframes kt-blink  { 0%,49%{opacity:1} 50%,100%{opacity:0} }

/* ── Trigger pill — bottom right ──────────────────────────────── */
#kt-btn {
  position: fixed; bottom: 28px; right: 28px; z-index: 9000;
  height: 44px; padding: 0 18px 0 12px; border-radius: 0;
  background: #000; border: 1px solid #00ff41; color: #00ff41;
  font-family: 'Fira Code', monospace; font-size: .78rem; font-weight: 600;
  letter-spacing: 0.1em; cursor: pointer;
  display: flex; align-items: center; gap: 9px;
  box-shadow: 0 0 18px rgba(0,255,65,.45), 0 4px 20px rgba(0,0,0,.7);
  transition: box-shadow .2s, background .2s;
}
#kt-btn:hover { box-shadow: 0 0 30px rgba(0,255,65,.7); background: rgba(0,255,65,.05); }
#kt-btn .kt-pulse { width: 7px; height: 7px; background: #00ff41; border-radius: 50%; box-shadow: 0 0 6px #00ff41; animation: pulse 2s infinite; flex-shrink: 0; }

/* ── Terminal window — bottom right ───────────────────────────── */
#kt-panel {
  position: fixed; bottom: 84px; right: 28px; z-index: 9001;
  width: 400px; max-width: calc(100vw - 40px);
  background: #000;
  border: 1px solid #00ff41;
  box-shadow: 0 0 0 1px rgba(0,255,65,.08), 0 0 32px rgba(0,255,65,.2), 0 20px 60px rgba(0,0,0,.9);
  display: flex; flex-direction: column;
  font-family: 'Fira Code', monospace;
  overflow: hidden;
  background-image: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,255,65,.03) 2px, rgba(0,255,65,.03) 4px);
  transform-origin: bottom right;
  transform: scale(0.96) translateY(10px);
  opacity: 0; pointer-events: none;
  transition: transform .22s cubic-bezier(.22,1,.36,1), opacity .18s ease;
}
#kt-panel.open { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; }

/* moving scanline */
#kt-panel::after {
  content: ''; pointer-events: none;
  position: absolute; left: 0; right: 0; height: 40px;
  background: linear-gradient(transparent, rgba(0,255,65,.04), transparent);
  animation: kt-scan 4s linear infinite; z-index: 2;
}

/* ── Title bar ────────────────────────────────────────────────── */
#kt-hdr {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: rgba(0,20,0,1);
  border-bottom: 1px solid rgba(0,255,65,.2); flex-shrink: 0;
}
.kt-wdot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.kt-wdot.r { background: #ff5f57; }
.kt-wdot.y { background: #febc2e; }
.kt-wdot.g { background: #28c840; }
#kt-hdr-title { flex: 1; text-align: center; font-size: .7rem; color: #00ff41; letter-spacing: .1em; text-shadow: 0 0 6px rgba(0,255,65,.6); margin-left: -28px; }
#kt-close { background: none; border: none; color: #4a7a52; cursor: pointer; font-size: .85rem; font-family: inherit; padding: 0; transition: color .15s; flex-shrink: 0; }
#kt-close:hover { color: #ff5555; }

/* ── Messages ─────────────────────────────────────────────────── */
#kt-msgs {
  flex: 1; overflow-y: auto; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 220px; max-height: 340px;
}
#kt-msgs::-webkit-scrollbar { width: 3px; }
#kt-msgs::-webkit-scrollbar-thumb { background: rgba(0,255,65,.2); }

.kt-m { font-size: .76rem; line-height: 1.6; white-space: pre-wrap; word-break: break-word; animation: kt-fadein .18s ease; }
.kt-m.agent { color: #00ff41; text-shadow: 0 0 5px rgba(0,255,65,.35); }
.kt-m.agent::before { content: '> '; color: rgba(0,255,65,.4); }
.kt-m.user  { color: #a8ffb0; text-align: right; }
.kt-m.user::after { content: ' <'; color: rgba(168,255,176,.4); }
.kt-m.sys   { color: rgba(0,255,65,.35); font-size: .68rem; }

/* typing */
.kt-m.typing::before { content: '> '; color: rgba(0,255,65,.4); }
.kt-dots { display: inline-flex; gap: 4px; align-items: center; vertical-align: middle; }
.kt-dots span { width:5px;height:5px;background:#00ff41;border-radius:50%;animation:kt-dot 1.2s infinite ease-in-out; }
.kt-dots span:nth-child(2){animation-delay:.2s} .kt-dots span:nth-child(3){animation-delay:.4s}

/* ── Quick commands ───────────────────────────────────────────── */
#kt-chips { padding: 0 14px 10px; flex-shrink: 0; display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid rgba(0,255,65,.1); padding-top: 10px; }
.kt-chip {
  font-size: .67rem; padding: 3px 8px; border: 1px solid rgba(0,255,65,.25);
  color: rgba(0,255,65,.7); background: transparent; font-family: 'Fira Code', monospace;
  cursor: pointer; letter-spacing: .04em; transition: all .15s; white-space: nowrap;
}
.kt-chip:hover { background: rgba(0,255,65,.1); color: #00ff41; border-color: rgba(0,255,65,.5); box-shadow: 0 0 6px rgba(0,255,65,.2); }

/* ── Input ────────────────────────────────────────────────────── */
#kt-footer {
  display: flex; align-items: center;
  padding: 8px 12px; border-top: 1px solid rgba(0,255,65,.18);
  background: rgba(0,10,0,.9); flex-shrink: 0; gap: 6px;
}
#kt-prompt { color: rgba(0,255,65,.6); font-size: .74rem; white-space: nowrap; flex-shrink: 0; user-select: none; }
#kt-input { flex: 1; background: transparent; border: none; outline: none; color: #00ff41; font-family: 'Fira Code', monospace; font-size: .76rem; caret-color: #00ff41; }
#kt-input::placeholder { color: rgba(0,255,65,.18); }
#kt-send { background: none; border: 1px solid rgba(0,255,65,.3); color: #00ff41; font-family: 'Fira Code', monospace; font-size: .68rem; padding: 3px 9px; cursor: pointer; letter-spacing: .08em; text-transform: uppercase; transition: background .15s, box-shadow .15s; flex-shrink: 0; }
#kt-send:hover { background: rgba(0,255,65,.1); box-shadow: 0 0 8px rgba(0,255,65,.3); }
#kt-send:disabled { opacity: .3; cursor: not-allowed; }
