/* ============================================================
   PIP — the ghost guide bot (FAB + panel)
   ============================================================ */

.pip-fab {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 200;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 4px solid var(--ink);
  background: var(--red);
  color: var(--paper);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 5px 5px 0 var(--ink);
  transition: transform 0.2s ease;
}
.pip-fab:hover { transform: translate(-2px, -2px) rotate(-4deg); }
body.phantom .pip-fab { background: #11161f; color: var(--ink); }
.pip-fab__ghost { width: 38px; height: 38px; }

.pip-fab__burst {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 4px solid var(--gold);
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}
.pip-fab.is-pinging .pip-fab__burst {
  animation: pipPing 0.7s ease-out;
}
@keyframes pipPing {
  0% { opacity: 0.9; transform: scale(0.85); }
  100% { opacity: 0; transform: scale(1.55); }
}
.pip-fab__ping {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 3px solid var(--red);
  opacity: 0;
  pointer-events: none;
}
.pip-fab.is-open .pip-fab__ping { display: none; }

/* hello bubble */
.pip-hello {
  position: fixed;
  right: 100px;
  bottom: 34px;
  z-index: 199;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 14px 14px 4px 14px;
  box-shadow: 4px 4px 0 var(--ink);
  font-family: var(--font-hand);
  font-size: 16px;
  padding: 10px 16px;
  max-width: 250px;
  opacity: 0;
  transform: translateY(8px) rotate(-1deg);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.pip-hello strong { color: var(--red); }
.pip-hello.is-on { opacity: 1; transform: translateY(0) rotate(-1deg); }

/* panel */
.pip {
  position: fixed;
  right: 26px;
  bottom: 104px;
  z-index: 201;
  width: min(92vw, 380px);
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 5px solid var(--ink);
  border-radius: 18px;
  box-shadow: 10px 10px 0 var(--ink);
  overflow: hidden;
}
/* display:flex above would beat the UA's [hidden] rule — the panel could
   never actually close. This makes `hidden` win again. */
.pip[hidden] { display: none !important; }
.pip__halftone {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, var(--ink) 1.1px, transparent 1.2px);
  background-size: 12px 12px;
  opacity: 0.05;
  pointer-events: none;
}

.pip__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--red);
  border-bottom: 4px solid var(--ink);
}
body.phantom .pip__bar { background: #11161f; }
.pip__id { display: flex; align-items: baseline; gap: 10px; }
.pip__title {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.06em;
  color: var(--paper);
}
body.phantom .pip__title { color: var(--ink); }
.pip__role {
  font-family: var(--font-hand);
  font-size: 13px;
  color: var(--paper);
  opacity: 0.85;
}
body.phantom .pip__role { color: var(--ink); }
.pip__close {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
}
.pip__close:hover { transform: translate(-1px, -1px); }

.pip__log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: none;
}
.pip__log::-webkit-scrollbar { display: none; }

.pip__msg {
  max-width: 86%;
  padding: 10px 14px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.45;
  background: var(--paper);
}
.pip__msg p + p { margin-top: 6px; }
.pip__msg--bot {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 3px 3px 0 var(--ink);
}
.pip__msg--user {
  align-self: flex-end;
  background: var(--gold);
  border-bottom-right-radius: 4px;
  box-shadow: 3px 3px 0 var(--ink);
}
.pip__msg--err {
  align-self: flex-start;
  background: var(--red);
  color: var(--paper);
  border-bottom-left-radius: 4px;
}

.pip__typing { display: flex; align-items: center; gap: 5px; }
.pip__thinking {
  font-family: var(--font-hand);
  margin-right: 4px;
}
.pip__typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink);
  animation: pipBounce 1s infinite ease-in-out;
}
.pip__typing span:nth-child(3) { animation-delay: 0.15s; }
.pip__typing span:nth-child(4) { animation-delay: 0.3s; }
@keyframes pipBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-5px); opacity: 1; }
}

.pip__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  border-top: 3px solid var(--ink);
}
.pip__chips[hidden] { display: none; }
.pip__chips button {
  font-family: var(--font-comic);
  font-size: 15px;
  letter-spacing: 0.06em;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 4px 14px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform 0.12s ease;
}
.pip__chips button:hover { transform: translate(-1px, -1px); background: var(--gold); }

.pip__form {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 3px solid var(--ink);
  background: var(--paper-dark);
}
.pip__input {
  flex: 1;
  border: 3px solid var(--ink);
  border-radius: 10px;
  padding: 9px 12px;
  font-family: var(--font-body);
  font-size: 14.5px;
  background: var(--paper);
  color: var(--ink);
  outline: none;
}
.pip__input:focus { border-color: var(--red); }
body.phantom .pip__input:focus { border-color: var(--ink); }
.pip__send {
  width: 44px;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: var(--red);
  color: var(--paper);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 2px 2px 0 var(--ink);
}
.pip__send svg { width: 20px; height: 20px; }
.pip__send:disabled { opacity: 0.55; cursor: wait; }
body.phantom .pip__send { background: #11161f; color: var(--ink); }

@media (max-width: 760px) {
  .pip-fab { right: 16px; bottom: 16px; width: 58px; height: 58px; }
  .pip { right: 10px; left: 10px; width: auto; bottom: 88px; }
  .pip-hello { right: 88px; bottom: 24px; }
}
