.juan-chat {
  --chat-bg: #fffaf2;
  --chat-ink: #433629;
  --chat-muted: #847360;
  --chat-line: #e9dece;
  --chat-bubble: #f3ebdf;
  color: var(--chat-ink);
  font-size: 14px;
  line-height: 1.6;
}
[data-user-color-scheme="dark"] .juan-chat {
  --chat-bg: #282923;
  --chat-ink: #f0e8db;
  --chat-muted: #bbae9a;
  --chat-line: #49463c;
  --chat-bubble: #36372e;
}
.juan-chat [hidden] { display: none !important; }
.juan-chat button { font: inherit; cursor: pointer; }
.juan-chat-launcher {
  position: fixed;
  z-index: 1050;
  width: 72px;
  height: 76px;
  padding: 0;
  border: 0;
  background: transparent;
  touch-action: none;
  user-select: none;
  filter: drop-shadow(0 5px 7px #43362938);
  cursor: grab !important;
}
.juan-chat-launcher:active { cursor: grabbing !important; }
.juan-chat-launcher svg { display: block; width: 100%; height: 100%; pointer-events: none; }
.juan-chat-launcher:hover svg { transform: rotate(-7deg); }
.juan-chat-panel {
  position: fixed;
  z-index: 1051;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 24px));
  height: min(540px, calc(100dvh - 32px));
  border: 1px solid var(--chat-line);
  border-radius: 20px;
  background: var(--chat-bg);
  box-shadow: 0 16px 60px #0003;
  overflow: hidden;
}
.juan-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--chat-line);
}
.juan-chat-heading { margin: 0; font-size: 17px; font-weight: 700; }
.juan-chat-caption { margin: 3px 0 0; font-size: 12px; color: var(--chat-muted); }
.juan-chat-close {
  border: 0;
  border-radius: 50%;
  background: var(--chat-bubble);
  color: var(--chat-ink);
  width: 36px;
  height: 36px;
  font-size: 24px !important;
  flex-shrink: 0;
}
.juan-chat-messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px; }
.juan-chat-welcome { margin-bottom: 20px; }
.juan-chat-welcome strong { font-size: 18px; }
.juan-chat-welcome p { color: var(--chat-muted); margin: 8px 0 12px; }
.juan-chat-suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.juan-chat-suggestions button {
  padding: 6px 10px;
  border: 1px solid var(--chat-line);
  border-radius: 12px;
  background: transparent;
  color: var(--chat-ink);
}
.juan-chat-message { margin: 0 0 16px; }
.juan-chat-message-label { margin: 0 0 4px; font-size: 11px; color: var(--chat-muted); }
.juan-chat-message-text {
  border-radius: 14px 14px 14px 3px;
  padding: 10px 12px;
  background: var(--chat-bubble);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.juan-chat-message.is-user { margin-left: 28px; }
.juan-chat-message.is-user .juan-chat-message-label { text-align: right; }
.juan-chat-message.is-user .juan-chat-message-text { background: #ead5ad; color: #433629; border-radius: 14px 14px 3px 14px; }
.juan-chat-message-note { font-size: 12px; color: var(--chat-muted); margin: 5px 0 0; }
.juan-chat-form { border-top: 1px solid var(--chat-line); padding: 12px 16px 14px; }
.juan-chat-input {
  display: block;
  width: 100%;
  resize: none;
  min-height: 66px;
  padding: 10px 12px;
  border: 1px solid var(--chat-line);
  border-radius: 12px;
  background: var(--chat-bg);
  color: var(--chat-ink);
  font: inherit;
}
.juan-chat-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }
.juan-chat-status { color: var(--chat-muted); font-size: 11px; }
.juan-chat-send, .juan-chat-stop { border: 0; border-radius: 10px; background: #68543b; color: #fffaf2; padding: 7px 14px; flex-shrink: 0; }
.juan-chat button:disabled { opacity: .55; cursor: default; }
@media (max-width: 600px) {
  .juan-chat-panel { left: 12px !important; right: 12px; top: auto !important; bottom: max(12px, env(safe-area-inset-bottom)); width: auto; height: min(580px, calc(100dvh - 24px)); }
  .juan-chat-input { font-size: 16px; }
}
