/* ==========================================================================
   Karishma — chat widget
   Loaded on every page, after site.css so it can use the theme tokens.
   ========================================================================== */

.karishma-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 95;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px 13px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 10px 30px -10px rgba(11, 28, 44, .5), 0 2px 6px rgba(11, 28, 44, .2);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
}
.karishma-launcher:hover {
  transform: translateY(-2px);
  background: var(--green-deep);
  box-shadow: 0 16px 36px -12px rgba(11, 28, 44, .55);
}
.karishma-launcher svg { flex: none; }
.karishma-launcher__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green-bright);
  box-shadow: 0 0 0 3px rgba(62, 155, 69, .25);
}
.karishma-launcher[hidden] { display: none; }

.karishma-panel {
  position: fixed;
  right: 20px;
  bottom: 88px;
  z-index: 96;
  display: none;
  flex-direction: column;
  width: 386px;
  max-height: min(638px, calc(100dvh - 130px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 30px 70px -24px rgba(11, 28, 44, .45);
}
.karishma-panel.is-open { display: flex; }

.karishma-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--ink);
  color: #fff;
}
.karishma-head__avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--green);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  flex: none;
}
.karishma-head__meta { display: flex; flex-direction: column; line-height: 1.2; }
.karishma-head__name { font-size: 15px; font-weight: 600; }
.karishma-head__sub {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .08em;
  color: #B9C6D0;
  text-transform: uppercase;
}
.karishma-head__actions { margin-left: auto; display: flex; gap: 4px; }
.karishma-head button {
  white-space: nowrap;
  background: transparent;
  border: 0;
  color: #fff;
  opacity: .72;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  font-size: 12px;
}
.karishma-head button:hover { opacity: 1; background: rgba(255, 255, 255, .12); }

.karishma-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--paper);
  overscroll-behavior: contain;
}
.km-msg {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.km-msg--bot {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  color: var(--ink-2);
}
.km-msg--user {
  align-self: flex-end;
  background: var(--green-deep);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.km-typing { display: inline-flex; gap: 4px; align-items: center; height: 12px; }
.km-typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted);
  animation: km-bounce 1.2s infinite ease-in-out;
}
.km-typing i:nth-child(2) { animation-delay: .15s; }
.km-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes km-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.km-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.km-chip {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  min-height: 34px;
}
.km-chip:hover { border-color: var(--green-deep); color: var(--green-deep); }

.karishma-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.karishma-form textarea {
  flex: 1;
  resize: none;
  height: 44px;
  max-height: 120px;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  font-family: var(--sans);
  font-size: 16px;          /* 16px stops iOS zooming on focus */
  line-height: 1.4;
  color: var(--ink);
  background: var(--paper);
}
.karishma-form textarea:focus {
  outline: none;
  border-color: var(--green-deep);
  box-shadow: 0 0 0 3px rgba(62, 155, 69, .16);
}
.karishma-send {
  width: 44px; height: 44px;
  border: 0;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  display: grid; place-items: center;
  flex: none;
}
.karishma-send:hover { background: var(--green-deep); }
.karishma-send:disabled { opacity: .5; cursor: default; }
.karishma-foot {
  padding: 8px 12px 12px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .06em;
  color: var(--muted);
  background: var(--surface);
  border-top: 0;
}
.karishma-foot a { text-decoration: underline; }



/* hidden must win over the display rules below */
.karishma-form[hidden],
.karishma-closed[hidden] { display: none !important; }

/* Closed state: the composer is replaced by a way back in */
.karishma-closed {
  padding: 16px 14px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  text-align: center;
}
.karishma-closed p {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}
.karishma-reopen {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background .16s var(--ease);
}
.karishma-reopen:hover { background: var(--green-deep); }

@media (max-width: 640px) {
  .karishma-launcher { right: 14px; bottom: 14px; padding: 12px 16px; }
  .karishma-launcher__text { display: none; }
  .karishma-launcher { padding: 14px; }
  .karishma-panel {
    right: 0; left: 0; bottom: 0;
    width: auto;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
    border: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .karishma-launcher, .karishma-launcher:hover { transform: none; }
  .km-typing i { animation: none; }
}
