#esp-chat-widget {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  font-family: var(--md-text-font, -apple-system, BlinkMacSystemFont, sans-serif);
}

#esp-chat-toggle {
  background: var(--md-accent-fg-color, #E53935);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
#esp-chat-toggle:hover { filter: brightness(1.05); }

#esp-chat-panel {
  position: absolute;
  bottom: 3.4rem;
  right: 0;
  width: min(22rem, 92vw);
  height: min(32rem, 70vh);
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 0.75rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#esp-chat-panel.esp-chat-closed { display: none; }

#esp-chat-panel header {
  background: var(--md-accent-fg-color, #E53935);
  color: #fff;
  padding: 0.55rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.95rem;
}
#esp-chat-close {
  background: transparent;
  color: #fff;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}

#esp-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  background: #fafafa;
}

.esp-chat-msg {
  max-width: 85%;
  padding: 0.5rem 0.7rem;
  border-radius: 0.6rem;
  font-size: 0.88rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.esp-chat-user {
  align-self: flex-end;
  background: var(--md-accent-fg-color, #E53935);
  color: #fff;
}
.esp-chat-assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e2e2e2;
  color: #222;
}

#esp-chat-form {
  display: flex;
  border-top: 1px solid #eee;
  padding: 0.5rem;
  gap: 0.4rem;
  background: #fff;
}
#esp-chat-input {
  flex: 1;
  border: 1px solid #ccc;
  border-radius: 0.4rem;
  padding: 0.45rem 0.6rem;
  font-size: 0.88rem;
  outline: none;
}
#esp-chat-input:focus { border-color: var(--md-accent-fg-color, #E53935); }
#esp-chat-form button {
  background: var(--md-accent-fg-color, #E53935);
  color: #fff;
  border: none;
  border-radius: 0.4rem;
  padding: 0 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
