/* ============================================================
   Artères Jeunes × Vivovojo — Chat Consultation
   Design adapté au quiz Vivovojo
   ============================================================ */

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

:root {
  --primary: #1B6B4A;
  --primary-light: #2A8F64;
  --primary-pale: #E8F5EE;
  --bg: #FAFBFC;
  --white: #FFFFFF;
  --text: #1A1A2E;
  --text-secondary: #4A4A68; /* was #5A5A7A — ratio 5.2:1 WCAG AA ✓ */
  --text-muted: #72728A;    /* was #9A9ABF — ratio 4.6:1 WCAG AA ✓ */
  --border: #E8E8F0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-full: 9999px;
}

html, body {
  height: 100%;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 17px; /* +1px base — presbytie 55-70 ans */
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---- Layout ---- */

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--white);
  box-shadow: -1px 0 0 var(--border), 1px 0 0 var(--border);
  position: relative;
  overflow-x: hidden;
}

/* ---- Header ---- */

#chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 14px;
  background: linear-gradient(135deg, #FFFFFF 0%, #F8FBF9 100%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

#chat-header .avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top center;
  border: 2px solid var(--primary);
  background: var(--primary-pale);
  flex-shrink: 0;
}

#chat-header .avatar-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}

#chat-header .header-info {
  flex: 1;
  min-width: 0;
}

#chat-header .header-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 5px;
}

#chat-header .verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: #1DA1F2;
  border-radius: 50%;
  flex-shrink: 0;
}

#chat-header .verified-badge svg {
  width: 10px;
  height: 10px;
  fill: #fff;
}

#chat-header .header-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#chat-header .header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  flex-shrink: 0;
}

#chat-header .header-status .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* Status dot states */
#chat-header .header-status .status-dot.offline {
  background: var(--text-muted);
  animation: none;
}

#chat-header .header-status .status-dot.connecting {
  background: #D4800A;
  animation: pulse-amber 1s infinite;
}

@keyframes pulse-amber {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Avatar "is typing" ring */
#chat-header .avatar.is-typing,
#chat-header .avatar-placeholder.is-typing {
  box-shadow: 0 0 0 3px rgba(27, 107, 74, 0.25);
  animation: avatar-typing-ring 1.5s ease infinite;
}

@keyframes avatar-typing-ring {
  0%, 100% { box-shadow: 0 0 0 3px rgba(27, 107, 74, 0.25); }
  50% { box-shadow: 0 0 0 5px rgba(27, 107, 74, 0.1); }
}

/* ---- Scenario progress milestones (A7) ---- */
.scenario-progress {
  padding: 0 8px 6px;
  background: transparent;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  flex-shrink: 0;
  position: relative;
}
.scenario-progress-bar {
  height: 2px;
  background: rgba(27, 107, 74, 0.3);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
  border-radius: 1px;
  margin-bottom: 4px;
}
.scenario-progress-steps {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: relative;
}
.scenario-progress-steps::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 10%;
  right: 10%;
  height: 1px;
  background: rgba(0,0,0,0.08);
  z-index: 0;
}
.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.progress-step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d8d8e8;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
  transition: background 0.4s, box-shadow 0.4s, transform 0.3s;
  flex-shrink: 0;
}
.progress-step-label {
  font-size: 8px;
  font-weight: 500;
  color: #bbb;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  transition: color 0.4s, font-weight 0.3s;
  letter-spacing: -0.01em;
  padding: 0 1px;
}
.progress-step.done .progress-step-dot {
  background: var(--primary, #1b6b4a);
  box-shadow: 0 0 0 1px rgba(27,107,74,0.2);
}
.progress-step.done .progress-step-label { color: var(--primary, #1b6b4a); font-weight: 600; }
.progress-step.active .progress-step-dot {
  background: var(--primary, #1b6b4a);
  box-shadow: 0 0 0 3px rgba(27,107,74,0.15);
  transform: scale(1.15);
}
.progress-step.active .progress-step-label { color: var(--primary, #1b6b4a); font-weight: 700; font-size: 8.5px; }

/* ---- Visual report card ---- */
.visual-report-card {
  background: linear-gradient(135deg, #f8fffe 0%, #f0f9f4 100%);
  border: 1px solid rgba(27,107,74,0.15);
  border-radius: 16px;
  padding: 16px;
  margin: 8px 0 12px;
  box-shadow: 0 2px 12px rgba(27,107,74,0.08);
}
.visual-report-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary, #1b6b4a);
  margin-bottom: 14px;
  text-align: center;
}
.visual-report-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.visual-report-row:last-of-type { border-bottom: none; }
.visual-report-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  padding-right: 12px;
}
.visual-report-value-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.visual-report-gauge { display: block; }
.visual-report-unit {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}
.visual-report-text-value {
  font-size: 20px;
  font-weight: 700;
  text-align: right;
}
.visual-report-footer {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 12px;
  line-height: 1.4;
  font-style: italic;
}

/* ---- Video testimonials ---- */
.video-testimonials-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 12px;
  padding: 0 4px;
}
.video-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s;
  border: 1px solid rgba(0,0,0,0.06);
}
.video-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); transform: translateY(-1px); }
.video-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16/7;
  background: linear-gradient(135deg, #1b6b4a 0%, #2d9969 100%);
  overflow: hidden;
}
.video-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.video-thumb-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: 700;
  color: rgba(255,255,255,0.4);
  background: linear-gradient(135deg, #1b6b4a 0%, #2d9969 50%, #1b6b4a 100%);
}
.video-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #1b6b4a;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  transition: transform 0.2s, background 0.2s;
  padding-left: 3px;
}
.video-card:hover .video-play-btn { transform: translate(-50%,-50%) scale(1.1); background: #fff; }
.video-duration {
  position: absolute;
  bottom: 6px;
  right: 8px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}
.video-meta {
  padding: 10px 12px;
}
.video-name { font-weight: 700; font-size: 13px; color: var(--text); margin-bottom: 1px; }
.video-location { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.video-result {
  font-size: 11px;
  font-weight: 600;
  color: #1b6b4a;
  background: rgba(27,107,74,0.08);
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-block;
}
.video-script {
  padding: 10px 12px;
  font-size: 13px;
  font-style: italic;
  color: var(--text-muted);
  border-top: 1px solid rgba(0,0,0,0.06);
  line-height: 1.5;
}

/* ---- Timer bar ---- */

.timer-bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 16px 6px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  transition: background 0.4s ease;
}

.timer-text {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  transition: color 0.4s ease;
}

.timer-track {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.timer-progress {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition: width 1s linear, background 0.4s ease;
}

/* Timer phases */
.timer-bar.phase-plenty .timer-text { color: var(--primary); }
.timer-bar.phase-plenty .timer-progress { background: var(--primary); }

.timer-bar.phase-attention .timer-text { color: #D4800A; }
.timer-bar.phase-attention .timer-progress { background: #D4800A; }

.timer-bar.phase-urgent .timer-text { color: #C0392B; }
.timer-bar.phase-urgent .timer-progress { background: #C0392B; }

.timer-bar.phase-final .timer-text { color: #C0392B; animation: timer-pulse 1.5s ease infinite; }
.timer-bar.phase-final .timer-progress { background: #C0392B; }

.timer-bar.phase-overtime { background: #FDF2F2; }
.timer-bar.phase-overtime .timer-text { color: #C0392B; font-weight: 700; }
.timer-bar.phase-overtime .timer-progress { background: #C0392B; width: 100% !important; }

@keyframes timer-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ---- Chat area ---- */

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: var(--bg);
  /* Subtle WhatsApp-style pattern */
  background-image:
    radial-gradient(circle at 20% 50%, rgba(27,107,74,0.015) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(27,107,74,0.01) 0%, transparent 50%),
    radial-gradient(circle at 50% 80%, rgba(27,107,74,0.012) 0%, transparent 50%);
}

#chat-messages {
  overscroll-behavior: contain;
  overflow-x: hidden;
}

#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ---- Scroll-to-bottom FAB ---- */

.scroll-fab {
  position: absolute;
  bottom: 80px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--white);
  border: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  opacity: 0;
  transform: scale(0.8) translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.scroll-fab.visible {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

.scroll-fab:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.scroll-fab svg {
  width: 20px;
  height: 20px;
  fill: var(--text-secondary);
}

.scroll-fab .unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Messages ---- */

.msg-row {
  display: flex;
  gap: 8px;
  max-width: 100%;
  opacity: 0;
  transform: translateY(8px);
  animation: msg-appear 0.3s ease forwards;
}

@keyframes msg-appear {
  to { opacity: 1; transform: translateY(0); }
}

.msg-row.persona-row { align-items: flex-end; }

.msg-row.user-row {
  flex-direction: row-reverse;
  align-items: flex-end;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top center;
  flex-shrink: 0;
  border: 1.5px solid var(--primary);
  margin-bottom: 2px;
}

.msg-avatar-svg {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 1.5px solid var(--primary);
  margin-bottom: 2px;
}
.msg-avatar-svg svg { display: block; width: 100%; height: 100%; }

.msg-avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.msg-bubble {
  max-width: min(calc(100% - 50px), 85vw);
  padding: 13px 16px;
  border-radius: var(--radius-md);
  font-size: 16px; /* 15→16px — confort lecture 55+ */
  line-height: 1.72; /* interligne généreux */
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  min-width: 0;
}

.msg-bubble strong, .msg-bubble b {
  font-weight: 700;
  color: var(--primary);
}

.persona-row .msg-bubble {
  background: var(--white);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.user-row .msg-bubble {
  background: linear-gradient(135deg, var(--primary) 0%, #1F7D56 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 4px rgba(27,107,74,0.15);
}

.user-row .msg-bubble strong, .user-row .msg-bubble b {
  color: #fff;
}

/* ---- Date separator (WhatsApp "Aujourd'hui") ---- */

.date-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0 8px;
  opacity: 0;
  animation: msg-appear 0.3s ease forwards;
}

.date-separator-pill {
  background: rgba(225, 225, 235, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 5px 14px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

/* ---- Message timestamps (WhatsApp-style) ---- */

.msg-timestamp {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 0 2px;
  font-weight: 500;
  letter-spacing: 0.02em;
  opacity: 0;
  animation: msg-appear 0.3s ease forwards;
}

/* ---- Read ticks (WhatsApp "Vu") ---- */

.msg-ticks {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  margin-top: 4px;
  font-size: 10px;
  color: rgba(255,255,255,0.6);
  line-height: 1;
}

.msg-ticks .tick-time {
  font-size: 10px;
  margin-right: 3px;
}

.msg-ticks .tick-checks {
  display: inline-flex;
  position: relative;
  width: 16px;
  height: 12px;
}

.msg-ticks .tick-check {
  position: absolute;
  top: 0;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  transition: color 0.3s ease;
}

.msg-ticks .tick-check:first-child {
  left: 0;
}

.msg-ticks .tick-check:last-child {
  left: 5px;
}

/* Phases : sent (gris) → delivered (blanc) → read (bleu) */
.msg-ticks .tick-check.delivered {
  color: rgba(255,255,255,0.85);
}

.msg-ticks .tick-check.read {
  color: #53BDEB;
}

/* ---- Typing indicator ---- */

.typing-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  opacity: 0;
  transform: translateY(8px);
  animation: msg-appear 0.25s ease forwards;
}

.typing-bubble {
  background: var(--white);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border-bottom-left-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
}

.typing-label {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-bounce 1.2s ease infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ---- Quick Replies — A3 : chips horizontaux scrollables ---- */

.quick-reply-wrap {
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding: 6px 0 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
}
.quick-reply-wrap::-webkit-scrollbar { display: none; }

/* Gradient d'effilement : indique qu'il y a plus à droite */
.quick-reply-wrap::after {
  content: '';
  min-width: 16px; /* espace de fin pour le dernier chip */
  flex-shrink: 0;
}

.quick-reply-btn {
  opacity: 0;
  animation: msg-appear 0.3s ease forwards;
  flex-shrink: 0;
  scroll-snap-align: start;
  white-space: nowrap;
}

.quick-reply-btn:nth-child(1) { animation-delay: 0ms; }
.quick-reply-btn:nth-child(2) { animation-delay: 100ms; }
.quick-reply-btn:nth-child(3) { animation-delay: 200ms; }
.quick-reply-btn:nth-child(4) { animation-delay: 300ms; }
.quick-reply-btn:nth-child(5) { animation-delay: 400ms; }
.quick-reply-btn:nth-child(6) { animation-delay: 500ms; }

.quick-reply-btn {
  padding: 13px 22px; /* 48px height min — gros doigts 55+ */
  background: var(--white);
  border: 2px solid var(--primary);
  border-radius: var(--radius-full);
  color: var(--primary);
  font-size: 15px; /* +1px lisibilité */
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s, box-shadow 0.2s;
  line-height: 1.35;
  box-shadow: 0 1px 3px rgba(27,107,74,0.08);
}

.quick-reply-btn:hover {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(27,107,74,0.2);
  transform: translateY(-1px);
}

.quick-reply-btn:active {
  transform: scale(0.97) translateY(0);
  box-shadow: none;
}

/* Sélection quick reply : flash vert + checkmark */
.quick-reply-btn.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: scale(1.04);
  box-shadow: 0 4px 14px rgba(27,107,74,0.35);
  animation: qr-select-flash 0.25s ease;
}

@keyframes qr-select-flash {
  0% { transform: scale(1); }
  50% { transform: scale(1.06); }
  100% { transform: scale(1.04); }
}

/* ---- Rating ---- */

.rating-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 0 8px;
  opacity: 0;
  animation: msg-appear 0.3s ease forwards;
}

.rating-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.rating-grid {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.rating-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--white);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rating-btn:hover {
  border-color: var(--primary);
  background: var(--primary-pale);
  color: var(--primary);
}

.rating-btn:active {
  background: var(--primary);
  color: #fff;
}

/* ---- Email Input ---- */

.email-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  margin: 8px 0;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
}

.email-input-field {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: #F7F8FA;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s;
}

.email-input-field:focus {
  border-color: var(--primary);
  background: var(--white);
}

.email-send-btn {
  padding: 13px 0;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.email-send-btn:hover {
  background: var(--primary-light);
}

.email-skip-btn {
  padding: 8px 0;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---- CTA Section ---- */

.cta-section {
  margin: 16px 0;
  opacity: 0;
  animation: msg-appear 0.4s ease 0.1s forwards;
}

.cta-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.cta-card {
  display: flex;
  flex-direction: column;
  padding: 20px;
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: 16px;
  text-decoration: none;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
  position: relative;
  opacity: 0;
  animation: cta-card-appear 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes cta-card-appear {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.cta-card:hover {
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(27,107,74,.12);
  transform: translateY(-2px);
}

.cta-card.highlighted {
  border-color: var(--primary);
  background: linear-gradient(135deg, var(--primary-pale) 0%, #F0FAF4 100%);
  box-shadow: 0 4px 16px rgba(27,107,74,.12), 0 0 0 3px rgba(27,107,74,.08);
}

/* T1-6 : Offre principale hyper-mise en avant */
.cta-card--primary {
  padding: 24px 20px;
  border-width: 2px;
}

.cta-card--primary .cta-label {
  font-size: 17px;
}

.cta-card--primary .cta-price {
  font-size: 36px;
}

.cta-card--primary .cta-btn {
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  padding: 15px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 14px rgba(27,107,74,0.35);
}

.cta-card--primary .cta-btn:hover {
  background: var(--primary-light);
}

/* Offres secondaires : plus discrètes */
.cta-card--secondary {
  opacity: 0.88;
}

.cta-card--secondary .cta-btn {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  font-size: 14px;
  padding: 11px;
}

.cta-card--secondary .cta-btn:hover {
  background: var(--primary-pale);
}

.cta-badge {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #E8890C 0%, #D4800A 100%);
  color: white;
  padding: 4px 14px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(212,128,10,0.3);
}

.cta-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.cta-price-original {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: line-through;
  margin-bottom: 2px;
}

.cta-price {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 8px;
}

.cta-price span {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
}

.cta-sublabel {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.cta-features {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Social proof toast — preuve sociale live dans le chat */
.social-proof-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  margin: 6px 0;
  background: #F0F7F4;
  border: 1px solid #C8E6D8;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}

.social-proof-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Toast avatar — photo placeholder colorée avec initiale */
.toast-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.6);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

/* Badge garantie visuel — signal de confiance fort pour avatar 55+ */
.cta-garantie-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(27, 107, 74, 0.07);
  border: 1.5px solid rgba(27, 107, 74, 0.25);
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--primary);
  text-align: center;
  line-height: 1.4;
}

.cta-btn {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  font-family: 'DM Sans', sans-serif;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(27,107,74,0.2);
}

.cta-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(27,107,74,0.3);
}

/* Pulse d'inactivité sur le CTA primaire (déclenché via JS après 3s) */
.cta-btn--pulse {
  animation: cta-idle-pulse 2s ease-in-out 3;
}

@keyframes cta-idle-pulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(27,107,74,0.2); transform: scale(1); }
  40% { box-shadow: 0 0 0 8px rgba(27,107,74,0.12), 0 4px 16px rgba(27,107,74,0.3); transform: scale(1.02); }
}

/* ---- Upsell bump pré-checkout ---- */
.cta-upsell-bump {
  margin: 12px 0;
  background: linear-gradient(135deg, #fffbf0 0%, #fff9e6 100%);
  border: 1.5px solid #e6b84a;
  border-radius: 12px;
  overflow: hidden;
  animation: bump-appear 0.4s cubic-bezier(0.16,1,0.3,1) forwards;
}

@keyframes bump-appear {
  from { opacity: 0; transform: scaleY(0.8) translateY(-8px); }
  to { opacity: 1; transform: scaleY(1) translateY(0); }
}

.bump-header {
  background: #e6b84a;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  letter-spacing: 0.04em;
}

.bump-body { padding: 12px; }

.bump-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 10px;
}

.bump-original {
  text-decoration: line-through;
  color: var(--text-muted);
}

.bump-actions { display: flex; flex-direction: column; gap: 8px; }

.bump-upgrade-btn {
  background: #e6b84a;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.bump-upgrade-btn:hover { background: #c9a036; }

.bump-skip-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px;
}

/* ---- CTA offer timer (A8) ---- */
.cta-offer-timer {
  text-align: center;
  padding: 8px 12px;
  margin: 4px 0;
  background: rgba(27,107,74,0.06);
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  transition: background 0.3s ease, color 0.3s ease;
}
.cta-offer-timer.urgent {
  background: rgba(192,57,43,0.07);
  color: #C0392B;
  animation: timer-pulse 1.5s ease infinite;
}
.cta-offer-timer.expired {
  background: rgba(0,0,0,0.04);
  color: var(--text-muted);
  animation: none;
}

/* ---- Consent ---- */

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.consent-row input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.consent-row label { cursor: pointer; }

.cta-guarantee {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 12px 0 4px;
  font-weight: 500;
}

.cta-guarantee::before {
  content: '🔒';
  font-size: 13px;
}

/* ---- Social proof inline ---- */

.social-proof-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 16px;
  margin: 8px 0 4px;
  opacity: 0;
  animation: msg-appear 0.4s ease 0.3s forwards;
}

.social-proof-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.social-proof-item .proof-icon {
  font-size: 13px;
}

/* ---- Sticky reply zone (quick replies / rating quand l'user scrolle) ---- */

#sticky-reply-zone {
  padding: 0;
  max-height: 0;
  overflow: hidden;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 0px solid var(--border);
  flex-shrink: 0;
  transition: max-height 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              padding 0.28s ease,
              border-top-width 0.1s ease;
}

#sticky-reply-zone.visible {
  max-height: 140px;
  padding: 10px 14px 12px;
  border-top-width: 1px;
}

/* Quick replies dans la zone sticky */
#sticky-reply-zone .quick-reply-wrap {
  padding: 0;
  margin: 0;
}

/* Rating dans la zone sticky — plus compact */
#sticky-reply-zone .rating-wrap {
  padding: 0;
  gap: 6px;
}
#sticky-reply-zone .rating-grid { gap: 5px; }
#sticky-reply-zone .rating-btn {
  width: 36px;
  height: 36px;
  font-size: 13px;
}

/* Textarea hint dans la zone sticky */
#sticky-reply-zone .sticky-textarea-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border: 2px solid var(--primary);
  border-radius: 22px;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}
#sticky-reply-zone .sticky-textarea-hint:hover {
  background: var(--primary-pale);
  color: var(--primary);
}

/* Sticky zone dark — opt-in uniquement via [data-theme="dark"], pas via prefers-color-scheme */
[data-theme="dark"] #sticky-reply-zone { background: rgba(26,26,36,0.96); }

/* ---- Sticky CTA bar ---- */
.sticky-cta-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 120;
  background: #fff;
  border-top: 1px solid rgba(27,107,74,0.2);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.4,0,0.2,1);
  safe-area-inset-bottom: env(safe-area-inset-bottom, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.sticky-cta-bar.visible { transform: translateY(0); }
.sticky-cta-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 12px;
  max-width: 500px;
  margin: 0 auto;
}
.sticky-cta-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sticky-cta-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.sticky-cta-price-original {
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: line-through;
}
.sticky-cta-price {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary, #1b6b4a);
  line-height: 1;
}
.sticky-cta-btn {
  background: var(--primary, #1b6b4a);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, transform 0.15s;
  box-shadow: 0 3px 12px rgba(27,107,74,0.35);
}
.sticky-cta-btn:hover { background: #155c3d; transform: translateY(-1px); }
.sticky-cta-btn:active { transform: translateY(0); }

/* ---- Char counter ---- */
.char-counter {
  font-size: 10px;
  color: var(--text-muted);
  text-align: right;
  padding: 2px 4px 0;
  min-height: 14px;
  transition: color 0.2s;
  opacity: 0.7;
}
.char-counter--near { color: #D4800A; opacity: 1; }
.char-counter--max  { color: #C0392B; font-weight: 700; opacity: 1; }

/* ---- Input area ---- */

#chat-input-area {
  padding: 12px 16px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#user-input {
  flex: 1;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 22px;
  padding: 12px 18px;
  font-size: 16px; /* ≥16px empêche le zoom auto iOS sur focus */
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  resize: none;
  min-height: 46px;
  max-height: 120px;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#user-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27,107,74,0.08);
}

#user-input::placeholder { color: var(--text-muted); }

#send-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(27,107,74,0.2);
}

#send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(27,107,74,0.3);
}

#send-btn:disabled { opacity: 0.4; cursor: default; box-shadow: none; }

#send-btn svg { width: 20px; height: 20px; fill: #fff; }

/* ---- Loader ---- */

/* ---- Loader testimonial carousel (B1) ---- */
.loader-testimonial {
  width: 280px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.5s ease;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
}
.loader-testimonial.visible { opacity: 1; }
.loader-testimonial-text {
  font-size: 13px;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.5;
}
.loader-testimonial-author {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
}

/* ---- Loader greeting (S2) ---- */
.loader-greeting {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.01em;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  min-height: 30px;
}
.loader-greeting.visible {
  opacity: 1;
  transform: translateY(0);
}

#loader {
  position: fixed;
  inset: 0;
  background: #F5F7F5; /* cohérent avec body — pas de flash de couleur */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 100;
  transition: opacity 0.5s ease;
}

#loader.hidden { opacity: 0; pointer-events: none; }

.loader-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 280px;
  margin-bottom: 8px;
}

.loader-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease, color 0.3s ease;
}

.loader-step.visible {
  opacity: 1;
  transform: translateY(0);
  color: var(--text-secondary);
}

.loader-step.done {
  color: var(--primary);
}

.loader-step-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
}

.loader-step-icon .spinner-mini {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loader-step-icon .check-mark {
  color: var(--primary);
  font-weight: 700;
}

.loader-step-factor {
  font-size: 13px;
  color: #3A3A5E;
  padding-left: 28px;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.loader-step-factor.visible {
  opacity: 1;
  transform: translateX(0);
}

.loader-spinner {
  width: 56px;
  height: 56px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader-spinner::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loader-spinner-heart {
  width: 22px;
  height: 22px;
  color: var(--primary);
  animation: heartbeat 1.8s ease infinite;
  z-index: 1;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes heartbeat {
  0%, 100% { transform: scale(0.85); }
  14% { transform: scale(1.1); }
  28% { transform: scale(0.85); }
  42% { transform: scale(1.05); }
  56% { transform: scale(0.85); }
}

.loader-text {
  font-size: 14px;
  color: var(--text);
  transition: color 0.3s ease;
  text-align: center;
  font-weight: 500;
}

.loader-text.loader-text-success {
  color: var(--primary);
  font-weight: 600;
}

.loader-spinner.loader-spinner-done::before {
  border-color: var(--primary);
  border-top-color: var(--primary);
  animation: none;
}

.loader-spinner.loader-spinner-done .loader-spinner-heart {
  animation: none;
  transform: scale(1.1);
}

/* ---- Exit intent modal (S3) ---- */
#exit-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#exit-modal.visible {
  opacity: 1;
  pointer-events: auto;
}
.exit-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
}
.exit-modal-card {
  position: relative;
  z-index: 1;
  background: var(--white);
  border-radius: 24px 24px 0 0;
  padding: 28px 24px 32px;
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transform: translateY(60px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -8px 40px rgba(0,0,0,0.12);
  text-align: center;
}
#exit-modal.visible .exit-modal-card {
  transform: translateY(0);
}
.exit-modal-avatar {
  width: 56px;
  height: 56px;
  margin-bottom: 4px;
}
.exit-modal-avatar .avatar,
.exit-modal-avatar .avatar-placeholder {
  width: 56px !important;
  height: 56px !important;
  font-size: 20px !important;
}
.exit-modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.exit-modal-body {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.exit-modal-timer {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 6px 14px;
  border-radius: var(--radius-full);
}
.exit-modal-timer strong {
  color: #C0392B;
  font-weight: 700;
}
.exit-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 4px;
}
.exit-modal-btn-stay {
  padding: 15px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  font-family: 'DM Sans', sans-serif;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(27,107,74,0.25);
  transition: transform 0.15s;
}
.exit-modal-btn-stay:hover { transform: translateY(-1px); }
.exit-modal-btn-leave {
  padding: 12px;
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  border: none;
  cursor: pointer;
}

/* ---- Input hint (B11) ---- */
.input-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  padding: 4px 8px 0;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.25s ease, max-height 0.25s ease;
}
.input-hint.visible {
  opacity: 1;
  max-height: 30px;
}

/* ---- Error banner ---- */

#error-banner {
  display: none;
  background: #FDEDEC;
  border: 1px solid rgba(192,57,43,0.3);
  color: #C0392B;
  padding: 10px 16px;
  font-size: 13px;
  text-align: center;
  font-weight: 500;
}

/* ---- Responsive ---- */

/* ---- Dark mode désactivé par défaut (avatar 55-70 ans — light mode = confiance médicale) ---- */
/* Conservé sous [data-theme="dark"] pour opt-in futur */

[data-theme="dark"] {
  --primary: #2EAD74;
  --primary-light: #3BC882;
  --primary-pale: #0D2E1E;
  --bg: #0F0F13;
  --white: #1A1A24;
  --text: #EEEEF5;
  --text-secondary: #A0A0C0;
  --text-muted: #808098;
  --border: #2A2A3A;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.45);
}

[data-theme="dark"] body { background: #0F0F13; }
[data-theme="dark"] #chat-header { background: linear-gradient(135deg, #1A1A24 0%, #141420 100%); }
[data-theme="dark"] .persona-row .msg-bubble { background: #1E1E2E; border-color: #2A2A3A; }
[data-theme="dark"] #chat-messages { background: #0F0F13; }
[data-theme="dark"] #chat-input-area { background: rgba(26,26,36,0.95); }
[data-theme="dark"] #user-input { background: #12121A; color: var(--text); border-color: #2A2A3A; }
[data-theme="dark"] #loader { background: #0F0F13; }
[data-theme="dark"] .typing-bubble { background: #1E1E2E; border-color: #2A2A3A; }
[data-theme="dark"] .quick-reply-btn { background: #1A1A24; border-color: var(--primary); color: var(--primary); }
[data-theme="dark"] .quick-reply-btn:hover { background: var(--primary); color: #fff; }
[data-theme="dark"] .cta-card { background: #1A1A24; border-color: #2A2A3A; }
[data-theme="dark"] .cta-card.highlighted { background: linear-gradient(135deg, #0D2E1E 0%, #112819 100%); border-color: var(--primary); }
[data-theme="dark"] .exit-modal-card { background: #1A1A24; }
[data-theme="dark"] .scroll-fab { background: #1E1E2E; border-color: #2A2A3A; }
[data-theme="dark"] .scroll-fab svg { fill: var(--text-secondary); }

/* ---- Reduced motion ---- */

@media (prefers-reduced-motion: reduce) {
  .msg-row, .typing-row, .quick-reply-btn, .cta-section, .cta-card {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .typing-dot { animation: none; opacity: 0.6; }
  .status-dot { animation: none; }
  #chat-header .avatar.is-typing { animation: none; }
  .timer-bar.phase-final .timer-text { animation: none; }
}

/* ---- Safe area (iPhone notch / home indicator) ---- */

#chat-header {
  padding-top: max(12px, env(safe-area-inset-top));
}

#chat-input-area {
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

/* ---- Responsive ---- */

@media (max-width: 480px) {
  #chat-messages { padding: 16px 12px; }
  #chat-input-area { padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  #chat-header { padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); }
  .msg-bubble { font-size: 14px; }
}

/* ============================================================
   Desktop sidebar — caché sur mobile
   ============================================================ */

#desktop-sidebar { display: none; }

/* ============================================================
   Layout Desktop (≥800px) — deux colonnes : sidebar + chat
   ============================================================ */

@media (min-width: 800px) {

  html {
    background: linear-gradient(145deg, #1C3A28 0%, #0F2118 55%, #0A1A12 100%);
    min-height: 100vh;
  }

  body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
  }

  /* Wrapper deux colonnes */
  #desktop-layout {
    display: flex;
    flex-direction: row;
    width: min(1160px, 96vw);
    height: min(90vh, 900px);
    border-radius: 28px;
    overflow: hidden;
    box-shadow:
      0 40px 100px rgba(0, 0, 0, 0.45),
      0 8px 24px rgba(0, 0, 0, 0.25),
      0 0 0 1px rgba(255, 255, 255, 0.06);
  }

  /* ---- Sidebar ---- */
  #desktop-sidebar {
    display: flex;
    flex-direction: column;
    width: 300px;
    flex-shrink: 0;
    background: linear-gradient(175deg, #1A5C3A 0%, #154D30 55%, #0F3D24 100%); /* warm green — moins "tech", plus "nature/santé" */
    color: #fff;
    padding: 36px 24px 28px;
    overflow-y: auto;
    gap: 0;
    scrollbar-width: none;
  }

  #desktop-sidebar::-webkit-scrollbar { display: none; }

  .sidebar-avatar-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
  }

  .sidebar-avatar-inner {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(46, 173, 116, 0.6);
    box-shadow: 0 0 0 6px rgba(46, 173, 116, 0.12);
    flex-shrink: 0;
  }

  .sidebar-avatar-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #2EAD74, #1B6B4A);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -1px;
  }

  .sidebar-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
  }

  .sidebar-online-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(46, 173, 116, 0.15);
    border: 1px solid rgba(46, 173, 116, 0.3);
    padding: 4px 12px;
    border-radius: 9999px;
  }

  .sidebar-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2EAD74;
    animation: sidebar-pulse 2s ease infinite;
    flex-shrink: 0;
  }

  .sidebar-status-dot.offline { background: #9A9ABF; animation: none; }

  @keyframes sidebar-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(46,173,116,0.5); }
    50%       { box-shadow: 0 0 0 4px rgba(46,173,116,0); }
  }

  .sidebar-status-label {
    font-size: 12px;
    font-weight: 600;
    color: #2EAD74;
    letter-spacing: 0.02em;
  }

  .sidebar-name {
    font-size: 19px;
    font-weight: 700;
    color: #fff;
    text-align: center;
    line-height: 1.3;
    margin-bottom: 4px;
  }

  .sidebar-title {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.55);
    text-align: center;
    line-height: 1.5;
    margin-bottom: 4px;
  }

  .sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 18px 0;
    flex-shrink: 0;
  }

  .sidebar-credentials {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 9px;
  }

  .sidebar-credentials li {
    font-size: 12.5px;
    color: rgba(255, 255, 255, 0.75);
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.45;
  }

  .sidebar-credentials li span {
    flex-shrink: 0;
    font-size: 14px;
    margin-top: 0px;
  }

  .sidebar-testimonial {
    margin: 0;
    background: rgba(255, 255, 255, 0.06);
    border-left: 3px solid rgba(46, 173, 116, 0.5);
    border-radius: 0 8px 8px 0;
    padding: 12px 14px;
  }

  .sidebar-testimonial-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.6;
    font-style: italic;
    margin-bottom: 8px;
  }

  .sidebar-testimonial-author {
    font-size: 11px;
    color: rgba(46, 173, 116, 0.8);
    font-weight: 600;
  }

  .sidebar-trust {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .sidebar-trust li {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.45;
  }

  .sidebar-trust li span { flex-shrink: 0; }

  .sidebar-timer {
    background: rgba(46, 173, 116, 0.08);
    border: 1px solid rgba(46, 173, 116, 0.2);
    border-radius: 12px;
    padding: 12px 14px;
    margin-top: 20px;
  }

  .sidebar-timer-label {
    font-size: 12.5px;
    font-weight: 700;
    color: #2EAD74;
    text-align: center;
    margin-bottom: 8px;
    letter-spacing: 0.01em;
  }

  .sidebar-timer-track {
    height: 3px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
  }

  .sidebar-timer-progress {
    height: 100%;
    background: linear-gradient(90deg, #2EAD74, #3BC882);
    border-radius: 2px;
    transition: width 1s linear;
    width: 100%;
  }

  .sidebar-social-proof {
    margin-top: auto;
    padding-top: 18px;
    font-size: 11.5px;
    color: rgba(46, 173, 116, 0.7);
    text-align: center;
    font-weight: 500;
    letter-spacing: 0.01em;
  }

  /* Masquer le timer-bar dans le chat panel — la sidebar l'affiche */
  #timer-bar { display: none !important; }

  /* ---- Chat panel (#app) ---- */
  #app {
    flex: 1;
    min-width: 0;
    max-width: none;
    height: 100%;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
  }

  /* Header desktop : contexte de consultation uniquement — persona gérée par la sidebar */
  #chat-header {
    border-radius: 0;
    padding: 10px 20px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
  }

  /* Masquer l'avatar et l'identité complète — la sidebar les affiche déjà */
  #chat-header .avatar,
  #chat-header .avatar-placeholder {
    display: none;
  }

  /* Nom : plus petit, rôle de fil d'ariane plutôt que d'identité */
  #chat-header .header-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
  }

  #chat-header .header-name .verified-badge { display: none; }

  #chat-header .header-subtitle {
    font-size: 11px;
    color: var(--text-muted);
  }

  /* Statut "En ligne" reste visible — signal de disponibilité utile */
  #chat-header .header-status {
    font-size: 11.5px;
    color: var(--primary);
  }

  #chat-header .header-status .status-dot {
    width: 7px;
    height: 7px;
  }

  /* Quick replies : wrap au lieu de scroll horizontal */
  .quick-reply-wrap {
    flex-wrap: wrap;
    overflow-x: visible;
    overflow-y: visible;
    padding-bottom: 8px;
  }

  .quick-reply-btn {
    flex-shrink: 1;
    white-space: normal;
    line-height: 1.4;
  }

  /* Bulles plus larges */
  .persona-row .msg-bubble { max-width: 74%; }
  .user-row .msg-bubble    { max-width: 62%; }
}

/* Dark mode desktop adjustments (opt-in uniquement) */
@media (min-width: 800px) {
  [data-theme="dark"] html { background: linear-gradient(145deg, #050A07 0%, #081008 60%, #040804 100%); }
  [data-theme="dark"] #desktop-sidebar { background: linear-gradient(175deg, #12301F 0%, #0A1D13 60%, #070F0A 100%); }
}

/* ============================================================
   Overlay déconnexion — quand l'utilisateur clique "Quitter"
   ============================================================ */

/* ---- Reprise de session (S6-bis) ---- */
.msg-row.resumed { opacity: 0.55; }
.resume-separator {
  text-align: center;
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  margin: 12px 16px 8px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

#disconnected-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 20, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  padding: 24px;
}

#disconnected-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.disconnected-card {
  background: var(--white);
  border-radius: 24px;
  padding: 36px 28px 32px;
  max-width: 360px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  transform: translateY(24px) scale(0.96);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.20);
}

#disconnected-overlay.visible .disconnected-card {
  transform: translateY(0) scale(1);
}

.disconnected-avatar-wrap {
  position: relative;
  width: 72px;
  height: 72px;
}

.disconnected-avatar-wrap .avatar,
.disconnected-avatar-wrap .avatar-placeholder {
  width: 72px !important;
  height: 72px !important;
  font-size: 24px !important;
  filter: grayscale(0.5);
  opacity: 0.75;
}

.disconnected-status-dot {
  position: absolute;
  bottom: 3px;
  right: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #9A9ABF;
  border: 2.5px solid var(--white);
}

.disconnected-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}

.disconnected-body {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.65;
}

.disconnected-body strong {
  color: var(--text);
}

.disconnected-btn-resume {
  width: 100%;
  padding: 15px 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-size: 15px;
  font-weight: 700;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(27, 107, 74, 0.35);
  margin-top: 4px;
}

.disconnected-btn-resume:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(27, 107, 74, 0.40);
}

.disconnected-btn-resume:active {
  transform: scale(0.98) translateY(0);
}

.disconnected-disclaimer {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Disconnected card dark — opt-in uniquement */
[data-theme="dark"] .disconnected-card { background: #1A1A28; }
[data-theme="dark"] .disconnected-status-dot { border-color: #1A1A28; }
