:root {
  --lemai-orange: #ff9a3d;
  --lemai-red: #e0293e;
  --lemai-gradient: linear-gradient(135deg, var(--lemai-orange), var(--lemai-red));
}

body.lemai-dark-mode {
  background-color: #121212;
  color: #ffffff;
}

/* --- Floating launcher --- */
.lemai-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--lemai-gradient);
  box-shadow: 0 6px 18px rgba(224, 41, 62, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100000;
  transition: transform 0.15s ease;
}
.lemai-launcher:hover {
  transform: scale(1.06);
}
.lemai-launcher-icon {
  font-size: 26px;
}
.lemai-launcher.lemai-hidden {
  display: none;
}

/* --- Panel --- */
.lemai-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 48px);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100000;
  font-family: inherit;
}
.lemai-panel.lemai-hidden {
  display: none;
}
.lemai-dark-mode .lemai-panel {
  background: #1e1e1e;
  color: #f0f0f0;
}

.lemai-header {
  background: var(--lemai-gradient);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.lemai-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.lemai-header-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.lemai-header-text {
  min-width: 0;
}
.lemai-header-title {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}
.lemai-header-subtitle {
  font-size: 11px;
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lemai-brand-lem {
  color: #fff;
}
.lemai-brand-ai {
  color: #fff2c8;
}
.lemai-header-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.lemai-icon-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 15px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.lemai-icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lemai-chatbox {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #faf7f5;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lemai-dark-mode .lemai-chatbox {
  background: #161616;
}

.lemai-message {
  max-width: 84%;
  padding: 10px 13px;
  border-radius: 14px;
  line-height: 1.4;
  font-size: 14px;
  animation: lemaiFadeIn 0.25s ease-in-out;
  word-wrap: break-word;
}
.lemai-message table {
  max-width: 100%;
  font-size: 12px;
}
.lemai-message-user {
  align-self: flex-end;
  background: var(--lemai-gradient);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.lemai-message-bot {
  align-self: flex-start;
  background: #fff;
  color: #222;
  border: 1px solid #eee2dc;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 8px;
}
.lemai-dark-mode .lemai-message-bot {
  background: #2a2a2a;
  color: #f0f0f0;
  border-color: #3a3a3a;
}
.lemai-message-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--lemai-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

@keyframes lemaiFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.lemai-typing {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 0 14px 8px;
  font-size: 12px;
  color: #999;
  flex-shrink: 0;
}
.lemai-typing-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--lemai-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.lemai-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #eee2dc;
  flex-shrink: 0;
}
.lemai-dark-mode .lemai-input-row {
  border-top-color: #3a3a3a;
}
.lemai-input {
  flex: 1;
  border: 1px solid #e2d8d2;
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  background: #fff;
  color: #222;
}
.lemai-input:focus {
  border-color: var(--lemai-red);
}
.lemai-dark-mode .lemai-input {
  background: #2a2a2a;
  border-color: #444;
  color: #f0f0f0;
}
.lemai-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--lemai-gradient);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
.lemai-send-btn:hover {
  transform: scale(1.08);
}

@media (max-width: 480px) {
  .lemai-panel {
    right: 8px;
    left: 8px;
    bottom: 8px;
    width: auto;
    height: calc(100vh - 16px);
  }
  .lemai-launcher {
    right: 16px;
    bottom: 16px;
  }
}
