:root {
  --ai-chat-bg: #0b1220;
  --ai-chat-panel: rgba(255, 255, 255, 0.96);
  --ai-chat-border: rgba(17, 24, 39, 0.10);
  --ai-chat-muted: rgba(17, 24, 39, 0.70);
  --ai-chat-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  --ai-chat-accent: #FFAA4C;
  --ai-chat-accent-dark: #e6953d;
}

.ai-chat[hidden] { display: none !important; }

.ai-chat {
  position: fixed;
  inset: 0;
  z-index: 99999;
}

.ai-chat__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 18, 32, 0.46);
  backdrop-filter: blur(2px);
}

.ai-chat__panel {
  position: absolute;
  top: 18px;
  right: 18px;
  bottom: 18px;
  width: min(420px, calc(100vw - 36px));
  background: var(--ai-chat-panel);
  border: 1px solid var(--ai-chat-border);
  border-radius: 18px;
  box-shadow: var(--ai-chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-chat__header {
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--ai-chat-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(255,255,255,0.80));
}

.ai-chat__titlewrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.ai-chat__badge {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: rgba(255, 170, 76, 0.18);
  color: #c66c0f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.ai-chat__title {
  font-weight: 800;
  color: #111827;
  line-height: 1.2;
}

.ai-chat__subtitle {
  font-size: 0.78rem;
  color: var(--ai-chat-muted);
  line-height: 1.2;
  margin-top: 2px;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.ai-chat__actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ai-chat__btn {
  border: 1px solid var(--ai-chat-border);
  background: #fff;
  color: #111827;
  border-radius: 12px;
  padding: 8px 10px;
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1;
}

.ai-chat__btn:hover { background: rgba(17,24,39,0.04); }
.ai-chat__btn:focus { outline: 2px solid rgba(91, 178, 255, 0.65); outline-offset: 2px; }

.ai-chat__btn--ghost {
  background: rgba(255,255,255,0.85);
}

.ai-chat__btn--icon {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ai-chat__body {
  flex: 1;
  padding: 14px;
  overflow: auto;
  background:
    radial-gradient(1000px 400px at 80% 0%, rgba(91, 178, 255, 0.10), transparent 60%),
    radial-gradient(900px 360px at 0% 30%, rgba(255, 170, 76, 0.10), transparent 60%),
    #f8fafc;
}

.ai-chat__msg {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  align-items: flex-end;
}

.ai-chat__msg--user { justify-content: flex-end; }

.ai-chat__bubble {
  max-width: 82%;
  border-radius: 16px;
  padding: 10px 12px;
  line-height: 1.35;
  font-size: 0.92rem;
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}

.ai-chat__bubble--user {
  background: #111827;
  color: #fff;
  border-bottom-right-radius: 6px;
}

.ai-chat__bubble--assistant {
  background: #ffffff;
  color: #111827;
  border: 1px solid rgba(17,24,39,0.08);
  border-bottom-left-radius: 6px;
}

.ai-chat__meta {
  font-size: 0.72rem;
  color: rgba(17,24,39,0.55);
  margin-top: 4px;
}

.ai-chat__typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.ai-chat__dot {
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: rgba(17,24,39,0.35);
  animation: aiChatDot 1.1s infinite ease-in-out;
}
.ai-chat__dot:nth-child(2) { animation-delay: 0.15s; }
.ai-chat__dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes aiChatDot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40% { transform: translateY(-3px); opacity: 0.9; }
}

.ai-chat__composer {
  padding: 12px;
  border-top: 1px solid var(--ai-chat-border);
  display: flex;
  gap: 10px;
  background: rgba(255,255,255,0.96);
}

.ai-chat__input {
  flex: 1;
  border: 1px solid rgba(17,24,39,0.12);
  border-radius: 14px;
  padding: 12px 12px;
  font-size: 0.95rem;
  background: #fff;
}

.ai-chat__input:focus {
  outline: none;
  border-color: rgba(255,170,76,0.65);
  box-shadow: 0 0 0 3px rgba(255,170,76,0.18);
}

.ai-chat__send {
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 14px;
  background: var(--ai-chat-accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.18s;
}
.ai-chat__send:hover { background: var(--ai-chat-accent-dark); }
.ai-chat__send:disabled { opacity: 0.6; cursor: not-allowed; }

.ai-chat__footer {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--ai-chat-border);
  background: rgba(255,255,255,0.92);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.74rem;
  color: rgba(17,24,39,0.82);
}

.ai-chat__hint,
.ai-chat__privacy {
  color: rgba(17,24,39,0.82);
}

.ai-chat__footer kbd {
  color: rgba(17,24,39,0.92);
}

.ai-chat__footer kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.72rem;
  border: 1px solid rgba(17,24,39,0.15);
  border-bottom-width: 2px;
  background: rgba(255,255,255,0.95);
  border-radius: 6px;
  padding: 1px 6px;
}

@media (max-width: 575.98px) {
  .ai-chat__panel {
    top: 10px;
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
    border-radius: 16px;
  }
  .ai-chat__subtitle { font-size: 0.76rem; }
  .ai-chat__header { align-items: flex-start; }
}

