/* Кариша — плавающий ассистент v2 */
.karisha-widget {
  position: fixed;
  right: 8px;
  bottom: 72px;
  z-index: 1200;
  pointer-events: none;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
.karisha-widget * { box-sizing: border-box; }

.karisha-fab {
  pointer-events: auto;
  width: 120px;
  height: auto;
  max-height: 220px;
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 0;
  display: block;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,0.4));
  transition: transform .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.karisha-fab img {
  width: 120px;
  height: auto;
  display: block;
  user-select: none;
  pointer-events: none;
}
.karisha-fab:active { transform: scale(0.96); }
.karisha-fab:hover { transform: translateY(-3px); }

.karisha-panel {
  pointer-events: auto;
  display: none;
  position: fixed;
  right: 10px;
  bottom: 72px;
  width: min(380px, calc(100vw - 16px));
  max-height: min(80vh, 580px);
  background: rgba(18, 14, 28, 0.97);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  overflow: hidden;
  flex-direction: column;
  z-index: 1201;
  backdrop-filter: blur(12px);
}
.karisha-widget.is-open .karisha-panel { display: flex; }
.karisha-widget.is-open .karisha-fab { display: none; }

.karisha-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
/* половина тела: лицо, причёска, плечи */
.karisha-avatar-wrap {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  overflow: hidden;
  flex-shrink: 0;
  background: #1a1224;
  border: 1px solid rgba(255,255,255,0.1);
}
.karisha-avatar {
  width: 100%;
  height: 145%;
  object-fit: cover;
  object-position: center 8%;
  display: block;
}
.karisha-head-text { flex: 1; min-width: 0; }
.karisha-name {
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff;
  line-height: 1.2;
}
.karisha-sub {
  font-size: 0.75rem;
  opacity: 0.7;
  color: #ddd;
  margin-top: 2px;
}

.karisha-feed {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 140px;
}
.karisha-bubble {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
}
.karisha-bubble.bot {
  align-self: flex-start;
  background: rgba(120, 90, 200, 0.22);
  color: #f2eeff;
  border: 1px solid rgba(160,130,255,0.2);
}
.karisha-bubble.user {
  align-self: flex-end;
  background: rgba(60, 140, 255, 0.22);
  color: #eaf3ff;
  border: 1px solid rgba(100,170,255,0.25);
}
.karisha-bubble.sys {
  align-self: center;
  background: transparent;
  opacity: 0.65;
  font-size: 0.8rem;
  text-align: center;
}

.karisha-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.karisha-form input[type="text"] {
  flex: 1;
  min-width: 0;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: #fff;
  padding: 11px 12px;
  font-size: 0.95rem;
  outline: none;
}
.karisha-form input::placeholder { color: rgba(255,255,255,0.4); }
.karisha-form button.send {
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #7b5cff, #4a6bff);
  color: #fff;
  font-weight: 700;
  padding: 0 14px;
  cursor: pointer;
  white-space: nowrap;
}

.karisha-actions {
  display: flex;
  gap: 8px;
  padding: 0 12px 12px;
  flex-shrink: 0;
}
.karisha-actions button {
  flex: 1;
  border-radius: 11px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: #eee;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 10px 8px;
  cursor: pointer;
}
.karisha-actions button.hide-btn {
  border-color: rgba(255,160,80,0.35);
  color: #ffc58a;
}

@media (max-width: 480px) {
  .karisha-widget { bottom: 64px; right: 4px; }
  .karisha-fab { width: 100px; }
  .karisha-fab img { width: 100px; }
  .karisha-panel {
    right: 6px;
    left: 6px;
    width: auto;
    bottom: 64px;
    max-height: min(74vh, 540px);
  }
  .karisha-avatar-wrap { width: 64px; height: 64px; }
}
body.has-bottom-nav .karisha-widget,
body .karisha-widget {
  bottom: max(72px, env(safe-area-inset-bottom, 0px) + 56px);
}
