/* Chat widget — themed via CSS variables */

.lb-chat-launch {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-right: env(safe-area-inset-right, 0);
}
.lb-chat-launch #lb-chat-btn { pointer-events: auto; }
.lb-chat-prompt {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: 14rem;
  text-align: right;
  margin-bottom: 0.15rem;
  padding-right: 2px;
  pointer-events: none;
}
.lb-chat-hint {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1.5;
}
.lb-chat-hint-line1 { display: block; color: var(--text-accent-dim); }
.lb-chat-arrow-svg { width: 7.85rem; margin: 0.25rem 1rem 0 0; }
.lb-chat-arrow-svg path { stroke: var(--text-accent); }

#lb-chat-btn {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--chat-btn-bg);
  border: 2px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--chat-btn-shadow);
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s;
  margin-top: 2px;
  flex-shrink: 0;
}
[data-theme="light"] #lb-chat-btn { border-color: var(--c-ink); }
#lb-chat-btn:hover { transform: scale(1.08) translateY(-2px); }
#lb-chat-btn img { width: 36px; height: 36px; border-radius: 8px; }
.lb-notif {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: var(--accent-hot);
  border-radius: 50%;
  border: 2px solid var(--bg);
  animation: lb-pulse 2s ease infinite;
  pointer-events: none;
  z-index: 1;
}
@keyframes lb-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

#lb-win {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  z-index: 10000;
  width: 360px;
  max-height: 540px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  transform: scale(0.9) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s var(--ease-out), opacity 0.3s ease;
  overflow: hidden;
}
[data-theme="light"] #lb-win {
  border-width: 2px;
  border-color: var(--c-ink);
  box-shadow: 6px 6px 0 var(--c-cyan);
}
#lb-win.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}
.lb-hdr {
  padding: 1rem 1.25rem;
  background: var(--bg-mid);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.lb-hdr img { width: 32px; height: 32px; border-radius: 8px; }
.lb-hdr-name {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--text-accent);
}
.lb-hdr-sub {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.lb-dot { width: 6px; height: 6px; border-radius: 50%; background: #4ade80; }
#lb-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
}
#lb-close:hover { color: var(--text-accent); }
#lb-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.lb-m { display: flex; flex-direction: column; max-width: 88%; animation: lb-in 0.3s ease; }
@keyframes lb-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.lb-m.bot { align-self: flex-start; }
.lb-m.usr { align-self: flex-end; }
.lb-b {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.65;
}
.bot .lb-b {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.usr .lb-b {
  background: var(--text-accent);
  color: var(--btn-primary-text);
  font-weight: 500;
  border-bottom-right-radius: 4px;
}
[data-theme="light"] .usr .lb-b { background: var(--c-ink); color: var(--bg); }
.lb-typing {
  display: flex;
  gap: 4px;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.lb-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: lb-b 1.2s ease infinite;
}
.lb-typing span:nth-child(2) { animation-delay: 0.2s; }
.lb-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes lb-b {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}
.lb-foot {
  padding: 0.85rem 1rem;
  background: var(--bg-mid);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.6rem;
}
#lb-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  outline: none;
  resize: none;
  max-height: 80px;
}
#lb-input:focus { border-color: var(--text-accent); }
#lb-send {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--text-accent);
  border: none;
  cursor: pointer;
  color: var(--btn-primary-text);
  font-size: 1rem;
}
@media (max-width: 480px) {
  #lb-win {
    width: calc(100vw - 2rem);
    right: 1rem;
    bottom: calc(5rem + env(safe-area-inset-bottom, 0));
  }
  .lb-chat-launch {
    bottom: calc(1rem + env(safe-area-inset-bottom, 0));
    right: calc(1rem + env(safe-area-inset-right, 0));
  }
  .lb-chat-prompt { max-width: 11rem; }
  .lb-chat-hint { font-size: 0.52rem; letter-spacing: 0.09em; }
  .lb-chat-arrow-svg { width: 6.6rem; margin-right: 0.85rem; }
}
