/* Koda — assistant koala */
.koda {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 80;
  font-family: var(--font-body);
  color: var(--ink);
}

.koda__launch {
  position: relative;
  width: 124px;
  height: 132px;
  padding: 0;
  filter: drop-shadow(0 16px 28px rgba(0, 0, 0, 0.45));
}

.koda__launch img {
  width: 124px;
  height: 124px;
  object-fit: contain;
  animation: koda-bob 3.4s ease-in-out infinite;
}

.koda__launch:hover img,
.koda__launch:focus-visible img {
  animation-play-state: paused;
  transform: translateY(-6px);
}

.koda__invite {
  position: absolute;
  right: calc(100% - 22px);
  top: 6px;
  padding: 0.42rem 0.75rem;
  border-radius: 999px;
  background: rgba(8, 16, 32, 0.92);
  border: 1px solid rgba(148, 176, 220, 0.22);
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.koda__invite::after {
  content: "";
  position: absolute;
  right: 14px;
  bottom: -6px;
  width: 10px;
  height: 10px;
  background: rgba(8, 16, 32, 0.92);
  border-right: 1px solid rgba(148, 176, 220, 0.22);
  border-bottom: 1px solid rgba(148, 176, 220, 0.22);
  transform: rotate(45deg);
}

.koda.is-open .koda__launch {
  display: none;
}

.koda__panel[hidden] {
  display: none !important;
}

.koda__panel {
  display: flex;
  flex-direction: column;
  width: min(400px, calc(100vw - 1.4rem));
  height: min(680px, calc(100dvh - 1.4rem));
  border-radius: 26px;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(43, 108, 255, 0.22), transparent 55%),
    rgba(7, 13, 24, 0.94);
  border: 1px solid rgba(148, 176, 220, 0.18);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(16px);
}

.koda.is-open .koda__panel {
  animation: koda-in 0.38s var(--ease);
}

.koda__stage {
  position: relative;
  height: 188px;
  flex: none;
  background: radial-gradient(circle at 50% 78%, rgba(32, 180, 140, 0.22), transparent 58%);
}

/* Ombre douce au sol, qui respire avec le flottement du koala */
.koda__stage::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 92px;
  height: 14px;
  margin-left: -46px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0));
  pointer-events: none;
  animation: koda-shadow 3.6s ease-in-out infinite;
}

.koda__actor {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center 8px;
  pointer-events: none;
  user-select: none;
  animation: koda-bob 3.6s ease-in-out infinite;
}

.koda__tools {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  display: flex;
  gap: 0.35rem;
}

.koda__tool {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(6, 10, 18, 0.55);
  border: 1px solid rgba(148, 176, 220, 0.18);
}

.koda__tool[aria-pressed="true"] {
  color: #06281f;
  background: #5eead4;
  border-color: transparent;
}

.koda__tool[aria-pressed="true"] .koda__slash {
  display: none;
}

.koda__side {
  position: absolute;
  top: 46%;
  z-index: 2;
}

.koda__side--mic { left: 0.55rem; }
.koda__side--spk { right: 0.55rem; }

.koda__tool.is-live {
  animation: koda-pulse 1.2s ease-out infinite;
}

.koda__prefs {
  display: grid;
  gap: 0.55rem;
  margin: 0 0.9rem 0.65rem;
  padding: 0.7rem 0.75rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(148, 176, 220, 0.14);
}

.koda__prefs[hidden] {
  display: none !important;
}

.koda__prefs label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.koda__prefs select {
  width: 62%;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(148, 176, 220, 0.22);
  border-radius: 8px;
  padding: 0.28rem 0.4rem;
}

.koda__prefs input[type="range"] {
  width: 62%;
  accent-color: #5eead4;
}

.koda__tool:hover,
.koda__tool:focus-visible,
.koda__send:hover,
.koda__send:focus-visible,
.koda__chips button:hover,
.koda__chips button:focus-visible {
  outline: none;
  border-color: rgba(94, 200, 255, 0.7);
}

.koda__id {
  margin-top: -0.35rem;
  padding: 0 1.1rem 0.35rem;
  text-align: center;
}

.koda__id strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: -0.03em;
}

.koda__id span {
  color: var(--muted);
  font-size: 0.78rem;
}

.koda__log {
  flex: 1;
  overflow: auto;
  padding: 0.35rem 0.9rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.koda__msg {
  display: flex;
}

.koda__msg p {
  margin: 0;
  max-width: 92%;
  padding: 0.65rem 0.8rem;
  border-radius: 16px;
  line-height: 1.45;
  font-size: 0.9rem;
}

.koda__msg--bot {
  justify-content: flex-start;
}

.koda__msg--bot p {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(148, 176, 220, 0.12);
  border-bottom-left-radius: 6px;
}

.koda__msg--user {
  justify-content: flex-end;
}

.koda__msg--user p {
  background: linear-gradient(180deg, #3b82ff, #2457d6);
  color: white;
  border-bottom-right-radius: 6px;
}

.koda__msg a {
  color: #9ae6ff;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.koda__jump {
  display: inline-flex;
  margin: 0.55rem 0.45rem 0 0;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(94, 200, 255, 0.35);
  color: #d7f4ff !important;
  text-decoration: none !important;
  font-size: 0.78rem;
}

.koda__typing p {
  display: flex;
  gap: 0.28rem;
  align-items: center;
  min-width: 3.2rem;
  min-height: 1.1rem;
}

.koda__typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9eb0cc;
  animation: koda-dot 1s ease-in-out infinite;
}

.koda__typing span:nth-child(2) { animation-delay: 0.15s; }
.koda__typing span:nth-child(3) { animation-delay: 0.3s; }

.koda__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 0.9rem 0.7rem;
}

.koda__chips[hidden] {
  display: none;
}

.koda__chips button {
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 176, 220, 0.2);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  font-size: 0.78rem;
}

.koda__form {
  display: flex;
  gap: 0.45rem;
  padding: 0.75rem;
  border-top: 1px solid rgba(148, 176, 220, 0.12);
}

.koda__form input {
  flex: 1;
  min-width: 0;
  border-radius: 999px;
  border: 1px solid rgba(148, 176, 220, 0.2);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  padding: 0.72rem 0.95rem;
  outline: none;
}

.koda__form input::placeholder {
  color: #7f90ab;
}

.koda__form input:focus {
  border-color: rgba(94, 200, 255, 0.65);
}

.koda__send {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: linear-gradient(180deg, #3b82ff, #2457d6);
}

@keyframes koda-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

@keyframes koda-shadow {
  0%, 100% { transform: scaleX(1); opacity: 1; }
  50% { transform: scaleX(0.84); opacity: 0.7; }
}

@keyframes koda-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes koda-dot {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

@keyframes koda-pulse {
  0% { box-shadow: 0 0 0 0 rgba(94, 234, 212, 0.55); }
  100% { box-shadow: 0 0 0 10px rgba(94, 234, 212, 0); }
}

@media (max-width: 720px) {
  .koda {
    right: 0.4rem;
    bottom: 0.35rem;
  }

  .koda__launch,
  .koda__launch img {
    width: 78px;
    height: 78px;
  }

  .koda__launch {
    height: 78px;
  }

  .koda__invite {
    left: 50%;
    right: auto;
    top: auto;
    bottom: calc(100% - 6px);
    transform: translateX(-50%);
    font-size: 0.75rem;
  }

  .koda__invite::after {
    left: 50%;
    right: auto;
    bottom: -5px;
    margin-left: -6px;
  }

  .hero__actions {
    padding-right: 4.75rem;
  }

  .koda__panel {
    width: calc(100vw - 0.8rem);
    height: min(720px, calc(100dvh - 0.8rem));
    border-radius: 22px;
  }

  .koda__stage {
    height: 150px;
  }

  .koda__stage::before {
    width: 74px;
    height: 11px;
    margin-left: -37px;
    bottom: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .koda__launch img,
  .koda__actor,
  .koda__stage::before,
  .koda.is-open .koda__panel,
  .koda__typing span,
  .koda__tool.is-live {
    animation: none;
  }
}
