/* Pronovision AI Assistant — standalone app (no site chrome) */
:root {
  --bg: #0a0e27;
  --bg-soft: #11173a;
  --card: #121832;
  --border: #232c5e;
  --text: #eef1ff;
  --muted: #9aa3c9;
  --accent: #7c5cff;
  --gradient: linear-gradient(120deg, #7c5cff 0%, #22d3ee 100%);
  --radius: 16px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html.ai-app-root,
body.ai-app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
  touch-action: manipulation;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--card);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.ai-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100dvh;
  background: var(--card);
  overflow: hidden;
}

/* ── Top bar ── */
.ai-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  background: var(--card);
  z-index: 50;
}
.ai-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 1.25rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.ai-topbar-center {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: .95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Bouton Dashboard (chatbot) — argent, 50% avant 1ère sauvegarde */
.ai-dash-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  margin-right: 4px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid rgba(210, 220, 232, 0.45);
  background: linear-gradient(145deg, rgba(250, 251, 253, 0.22) 0%, rgba(176, 190, 201, 0.18) 55%, rgba(138, 154, 170, 0.2) 100%);
  color: #e8eef4;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease, transform 0.2s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.ai-dash-btn--hint {
  opacity: 0.5;
}
.ai-dash-btn--active {
  opacity: 1;
  border-color: rgba(220, 232, 244, 0.75);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 4px 14px rgba(130, 150, 170, 0.35);
}
.ai-dash-btn:hover {
  opacity: 1;
  transform: translateY(-1px);
}
.ai-dash-btn-vip {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 2px 5px;
  border-radius: 999px;
  background: linear-gradient(145deg, #fafbfd 0%, #b0bec9 100%);
  color: #141c28;
  border: 1px solid rgba(220, 228, 236, 0.5);
}
.pv-ticket-save-btn--done {
  opacity: 0.92;
}
.ai-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3ddc84;
  flex-shrink: 0;
}
.ai-pill {
  margin-left: auto;
  background: rgba(139, 92, 246, .18);
  color: #a78bfa;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: .68rem;
  font-weight: 700;
  flex-shrink: 0;
}
.ai-pill-admin {
  background: rgba(234, 179, 8, .18);
  color: #fbbf24;
}
.ai-lang { position: relative; flex-shrink: 0; }
.ai-lang .lang-trigger {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.ai-lang .lang-caret { opacity: .6; font-size: .7rem; }
.ai-lang .lang-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 120px;
  list-style: none;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.ai-lang.open .lang-menu { display: block; }
.ai-lang .lang-menu li {
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .85rem;
}
.ai-lang .lang-menu li:hover { background: rgba(255, 255, 255, .06); }

/* ── Main stage ── */
.ai-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.auth-gate {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  gap: 12px;
}
.auth-gate h3 { font-size: 1.2rem; }
.auth-gate p { color: var(--muted); font-size: .9rem; max-width: 320px; }
.auth-gate .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--gradient);
  color: #08102a;
  font-weight: 700;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.auth-gate .btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

#chat-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.ai-chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: var(--card);
}

/* ── Stars ── */
@keyframes pvStar { 0%, 100% { opacity: .08; } 50% { opacity: .7; } }
.chat-stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.chat-star {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #a78bfa;
  animation: pvStar var(--d, 2.2s) ease-in-out infinite;
}

/* ── Messages ── */
.chat-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  z-index: 1;
  scroll-behavior: smooth;
}
.bubble {
  padding: 12px 16px;
  border-radius: 14px;
  max-width: 88%;
  font-size: .93rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble strong { font-weight: 700; }
.bubble em { font-style: italic; color: var(--muted); font-size: .9em; }
.bubble.bot {
  background: transparent;
  align-self: flex-start;
  border-top-left-radius: 4px;
}
.bubble.bot.typing-bubble,
.bubble.bot:has(.typing) {
  background: transparent;
  padding: 4px 0;
}
.bubble.me {
  background: var(--gradient);
  color: #08102a;
  align-self: flex-end;
  border-top-right-radius: 4px;
  font-weight: 600;
}

/* Bot message entrance: fade + slide down */
.bubble.bot-enter {
  opacity: 0;
  transform: translateY(-16px);
  transition: opacity .55s ease, transform .55s cubic-bezier(.22, 1, .36, 1);
}
.bubble.bot-enter.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* User bubble quick entrance */
.bubble.me-enter {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .35s ease, transform .35s cubic-bezier(.22, 1, .36, 1);
}
.bubble.me-enter.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Typing ── */
.typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 8px 4px;
  background: transparent;
}
.typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink {
  0%, 60%, 100% { transform: translateY(0); opacity: .6; }
  30% { transform: translateY(-7px); opacity: 1; }
}

/* ── Intro (Gemini-style, all viewports) ── */
.chat-intro-center { display: none; }
#chat-intro-center-coach { display: none; }

#chat-wrap.chat-intro .chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: 0;
}
#chat-wrap.chat-intro .chat-intro-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 12px 16px 8px;
  text-align: center;
}
#chat-wrap.chat-intro .chat-intro-greeting {
  margin: 0;
  max-width: 300px;
  font-size: .95rem;
  line-height: 1.45;
  align-self: center;
  text-align: center;
}
#chat-wrap.chat-intro .chat-suggest {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  position: static;
  margin: 0 auto;
  padding: 0 12px 10px;
  width: 100%;
  max-width: 360px;
  z-index: 2;
}
#chat-wrap.chat-intro .chat-robot-wrap {
  position: relative;
  top: auto;
  right: auto;
  width: 88px;
  height: 98px;
  margin: 0 auto;
  transform: none;
  filter: drop-shadow(0 6px 24px rgba(139, 92, 246, .55));
}
#chat-wrap.chat-intro .robot-svg { width: 88px; height: 98px; }

#chat-wrap.chat-started .chat-intro-center { display: none !important; }
#chat-wrap.chat-started .chat-body {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}
#chat-wrap.chat-started .chat-robot-wrap {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 52px;
  height: 58px;
  z-index: 20;
  transition: top .5s cubic-bezier(.4, 0, .2, 1), right .5s cubic-bezier(.4, 0, .2, 1);
}
#chat-wrap.chat-started .robot-svg { width: 52px; height: 58px; }

/* ── Chips ── */
.chat-suggest {
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 0 12px 10px;
  z-index: 2;
  position: relative;
}
.chat-suggest .chip {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: .78rem;
  transition: border-color .15s, transform .15s;
  font-family: inherit;
  line-height: 1.25;
  text-align: center;
}
.chat-suggest .chip:hover { border-color: var(--accent); }
.chip-label-short { display: none; }
.chip-mobile-hide { display: none; }

/* ── Input ── */
.chat-input {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--card);
  z-index: 2;
  flex-shrink: 0;
}
.chat-input input {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
}
.chat-input input:focus { outline: none; border-color: var(--accent); }
.chat-input .btn {
  flex-shrink: 0;
  padding: 12px 16px;
  border-radius: 999px;
  border: none;
  background: var(--gradient);
  color: #08102a;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  font-size: .88rem;
}

/* ── Token bar ── */
.token-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  font-size: .78rem;
  flex-shrink: 0;
  z-index: 2;
}
.token-bar-track {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  overflow: hidden;
}
.token-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .5s ease, background .5s ease;
  background: linear-gradient(90deg, #7c3aed, #6d28d9);
}
.token-bar-fill.warn { background: linear-gradient(90deg, #f59e0b, #d97706); }
.token-bar-fill.alert { background: linear-gradient(90deg, #ef4444, #dc2626); }
.token-label { white-space: nowrap; color: var(--muted); font-size: .72rem; }
.token-count { font-weight: 700; white-space: nowrap; }

.vip-gate-chat {
  padding: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  background: rgba(139, 92, 246, .06);
  flex-shrink: 0;
  z-index: 2;
}
.vip-gate-chat p { margin: 0 0 10px; color: var(--muted); font-size: .85rem; }
.quota-msg {
  padding: 6px 14px;
  color: var(--muted);
  font-size: .75rem;
  text-align: center;
  flex-shrink: 0;
}

/* ── Robot ── */
.chat-robot-wrap {
  position: absolute;
  pointer-events: none;
  z-index: 20;
  filter: drop-shadow(0 4px 16px rgba(139, 92, 246, .5));
}
.robot-svg { overflow: visible; }
.r-antenna-dot { animation: antennaPulse 2.5s ease-in-out infinite; }
@keyframes antennaPulse {
  0%, 100% { opacity: .5; }
  50% { opacity: 1; fill: #c4b5fd; }
}
.r-eye-inner { animation: eyeBlink 4s ease-in-out infinite; transform-origin: center; }
@keyframes eyeBlink {
  0%, 90%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.05); }
}
.r-arm-right {
  transform-origin: 58px 62px;
  transition: transform .35s cubic-bezier(.34, 1.56, .64, 1);
}
.chat-robot-wrap.talking .r-arm-right { transform: rotate(-110deg); }
.chat-robot-wrap.talking .r-body { animation: robotBounce .5s ease-in-out; }
.chat-robot-wrap.talking .r-antenna-dot { fill: #c4b5fd; animation: antennaTalking .3s ease-in-out infinite alternate; }
.chat-robot-wrap.talking .r-eye-glow { fill: #818cf8; }
@keyframes robotBounce {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
  70% { transform: translateY(-3px); }
}
@keyframes antennaTalking { from { opacity: .7; } to { opacity: 1; } }
.chat-robot-wrap:not(.talking) .robot-svg { animation: robotIdle 3.5s ease-in-out infinite; }
@keyframes robotIdle {
  0%, 100% { transform: rotate(-1.5deg); }
  50% { transform: rotate(1.5deg); }
}

/* ── Desktop (PC) ── */
@media (min-width: 769px) {
  .ai-shell { max-width: 920px; margin: 0 auto; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }

  #chat-wrap.chat-intro .chat-intro-center {
    align-items: center;
    text-align: center;
  }
  #chat-wrap.chat-intro .chat-intro-greeting {
    align-self: center;
    text-align: center;
    max-width: 520px;
  }

  .chat-suggest,
  #chat-wrap.chat-intro .chat-suggest {
    display: flex !important;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: stretch;
    gap: 8px;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    grid-template-columns: unset;
  }
  .chat-suggest::-webkit-scrollbar { display: none; }
  .chat-suggest .chip {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: .82rem;
    padding: 9px 14px;
  }

  .chat-body {
    align-items: center;
    padding-left: 24px;
    padding-right: 24px;
  }
  .bubble.bot {
    align-self: center;
    max-width: min(640px, 92%);
    text-align: center;
  }
  .bubble.me {
    align-self: flex-end;
    max-width: 72%;
  }

  .chat-input {
    padding: 10px 20px 14px;
    padding-right: 72px;
    max-width: 920px;
    margin: 0 auto;
    width: 100%;
  }
  .chat-input input {
    padding: 11px 16px;
    font-size: 15px;
  }
  .chat-input .btn {
    padding: 11px 18px;
    min-width: 88px;
  }
}

/* ===== Mode Coach ===== */
/* Zone saisie + bouton coach côte à côte */
.chat-input-area {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex-shrink: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
}
.chat-input {
  border-top: none !important;
  background: transparent !important;
  padding-bottom: 6px !important;
}
.coach-side-wrap,
.coach-mode-bar {
  display: flex;
  justify-content: flex-end;
  padding: 0 12px 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--card);
}

.coach-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  position: relative;
  overflow: hidden;
  /* Dégradé rouge subtil + contour brillant */
  background: linear-gradient(135deg, rgba(185,28,28,.35) 0%, rgba(239,68,68,.2) 100%);
  border: 1px solid rgba(239,68,68,.55);
  color: #fca5a5;
  border-radius: 999px;
  padding: 6px 14px 6px 10px;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background .2s, border-color .2s, color .2s, box-shadow .2s;
  letter-spacing: .03em;
  box-shadow: 0 0 10px rgba(239,68,68,.2), inset 0 1px 0 rgba(255,255,255,.07);
}
/* Shimmer au survol */
.coach-mode-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,.1) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform .4s ease;
}
.coach-mode-btn:hover::after { transform: translateX(100%); }
.coach-mode-btn:hover {
  background: linear-gradient(135deg, rgba(185,28,28,.55) 0%, rgba(239,68,68,.38) 100%);
  border-color: rgba(239,68,68,.9);
  color: #fff;
  box-shadow: 0 0 18px rgba(239,68,68,.45), inset 0 1px 0 rgba(255,255,255,.1);
}
.coach-mode-btn-label {
  line-height: 1.2;
  white-space: nowrap;
}
.coach-mode-btn-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
  box-shadow: 0 0 5px #ef4444;
  animation: coachDotIdle 2.5s ease-in-out infinite;
}
@keyframes coachDotIdle {
  0%, 100% { box-shadow: 0 0 4px #ef4444; opacity: 1; }
  50% { box-shadow: 0 0 9px #f87171; opacity: .75; }
}

/* PC : aligner le bouton Coach sur la colonne « Envoyer » (après les styles de base) */
@media (min-width: 769px) {
  .chat-input-area {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 8px;
    row-gap: 4px;
    padding: 10px 72px 14px 20px;
    max-width: 920px;
    margin-inline: auto;
    width: 100%;
    box-sizing: border-box;
  }

  .chat-input-area > .chat-input {
    display: contents;
    padding: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    width: auto !important;
  }

  .chat-input-area > .chat-input input {
    grid-column: 1;
    grid-row: 1;
  }

  .chat-input-area > .chat-input .btn {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .chat-input-area > .coach-side-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: subgrid;
    padding: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    width: auto;
  }

  .coach-side-wrap .coach-mode-btn {
    grid-column: 2;
    justify-self: end;
    max-width: 100%;
    min-width: 0;
  }

  .coach-side-wrap .coach-mode-btn-label {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .coach-mode-bar {
    padding-left: 20px;
    padding-right: 72px;
    max-width: 920px;
    margin-inline: auto;
    width: 100%;
    box-sizing: border-box;
  }
}

/* Mode coach actif */
body.ai-coach-active .ai-chat {
  background: linear-gradient(180deg, #1a0404 0%, #0f0505 100%) !important;
}
body.ai-coach-active .chat-body { background: transparent; }
body.ai-coach-active .ai-shell {
  border-color: rgba(239,68,68,.3) !important;
}
body.ai-coach-active .ai-topbar {
  background: #1a0404 !important;
  border-bottom-color: rgba(239,68,68,.3) !important;
}
body.ai-coach-active #chat-form { display: none !important; }
body.ai-coach-active .chat-input-area,
body.ai-coach-active .coach-side-wrap,
body.ai-coach-active #coach-form-wrap {
  background: #120303 !important;
  border-top-color: rgba(239, 68, 68, .22) !important;
}
body.ai-coach-active #coach-form-wrap {
  display: flex !important;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
}
body.ai-coach-active .coach-side-wrap {
  padding-bottom: 6px;
}
body.ai-coach-active #chat-wrap .chat-suggest { display: none !important; }
body.ai-coach-active .coach-mode-btn {
  background: linear-gradient(135deg, rgba(185,28,28,.65) 0%, rgba(239,68,68,.45) 100%);
  border-color: #ef4444;
  color: #fff;
  box-shadow: 0 0 20px rgba(239,68,68,.5), inset 0 1px 0 rgba(255,255,255,.12);
}
body.ai-coach-active .coach-mode-btn-dot {
  animation: coachPulse 1.5s ease-in-out infinite;
}
@keyframes coachPulse {
  0%, 100% { box-shadow: 0 0 4px #ef4444; opacity: 1; }
  50% { box-shadow: 0 0 12px #ef4444, 0 0 24px rgba(239,68,68,.4); opacity: .7; }
}

/* Zone drop image coach */
.coach-img-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  border: 2px dashed rgba(239,68,68,.45);
  border-radius: 12px;
  background: rgba(239,68,68,.06);
  color: #fca5a5;
  font-size: .85rem;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  padding: 14px;
  text-align: center;
}
.coach-img-drop:hover, .coach-img-drop.drag-over {
  border-color: #ef4444;
  background: rgba(239,68,68,.12);
}

.btn-coach-send {
  background: linear-gradient(120deg, #ef4444, #b91c1c) !important;
  color: #fff !important;
  font-weight: 800 !important;
  border-radius: 999px !important;
  padding: 10px 24px !important;
  border: none !important;
  cursor: pointer;
  font-size: .9rem !important;
  transition: opacity .2s !important;
  width: 100%;
}
.btn-coach-send:hover { opacity: .88; }

/* Auth gate — ajouter un hint "en chargement" visuel */
.auth-gate { animation: gateIn .35s ease both; }
@keyframes gateIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ===== Spinner de chargement initial ===== */
.ai-loading-gate {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.ai-spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(124,92,255,.2);
  border-top-color: #7c5cff;
  border-radius: 50%;
  animation: aiSpin .8s linear infinite;
}
@keyframes aiSpin { to { transform: rotate(360deg); } }

/* ===== Mode Coach — fond rouge + étoiles rouges ===== */

/* Étoiles rouges en mode coach */
.chat-stars.coach-stars .chat-star {
  background: #f87171;
}

/* Fond rouge sur le chat-wrap entier */
body.ai-coach-active .ai-chat {
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(127,10,10,.55) 0%, rgba(60,4,4,.25) 50%, transparent 100%),
              linear-gradient(180deg, #1a0505 0%, #0f0202 100%) !important;
}

/* Topbar rouge */
body.ai-coach-active .ai-topbar {
  background: #150202 !important;
  border-bottom-color: rgba(239,68,68,.25) !important;
}

/* Shell border */
body.ai-coach-active .ai-shell {
  border-color: rgba(239,68,68,.2) !important;
}

/* Bubble de bienvenue Coach */
.coach-bubble {
  background: rgba(239,68,68,.12) !important;
  border: 1px solid rgba(239,68,68,.3) !important;
  color: #fecaca !important;
  max-width: 280px;
  text-align: center;
}

/* Le chat-body en mode coach : fond transparent pour laisser le dégradé rouge */
body.ai-coach-active .chat-body {
  background: transparent !important;
}

/* Bulles dans le chat coach */
body.ai-coach-active .bubble.bot {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.25);
}
body.ai-coach-active .bubble.me {
  background: linear-gradient(120deg, #b91c1c, #ef4444);
}

/* Centre intro coach */
body.ai-coach-active #chat-intro-center {
  display: none !important; /* libère la place pour le centre coach */
}
body.ai-coach-active #chat-intro-center-coach {
  display: flex !important;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px 20px;
  animation: gateIn .35s ease both;
}

/* Robot rouge en mode coach (intro centré + coin après envoi) */
body.ai-coach-active #chat-wrap.chat-intro .coach-robot-wrap,
body.ai-coach-active #chat-intro-center-coach .chat-robot-wrap {
  display: flex !important;
  align-items: center;
  justify-content: center;
  position: relative;
  top: auto;
  right: auto;
  width: 88px;
  height: 98px;
  margin: 0 auto;
  filter: drop-shadow(0 6px 24px rgba(239, 68, 68, .55));
}
body.ai-coach-active #chat-wrap.chat-intro .coach-robot-wrap .robot-svg,
body.ai-coach-active #chat-intro-center-coach .robot-svg {
  filter: hue-rotate(117deg) saturate(2.1) brightness(0.9);
  width: 88px;
  height: 98px;
}
body.ai-coach-active #chat-robot-center {
  display: none !important;
}
body.ai-coach-active #chat-wrap.chat-started .chat-robot-wrap {
  filter: drop-shadow(0 4px 16px rgba(239, 68, 68, .45));
}
body.ai-coach-active #chat-wrap.chat-started .robot-svg {
  filter: hue-rotate(117deg) saturate(2.1) brightness(0.9);
}

/* Robot coach centré (assistant.html) */
.coach-intro-center {
  flex: 1;
}
