/* ════════════════════════════════════════════════════════════════════
   Baby Dragon · floating chat companion for the China trip
   ════════════════════════════════════════════════════════════════════ */

.bd-launcher {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 1500;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(140deg, var(--vermillion) 0%, var(--vermillion-deep) 100%);
  color: var(--paper-light);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  box-shadow:
    0 6px 18px rgba(156, 40, 32, 0.32),
    0 2px 6px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 220ms cubic-bezier(.23,1,.32,1), box-shadow 220ms;
  animation: bd-bob 4s ease-in-out infinite;
}

.bd-launcher:hover {
  transform: scale(1.06);
  box-shadow:
    0 8px 24px rgba(156, 40, 32, 0.42),
    0 3px 8px rgba(0, 0, 0, 0.22);
}

.bd-launcher:active { transform: scale(0.96); }

.bd-launcher__pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--vermillion);
  opacity: 0;
  animation: bd-pulse 2.4s ease-out infinite;
  pointer-events: none;
}

@keyframes bd-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

@keyframes bd-pulse {
  0%   { opacity: 0.6; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.6); }
}

/* ─── Panel ─────────────────────────────────────────────────────── */

.bd-panel {
  position: fixed;
  bottom: 90px;
  right: 18px;
  width: min(380px, calc(100vw - 36px));
  height: min(620px, calc(100vh - 120px));
  z-index: 1500;
  background: var(--paper-light);
  border: 1px solid rgba(74, 60, 50, 0.18);
  border-radius: 16px;
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.22),
    0 4px 12px rgba(0, 0, 0, 0.10);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: bd-pop-in 240ms cubic-bezier(.23,1,.32,1);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
}

@keyframes bd-pop-in {
  from { opacity: 0; transform: scale(.9) translateY(20px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}

@media (max-width: 480px) {
  .bd-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 16px 16px 0 0;
  }
}

/* ─── Header ─────────────────────────────────────────────────────── */

.bd-head {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .85rem 1rem;
  background: linear-gradient(140deg, var(--vermillion) 0%, var(--vermillion-deep) 100%);
  color: var(--paper-light);
}

.bd-head__avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.bd-head__title {
  font-family: "Cormorant Garamond", serif;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.1;
  margin: 0;
}

.bd-head__sub {
  font-size: 11.5px;
  opacity: 0.8;
  margin-top: 1px;
}

.bd-head__close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--paper-light);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
}
.bd-head__close:hover { background: rgba(255,255,255,0.15); }

/* ─── Messages ────────────────────────────────────────────────────── */

.bd-log {
  flex: 1;
  overflow-y: auto;
  padding: .85rem;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  background: var(--paper-light);
  scroll-behavior: smooth;
}

.bd-msg {
  max-width: 85%;
  padding: .55rem .75rem;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-deep);
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: bd-msg-in 180ms ease-out;
}

@keyframes bd-msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bd-msg--user {
  align-self: flex-end;
  background: var(--vermillion);
  color: var(--paper-light);
  border-bottom-right-radius: 4px;
}

.bd-msg--bot {
  align-self: flex-start;
  background: var(--paper-warm);
  border-bottom-left-radius: 4px;
}

.bd-msg--bot.bd-msg--err {
  background: rgba(200, 54, 44, 0.12);
  color: var(--vermillion-deep);
  font-style: italic;
}

.bd-msg p { margin: 0 0 .4rem; }
.bd-msg p:last-child { margin-bottom: 0; }
.bd-msg ul, .bd-msg ol { margin: .25rem 0 .5rem; padding-inline-start: 1.4rem; }
.bd-msg li { margin: .1rem 0; }
.bd-msg code {
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12.5px;
  font-family: ui-monospace, monospace;
}
.bd-msg strong { font-weight: 600; }
.bd-msg a {
  color: var(--vermillion);
  font-weight: 500;
  word-break: break-all;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.bd-msg a:hover { color: var(--vermillion-deep); }
.bd-msg--user a {
  color: var(--paper-light);
  text-decoration-color: rgba(255,255,255,0.7);
}

/* RTL bubble for Arabic content */
.bd-msg[dir="rtl"] {
  text-align: right;
}

/* ─── Typing indicator ──────────────────────────────────────────── */

.bd-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
  background: var(--paper-warm);
  border-radius: 14px 14px 14px 4px;
}
.bd-typing span {
  width: 6px; height: 6px;
  background: var(--ink-mid);
  border-radius: 50%;
  opacity: .35;
  animation: bd-typing 1.2s infinite;
}
.bd-typing span:nth-child(2) { animation-delay: .15s; }
.bd-typing span:nth-child(3) { animation-delay: .30s; }

@keyframes bd-typing {
  0%, 60%, 100% { transform: translateY(0);  opacity: .35; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* ─── Quick chips ───────────────────────────────────────────────── */

.bd-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 .85rem .65rem;
  background: var(--paper-light);
}

.bd-chip {
  font-size: 12px;
  padding: 6px 10px;
  border: 1px solid rgba(74, 60, 50, 0.22);
  background: var(--paper-warm);
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink-mid);
  transition: background 160ms;
}
.bd-chip:hover {
  background: var(--paper-light);
  color: var(--ink-deep);
}

/* ─── Composer ──────────────────────────────────────────────────── */

.bd-composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: .65rem .75rem .85rem;
  border-top: 1px solid rgba(74, 60, 50, 0.14);
  background: var(--paper-light);
}

.bd-input {
  flex: 1;
  resize: none;
  border: 1px solid rgba(74, 60, 50, 0.22);
  border-radius: 12px;
  padding: .55rem .65rem;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  background: var(--paper-warm);
  color: var(--ink-deep);
  max-height: 120px;
  min-height: 40px;
  outline: none;
}
.bd-input:focus {
  border-color: var(--vermillion);
  background: var(--paper-light);
}

.bd-btn {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--vermillion);
  color: var(--paper-light);
  cursor: pointer;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 140ms, transform 100ms;
}
.bd-btn:hover  { background: var(--vermillion-deep); }
.bd-btn:active { transform: scale(0.94); }
.bd-btn:disabled {
  background: var(--paper-warm);
  color: var(--ink-mid);
  cursor: not-allowed;
  opacity: .55;
}

.bd-btn--mic.recording {
  background: #d94a3a;
  animation: bd-mic-pulse 1.1s ease-in-out infinite;
}

@keyframes bd-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 74, 58, 0.55); }
  50%      { box-shadow: 0 0 0 10px rgba(217, 74, 58, 0); }
}

/* ─── Hidden helper ────────────────────────────────────────────── */

.bd-hidden { display: none !important; }
