/* Live Support — green + white (match app theme) */
.chat-fab {
  position: fixed;
  right: 16px;
  bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 6500;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid #8dc63f;
  background: linear-gradient(145deg, #ffffff, #d6ebbc);
  box-shadow: 0 10px 28px rgba(60, 100, 30, 0.22), 0 0 14px rgba(141, 198, 63, 0.28);
  cursor: grab;
  display: grid;
  place-items: center;
  touch-action: none;
  user-select: none;
  padding: 0;
  overflow: visible;
}
.chat-fab.hidden { display: none !important; }
.chat-fab-mascot {
  width: 60px;
  height: 60px;
  object-fit: cover;
  object-position: center 28%;
  pointer-events: none;
  border-radius: 50%;
}
.chat-fab .badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #ff4d4d;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.chat-fab .badge.show { display: flex; }

.chat-panel {
  position: fixed;
  right: 12px;
  bottom: calc(82px + env(safe-area-inset-bottom));
  z-index: 6600;
  width: min(360px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  height: min(500px, 72dvh);
  display: none;
  flex-direction: column;
  background: linear-gradient(180deg, #f7fbf2, #e2f0cc);
  border: 1px solid rgba(90, 140, 40, 0.22);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(60, 100, 30, 0.18);
  animation: chatIn 0.25s ease;
  box-sizing: border-box;
}
.chat-panel.open { display: flex; }
@keyframes chatIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, #6faa28, #8dc63f 55%, #b6e85a);
  color: #0b1a0a;
}
.chat-head h3 {
  font-family: 'Sora', sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  margin: 0;
}
.chat-head button {
  border: 0;
  background: rgba(255, 255, 255, 0.35);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  color: #0b1a0a;
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  background:
    radial-gradient(ellipse at top, rgba(141, 198, 63, 0.2), transparent 55%),
    linear-gradient(180deg, #f4faec, #e4f0d6);
}

.chat-bubble {
  max-width: min(82%, calc(100% - 12px));
  padding: 0.65rem 0.8rem;
  border-radius: 14px;
  font-size: 0.86rem;
  line-height: 1.4;
  word-break: break-word;
  box-sizing: border-box;
  overflow: hidden;
}
.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #8dc63f, #6faa28);
  color: #0b1a0a;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(95, 160, 32, 0.22);
}
.chat-bubble.admin {
  align-self: flex-start;
  background: linear-gradient(135deg, #ffffff, #f0f7e6);
  color: #142016;
  border: 1px solid rgba(90, 140, 40, 0.18);
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 12px rgba(60, 100, 30, 0.06);
}
.chat-meta {
  display: block;
  font-size: 0.62rem;
  opacity: 0.65;
  margin-top: 0.25rem;
}
.chat-img {
  display: block;
  max-width: min(220px, 70vw);
  max-height: 180px;
  width: auto;
  height: auto;
  border-radius: 10px;
  margin: 0 0 0.35rem;
  object-fit: cover;
  cursor: pointer;
  background: rgba(90, 140, 40, 0.08);
  border: 1px solid rgba(90, 140, 40, 0.14);
}
.chat-voice {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: min(220px, 100%);
  min-width: 0;
  box-sizing: border-box;
}
.chat-voice span { font-size: 0.75rem; opacity: 0.85; color: #2f7a18; }
.chat-voice audio {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 32px;
}

.chat-foot {
  display: flex;
  gap: 0.35rem;
  padding: 0.7rem;
  border-top: 1px solid rgba(90, 140, 40, 0.18);
  background: linear-gradient(180deg, #f7fbf2, #dcebc8);
  align-items: center;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
}
.chat-tool-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(90, 140, 40, 0.28);
  border-radius: 50%;
  background: linear-gradient(145deg, #ffffff, #e2f0cc);
  color: #2f7a18;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.chat-tool-btn:active { transform: scale(0.96); }
.chat-tool-btn.recording {
  background: rgba(185, 28, 28, 0.2);
  border-color: #ff4d4d;
  color: #c0392b;
  animation: chatPulse 1s infinite;
}
@keyframes chatPulse {
  50% { box-shadow: 0 0 0 6px rgba(255, 77, 77, 0.18); }
}
.chat-foot input[type="text"] {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(90, 140, 40, 0.22);
  background: linear-gradient(180deg, #ffffff, #f3f9ea);
  color: #142016;
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  outline: none;
  font-size: 16px;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.chat-foot input[type="text"]::placeholder {
  color: rgba(79, 102, 72, 0.5);
}
.chat-foot input[type="text"]:focus {
  border-color: #7cbc34;
  box-shadow: 0 0 0 3px rgba(122, 188, 52, 0.18);
}
.chat-foot button[type="submit"] {
  border: 0;
  background: linear-gradient(135deg, #8dc63f, #6faa28);
  color: #0b1a0a;
  font-weight: 700;
  border-radius: 12px;
  padding: 0 0.95rem;
  height: 38px;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(95, 160, 32, 0.25);
}
