/* luna copilot shell. tiny panel. big opinions */
#lunaCopilotBackdrop {
  position: fixed;
  inset: 0;
  z-index: 618;
  background: rgba(8, 10, 18, 0.42);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.32s ease;
}
#lunaCopilotBackdrop.show {
  opacity: 1;
  pointer-events: auto;
}
#lunaCopilotPanel {
  position: fixed;
  right: 20px;
  bottom: 96px;
  width: min(380px, calc(100vw - 24px));
  max-height: min(520px, calc(100vh - 120px));
  z-index: 620;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  overflow: hidden;
  background: var(--theme-tint, rgba(255, 255, 255, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(24px) saturate(190%);
  -webkit-backdrop-filter: blur(24px) saturate(190%);
  transform: translateY(16px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.36s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.32s ease;
}
#lunaCopilotPanel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}
.luna-copilot-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}
.luna-copilot-head img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}
.luna-copilot-head-text {
  flex: 1;
  min-width: 0;
}
.luna-copilot-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--theme-text, #1a1a1a);
}
.luna-copilot-sub {
  font-size: 0.78rem;
  color: var(--theme-text-secondary, #666);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#lunaCopilotClose {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  color: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
#lunaCopilotClose:hover {
  background: rgba(0, 0, 0, 0.1);
}
#lunaCopilotMessages {
  flex: 1;
  min-height: 120px;
  max-height: 320px;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.luna-copilot-msg {
  max-width: 92%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
}
.luna-copilot-msg.user {
  align-self: flex-end;
  background: rgba(72, 145, 255, 0.18);
  border: 1px solid rgba(100, 170, 255, 0.25);
}
.luna-copilot-msg.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.35);
}
.luna-copilot-msg.streaming::after {
  content: '▍';
  animation: lunaCopilotBlink 0.9s step-end infinite;
}
@keyframes lunaCopilotBlink {
  50% { opacity: 0; }
}
#lunaCopilotSignin {
  padding: 20px 16px;
  text-align: center;
  font-size: 0.88rem;
  color: var(--theme-text-secondary, #666);
}
#lunaCopilotSignin button {
  margin-top: 10px;
  padding: 8px 16px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #4891ff, #7c6cff);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.luna-copilot-foot {
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  flex-shrink: 0;
}
.luna-copilot-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
#lunaCopilotInput {
  flex: 1;
  min-height: 38px;
  max-height: 96px;
  resize: none;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.45);
  padding: 9px 12px;
  font: inherit;
  font-size: 0.88rem;
  outline: none;
}
#lunaCopilotSend {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #4891ff, #7c6cff);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#lunaCopilotSend:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
#lunaCopilotStatus {
  font-size: 0.72rem;
  color: var(--theme-text-secondary, #888);
  min-height: 16px;
  margin-top: 6px;
}
@media (max-width: 520px) {
  #lunaCopilotPanel {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: min(88dvh, 88vh);
    height: min(88dvh, 88vh);
    border-radius: 22px 22px 0 0;
    transform: translateY(105%);
    opacity: 1;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.18);
  }
  #lunaCopilotPanel.open {
    transform: translateY(0);
    opacity: 1;
  }
  .luna-copilot-head {
    padding: 14px 14px 12px;
    position: relative;
  }
  .luna-copilot-head::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.18);
  }
  #lunaCopilotClose {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    font-size: 1.35rem;
  }
}
