/* ================================================
       IA'M FINE - PWA MOBILE STYLESHEET
       VERSION: 3.0 - REFACTORED WITH iOS/ANDROID DETECTION

       ⚠️ ARCHITECTURE:
       - Détection iOS via classe .is-ios ajoutée dans index.jsx
       - Séparation claire iOS vs Android pour éviter conflits
       - Safe-area optimisée selon l'OS
       - Styles PWA natifs pour expérience mobile premium

       📱 BREAKPOINTS:
       - Petit écran: ≤375px (iPhone SE, petits Android)
       - Moyen écran: 376-430px (iPhone 12/13/14, Android standards)
       - Desktop: >430px (tablettes, grands écrans)
       ================================================ */

/* ================================================
       VARIABLES CSS - DESIGN SYSTEM
       ================================================ */
:root {
  /* Couleurs principales */
  --pwa-primary: #ff4757;
  --pwa-primary-light: #ff6b6b;
  --pwa-primary-dark: #e63946;
  --pwa-primary-gradient: linear-gradient(45deg, #ff4757, #ff6b6b);
  --pwa-success: #10b981;

  /* Backgrounds */
  --pwa-bg-main: #0a0a0a;
  --pwa-bg-card: rgba(255, 255, 255, 0.05);
  --pwa-bg-elevated: rgba(255, 255, 255, 0.08);
  --pwa-bg-overlay: rgba(0, 0, 0, 0.85);

  /* Textes */
  --pwa-text-primary: #ffffff;
  --pwa-text-secondary: rgba(255, 255, 255, 0.7);
  --pwa-text-muted: rgba(255, 255, 255, 0.5);

  /* Bordures */
  --pwa-border: rgba(255, 255, 255, 0.1);
  --pwa-border-light: rgba(255, 255, 255, 0.2);
  --pwa-border-active: rgba(255, 107, 107, 0.5);

  /* Espacements */
  --pwa-spacing-xs: 4px;
  --pwa-spacing-sm: 8px;
  --pwa-spacing-md: 12px;
  --pwa-spacing-lg: 16px;
  --pwa-spacing-xl: 24px;
  --pwa-spacing-2xl: 32px;

  /* Radius */
  --pwa-radius-sm: 8px;
  --pwa-radius-md: 12px;
  --pwa-radius-lg: 20px;
  --pwa-radius-full: 50px;

  /* Shadows */
  --pwa-shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.25);
  --pwa-shadow-md: 0 6px 16px rgba(255, 107, 107, 0.15);
  --pwa-shadow-active: 0 3px 10px rgba(255, 107, 107, 0.15);

  /* Transitions */
  --pwa-transition: 0.3s ease;

  /* Layout - Safe Area & TabBar */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 55px;
  /* Hauteur boutons uniquement - safe-area gérée par tab-bar */
  --input-h: 90px;
}

/* ================================================
       RESET & BASE - TOUS APPAREILS
       ================================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Hide scrollbar */
  -ms-overflow-style: none; /* IE and Edge */
  scrollbar-width: none; /* Firefox */
}

/* Hide scrollbar for Chrome, Safari and Opera */
*::-webkit-scrollbar {
  display: none;
}

html {
  height: 100% !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  /* PWA: Remove fixed positioning to allow safe-area extension */
  position: static !important;
  overflow: visible !important;
  background: var(--pwa-bg-main);
}

body {
  height: 100% !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  /* PWA: Remove fixed positioning to allow safe-area extension */
  position: static !important;
  overflow: visible !important;
  background: var(--pwa-bg-main);
  color: var(--pwa-text-primary);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  width: 100%;
}

#root {
  /* PWA: Allow safe-area extension */
  height: 100% !important;
  min-height: 100vh !important;
  position: static !important;
  overflow: visible !important;
}

input,
textarea,
select {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-appearance: none;
}

button,
a,
.clickable {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.selectable {
  -webkit-user-select: text;
  user-select: text;
}

/* ================================================
       CONTAINER PRINCIPAL - TOUS APPAREILS
       ================================================ */
.pwa-app-container {
  /* ✅ FIX ANDROID: Force 100dvh first for modern browsers */
  height: 100dvh;
  /* ✅ FIX ANDROID: Fallback to JS calculated height */
  height: calc(var(--vh, 1vh) * 100);
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  background: var(--pwa-bg-main);
  position: relative;
  /* ✅ FIX ANDROID: Prevent scrolling on the container itself */
  overflow: hidden;
  padding-bottom: 0;
  margin-bottom: 0;
}

/* ✅ FIX ANDROID: Pas de padding sur main-content - chaque container gère son propre padding */
body:not(.is-ios) .pwa-main-content {
  padding-bottom: 0 !important;
}

/* Support iOS modernes : hauteur "dynamic viewport" */
@supports (height: 100dvh) {
  .pwa-app-container {
    height: 100dvh !important;
    /* Also try JS calc if available for perfect match */
    height: calc(var(--vh, 1dvh) * 100) !important;
    overflow: hidden;
  }
}

/* Support iOS anciens : hauteur "small viewport" */
@supports (height: 100svh) {
  .pwa-app-container {
    height: 100% !important;
    /* Rely on body height */
    min-height: 100% !important;
    overflow: hidden;
  }
}

/* Limite largeur sur très grands écrans (tablettes/desktop) */
@media (min-width: 769px) {
  .pwa-app-container {
    max-width: 600px;
  }
}

/* Landing page SANS scroll (bloqué) */
.pwa-app-container:not(:has(.pwa-main-content)) {
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ================================================
       ANIMATIONS GLOBALES - TOUS APPAREILS
       ================================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@keyframes breathingAuraPWA {
  0%,
  100% {
    opacity: 0.5;
    transform: scale(1);
  }

  50% {
    opacity: 0.85;
    transform: scale(1.06);
  }
}

@keyframes pwsFall {
  from {
    transform: translateY(-100vh) translateX(0);
  }

  to {
    transform: translateY(calc(100vh + 100px)) translateX(20px);
  }
}

@keyframes questionChange {
  0%,
  100% {
    opacity: 1;
    transform: translateY(0);
  }

  40% {
    opacity: 0;
    transform: translateY(-5px);
  }

  60% {
    opacity: 0;
    transform: translateY(5px);
  }
}

@keyframes msgAppear {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes blink {
  0%,
  50% {
    opacity: 1;
  }

  51%,
  100% {
    opacity: 0;
  }
}

@keyframes pulseLoad {
  0%,
  100% {
    opacity: 0.7;
  }

  50% {
    opacity: 1;
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.4;
    transform: scale(1);
  }

  50% {
    opacity: 0.8;
    transform: scale(1.1);
  }
}

@keyframes authCardSlide {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes pwaScaleIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translate(-50%, -45%);
  }

  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ================================================
       WARM RESUME TRANSITION OVERLAY - PWA
       🔧 FIX v2: Overlay to mask flash during state restoration
       ================================================ */
.pwa-warm-resume-overlay {
  position: fixed;
  inset: 0;
  background: var(--pwa-bg-main);
  z-index: 99999;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s ease-out;
}

.pwa-warm-resume-overlay.fade-out {
  opacity: 0;
}

.pwa-warm-resume-overlay.hidden {
  display: none;
}

/* Alternative: Apply to body during resume */
body.pwa-resuming {
  /* Prevent any visual flash during state restoration */
  visibility: hidden;
}

body.pwa-resuming.ready {
  visibility: visible;
  animation: fadeIn 0.2s ease-out;
}

/* ================================================
       PARTICULES ANIMÉES - TOUS APPAREILS
       ================================================ */
.pwa-snow-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.4;
}

.pwa-snowflake {
  position: absolute;
  width: 2px;
  height: 2px;
  background: rgba(255, 107, 107, 0.4);
  border-radius: 50%;
  opacity: 0.5;
  animation: pwsFall linear infinite;
}

/* ================================================
       STYLES COMMUNS - HEADER, LOGO, BOUTONS
       ================================================ */
.pwa-header {
  position: relative;
  z-index: 10;
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-top));
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  height: 56px;
  min-height: 56px;
  flex-shrink: 0;
}

/* Fix encoche iPhone - padding supplémentaire */
body.is-ios .pwa-header {
  padding-top: calc(18px + var(--safe-top));
  /* ✅ AJOUTÉ : 12px → 18px (+6px) */
}

.pwa-header-pro {
  position: relative;
  z-index: 100;
  background: rgba(10, 10, 10, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  padding-bottom: 0px;
  /* ✅ CHANGÉ : 4px → 0px pour supprimer l'espace gris */
}

.pwa-header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  padding-top: calc(14px + var(--safe-top));
  height: 48px;
}

/* Fix encoche iPhone - padding supplémentaire */
body.is-ios .pwa-header-container {
  padding-top: calc(20px + var(--safe-top));
  /* ✅ AJOUTÉ : 14px → 20px (+6px) */
}

/* Logo et titres */
.pwa-header-logo-section,
.pwa-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.pwa-logo-wrapper,
.pwa-logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.pwa-logo-wrapper img,
.pwa-logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.pwa-header-titles,
.pwa-logo-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  text-align: left;
}

.pwa-header-main-title {
  font-size: 15px;
  font-weight: 600;
  color: #ff6b6b;
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.3px;
  display: block;
  text-align: left;
  width: 100%;
}

.pwa-header-beta,
.pwa-header-heartbreak,
.pwa-logo-heartbreak {
  font-size: 6.5px;
  background: linear-gradient(45deg, #ff4757, #ff6b6b, #ff8a8a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  opacity: 0.6;
  font-weight: 400;
  margin-top: 1px;
  display: block;
  text-align: left;
  width: 100%;
}

@keyframes heartbreakGradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.pwa-logo-text {
  font-size: 15px;
  font-weight: 700;
  background: linear-gradient(45deg, #ff4757, #ff6b6b, #ff8a8a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.5px;
  margin-top: -2px;
}

/* Boutons header */
.pwa-header-actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pwa-header-action-btn:not(.pwa-cta-btn) {
  width: 28px;
  height: 28px;
  border-radius: 14px;
  background: rgba(255, 107, 107, 0.08);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  position: relative;
  color: #ff6b6b;
}

.pwa-header-action-btn:hover {
  background: rgba(255, 107, 107, 0.12);
  transform: scale(1.05);
}

.pwa-header-action-btn:active {
  transform: scale(0.95);
}

.pwa-header-action-btn svg {
  width: 14px;
  height: 14px;
  color: #ff6b6b;
  stroke-width: 1.8;
}

/* ✨ PULSE ANIMATION - Analysis button when unseen data available */
@keyframes analysisPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.4);
  }

  50% {
    transform: scale(1.08);
    box-shadow: 0 0 0 6px rgba(255, 107, 107, 0);
  }

  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 107, 107, 0);
  }
}

.pwa-analysis-trigger.has-data {
  animation: analysisPulse 2s ease-in-out infinite;
}

/* Désactiver animation au hover pour éviter conflit */
.pwa-analysis-trigger.has-data:hover {
  animation: none;
  transform: scale(1.05);
}

.pwa-cta-cluster .pwa-cta-btn {
  width: auto;
  height: 30px;
  border-radius: 9999px;
  padding: 6px 14px;
  background: rgba(255, 107, 107, 0.08);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  color: #ff6b6b;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.pwa-cta-cluster .pwa-analytics-btn {
  width: 34px;
  min-width: 34px;
  padding: 0 8px;
  border-radius: 8px;
}

/* Bouton profil */
.pwa-profile-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--pwa-transition);
  position: relative;
  border-radius: 50%;
}

.pwa-profile-btn:not(.connected) {
  color: rgba(255, 255, 255, 0.4);
  background: transparent;
}

.pwa-profile-btn:not(.connected):hover {
  background: transparent;
}

.pwa-profile-btn.connected {
  background: transparent;
  color: #ff4757;
  filter: drop-shadow(0 0 8px rgba(255, 82, 82, 0.4));
}

.pwa-profile-btn.connected:hover,
.pwa-profile-btn.connected:active {
  background: transparent;
  filter: drop-shadow(0 0 12px rgba(255, 82, 82, 0.6));
  transform: scale(1.05);
}

.pwa-profile-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  transition: all 0.3s ease;
}

.pwa-profile-btn.connected svg {
  stroke-width: 2.5;
}

/* Menu profil dropdown */
.pwa-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 998;
  animation: fadeIn 0.15s ease;
}

.pwa-profile-menu-pro {
  position: fixed;
  top: calc(52px + var(--safe-top));
  right: 16px;
  width: 280px;
  background: #1a1a1a;
  border: 0.5px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.8),
    0 2px 10px rgba(0, 0, 0, 0.5);
  z-index: 999;
  animation: slideDown 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.pwa-menu-user-section {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: rgba(255, 107, 107, 0.03);
}

.pwa-user-info {
  flex: 1;
  min-width: 0;
}

.pwa-user-email,
.pwa-profile-menu-pro .pwa-user-email {
  font-size: 14px;
  color: #ff6b6b;
  font-weight: 600;
  letter-spacing: -0.2px;
  text-shadow: 0 0 8px rgba(255, 107, 107, 0.3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pwa-menu-separator {
  height: 0.5px;
  background: rgba(255, 255, 255, 0.06);
}

.pwa-menu-options {
  padding: 6px;
}

.pwa-menu-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: #ffffff;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pwa-menu-option:active {
  background: rgba(255, 255, 255, 0.06);
}

.pwa-option-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pwa-option-arrow {
  color: rgba(255, 255, 255, 0.3);
}

/* ================================================
       BOTTOM SHEETS, MODALS, PANELS - COMMUNS
       ================================================ */

/* Bottom sheet des modes */
.pwa-modes-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

.pwa-modes-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1a1a1a;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  z-index: 1001;
  height: 30vh;
  max-height: 250px;
  min-height: 180px;
  transform: translateY(100%);
  transition: transform 0.22s ease-out;
  will-change: transform;
}

.pwa-modes-sheet.open {
  transform: translateY(0);
}

.pwa-sheet-handle {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  margin: 8px auto 0;
}

.pwa-sheet-content {
  padding: 20px;
  height: calc(100% - 20px);
  display: flex;
  align-items: center;
}

.pwa-modes-list {
  display: flex;
  gap: 12px;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.pwa-modes-list::-webkit-scrollbar {
  display: none;
}

.pwa-modes-list .pwa-mode-option {
  flex-shrink: 0;
  min-width: 80px;
  height: 80px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.pwa-modes-list .pwa-mode-option:active {
  transform: scale(0.95);
}

.pwa-modes-list .pwa-mode-option.active {
  background: rgba(255, 107, 107, 0.15);
  border-color: #ff6b6b;
}

.pwa-mode-icon {
  font-size: 24px;
}

.pwa-mode-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  text-transform: capitalize;
}

.pwa-mode-subtitle {
  font-size: 10px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 2px;
  line-height: 1;
}

.pwa-modes-list .pwa-mode-option.active .pwa-mode-subtitle {
  color: rgba(255, 107, 107, 0.7);
}

.pwa-modes-list .pwa-mode-option.active .pwa-mode-label {
  color: #ff6b6b;
}

.pwa-mode-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  background: #ff6b6b;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: white;
  font-weight: bold;
}

.pwa-modes-help-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  color: #8b8b8b;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
}

.pwa-modes-help-btn:active {
  background: rgba(255, 255, 255, 0.06);
  transform: scale(0.98);
}

/* Modal d'aide */
.pwa-help-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10002;
  animation: fadeIn 0.2s ease;
}

/* ⭐ HELP MODAL - Layout flex professionnel */
.pwa-help-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 400px;
  max-height: 80vh;
  background: #1a1a1a;
  border-radius: 20px;
  z-index: 10003;
  animation: modalSlideIn 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.1);

  /* Flex layout pour scroll professionnel */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header fixe - ne scroll pas */
.pwa-help-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: #1a1a1a;
}

.pwa-help-header h4 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #ffffff;
}

.pwa-help-close {
  background: none;
  border: none;
  color: #8b8b8b;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
  cursor: pointer;
}

.pwa-help-close:active {
  color: #ffffff;
}

/* Intro fixe - ne scroll pas */
.pwa-help-intro {
  flex-shrink: 0;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: #1a1a1a;
}

.pwa-help-intro p {
  margin: 0;
  font-size: 14px;
  color: #b0b0b0;
  line-height: 1.5;
  text-align: center;
  font-style: italic;
}

/* ⭐ Zone scrollable des modes */
.pwa-help-modes {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 107, 107, 0.3) transparent;
}

.pwa-help-modes::-webkit-scrollbar {
  width: 4px;
}

.pwa-help-modes::-webkit-scrollbar-track {
  background: transparent;
}

.pwa-help-modes::-webkit-scrollbar-thumb {
  background: rgba(255, 107, 107, 0.3);
  border-radius: 2px;
}

.pwa-help-mode {
  margin-bottom: 24px;
}

.pwa-help-mode:last-child {
  margin-bottom: 0;
}

.pwa-help-mode-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.pwa-help-mode-icon {
  font-size: 20px;
}

.pwa-help-mode-name {
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
}

.pwa-help-mode-detail {
  margin: 0;
  font-size: 13px;
  color: #9b9b9b;
  line-height: 1.5;
  padding-left: 30px;
}

/* Panneau d'analyse */
.pwa-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 98;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

/* ⭐ ANALYSIS PANEL - Layout flex professionnel */
.pwa-analysis-panel {
  /* Position */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 99;

  /* Apparence */
  background: var(--pwa-bg-main);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  animation: slideUp 0.3s ease;

  /* Flex layout pour scroll professionnel */
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header fixe - ne scroll pas */
.pwa-panel-header {
  flex-shrink: 0;
  padding: 8px 20px 16px;
  text-align: center;
  position: relative;
  background: var(--pwa-bg-main);
}

.pwa-panel-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--pwa-text-primary);
  margin: 12px 0 0;
}

.pwa-panel-handle {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  margin: 0 auto 8px;
}

/* ⭐ Zone scrollable du panel */
.pwa-panel-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  padding-bottom: calc(20px + var(--safe-bottom));
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 107, 107, 0.3) transparent;
}

.pwa-panel-content::-webkit-scrollbar {
  width: 4px;
}

.pwa-panel-content::-webkit-scrollbar-track {
  background: transparent;
}

.pwa-panel-content::-webkit-scrollbar-thumb {
  background: rgba(255, 107, 107, 0.3);
  border-radius: 2px;
}

.pwa-panel-close {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1.5px solid rgba(255, 107, 107, 0.6);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.4),
    0 0 8px rgba(255, 107, 107, 0.2);
  flex-shrink: 0;
}

.pwa-panel-close:hover {
  border-color: rgba(255, 107, 107, 0.8);
  color: #ff6b6b;
  background: rgba(0, 0, 0, 0.95);
  transform: scale(1.05);
}

.pwa-panel-close:active {
  transform: scale(0.95);
}

/* Story section */
/* Note: horizontal margin handled by inline styles (0 20px) in PWAAnalysisPanel.jsx */
.pwa-story-section {
  margin-bottom: 24px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 107, 107, 0.2);
  border-radius: 16px;
}

.pwa-story-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.pwa-section-label {
  font-size: 12px;
  font-weight: 600;
  color: #9ca3af;
  letter-spacing: 0.3px;
  margin-bottom: 12px;
}

.pwa-status-badge {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
}

/* Toxicity widget */
.pwa-toxicity-widget {
  background: transparent;
  border-radius: 12px;
  padding: 12px;
}

.pwa-toxicity-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.pwa-toxicity-label {
  font-size: 12px;
  color: var(--pwa-text-secondary);
}

.pwa-toxicity-percent {
  font-size: 20px;
  font-weight: 700;
  color: var(--pwa-primary);
}

.pwa-toxicity-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.pwa-toxicity-progress {
  height: 100%;
  background: var(--pwa-primary);
  transition: width 0.5s ease;
  border-radius: 4px;
}

.pwa-toxicity-progress[data-level="high"] {
  background: linear-gradient(90deg, #ff6b6b, #dc2626);
}

.pwa-toxicity-progress[data-level="medium"] {
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
}

.pwa-toxicity-progress[data-level="low"] {
  background: linear-gradient(90deg, #34d399, #10b981);
}

/* Radar section */
/* Note: horizontal padding handled by inline styles (0 20px) in HeartRadarSection.jsx */
.pwa-radar-section {
  margin-bottom: 24px;
}

.pwa-radar-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.pwa-radar-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  transition: all 0.2s;
}

.pwa-radar-card.critical {
  background: rgba(255, 68, 68, 0.1);
  border-color: rgba(255, 68, 68, 0.3);
}

.pwa-radar-card.warning {
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.3);
}

.pwa-radar-card.mild {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
}

.pwa-radar-card.positive {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
}

.pwa-radar-emoji {
  display: block;
  font-size: 20px;
  margin-bottom: 4px;
}

.pwa-radar-label {
  font-size: 11px;
  color: var(--pwa-text-primary);
  font-weight: 500;
}

/* ================================================
       LANDING PAGE - TOUS APPAREILS
       ================================================ */

/* Heartbreak link - position above safe-area in PWA */
.pwa-heartbreak-link-wrapper {
  bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px)) !important;
}

.pwa-landing-content {
  flex: 1;
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 24px 20px 24px;
  padding-top: calc(10px + 2vh);
  /* Title higher */
  animation: fadeInUp 0.6s ease-out;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.pwa-title-section {
  text-align: center;
  padding-top: 5px;
  padding-bottom: 25px;
  /* More space after subtitle */
  flex-shrink: 1;
  width: 100%;
}

.pwa-main-title {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 2px;
  margin-bottom: 16px;
  color: transparent;
  background: transparent;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
  text-transform: uppercase;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.6));
}

.pwa-main-title .title-word {
  display: inline-block;
  background: #ff4757;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
  opacity: 0;
  animation: cinematicFade 0.8s cubic-bezier(0.23, 1, 0.32, 1) both;
  margin-right: -2px;
}

.pwa-main-title .word-1 {
  animation-delay: 0.3s;
}
.pwa-main-title .word-2 {
  animation-delay: 0.8s;
}
.pwa-main-title .word-3 {
  animation-delay: 1.3s;
}

.pwa-subtitle {
  font-size: 15px;
  color: #ff6b6b;
  text-shadow: 0 0 10px rgba(255, 107, 107, 0.4);
  letter-spacing: 1.5px;
  font-weight: 600;
  font-family: "Courier New", monospace;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
  max-width: min(90vw, 540px);
  min-height: 2.7em;
  display: inline-block;
  margin-top: 8px;
}

.pwa-subtitle-cursor {
  margin-left: 2px;
  opacity: 0;
}

.pwa-subtitle-cursor.visible {
  opacity: 1;
  animation: blink 0.7s infinite;
}

.pwa-subtitle-cursor.hidden {
  opacity: 0;
  animation: none;
}

.pwa-question-container {
  width: 100%;
  max-width: 380px;
  margin: 15px auto;
  background: linear-gradient(
    135deg,
    rgba(10, 10, 10, 0.85) 0%,
    rgba(20, 10, 15, 0.75) 100%
  );
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 2px solid rgba(255, 107, 107, 0.6);
  border-radius: 35px;
  overflow: visible;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
  flex-shrink: 1;
}

.pwa-question-text {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--pwa-text-primary);
  text-align: center;
  line-height: 1.3;
  padding: 1.2rem 1.4rem 1rem;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  overflow: visible;
}

.pwa-question-text.changing {
  animation: questionChange 0.3s ease;
}

.pwa-choice-buttons {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0 1rem 1rem;
  gap: 0.5rem;
}

.pwa-choice-btn {
  width: 100%;
  padding: 0.8rem 1rem;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
  font-family: inherit;
  position: relative;
  overflow: hidden;
  z-index: 1;
  box-shadow: 0 0 3px rgba(255, 255, 255, 0.1);
}

.pwa-choice-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 107, 107, 0.5);
  transform: translateY(-2px);
  color: rgba(255, 255, 255, 0.8);
}

.pwa-choice-btn.selected {
  background: rgba(255, 107, 107, 0.2);
  border-color: rgba(255, 107, 107, 0.8);
  box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
  text-shadow: 0 0 12px rgba(255, 107, 107, 0.5);
  color: #ffffff;
}

.pwa-choice-btn > div:first-child {
  font-weight: 700;
  font-size: 1.15rem;
  margin-bottom: 0.25rem;
}

.pwa-btn-subtitle {
  font-size: 0.85rem;
  opacity: 0.85;
  font-weight: 400;
  font-style: italic;
}

.pwa-start-btn {
  display: block;
  width: 100%;
  max-width: 380px;
  margin: 50px auto 10px;
  padding: 1rem 2rem;
  background: rgba(255, 71, 87, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: white;
  text-decoration: none;
  border: 2px solid rgba(255, 71, 87, 1);
  border-radius: 50px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: visible;
  text-align: center;
  flex-shrink: 0;
  box-shadow:
    0 4px 20px rgba(255, 71, 87, 0.5),
    0 0 30px rgba(255, 71, 87, 0.3);
  z-index: 1;
}

@keyframes pwaStartPulse {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.pwa-start-pulse {
  display: none;
  width: 6px;
  height: 6px;
  margin-left: 0.55rem;
  border-radius: 999px;
  background: currentColor;
  box-shadow:
    10px 0 0 currentColor,
    20px 0 0 currentColor;
  animation: pwaStartPulse 0.9s ease-in-out infinite;
  vertical-align: middle;
}

.pwa-start-btn.is-starting .pwa-start-pulse {
  display: inline-block;
}

.pwa-start-btn::after {
  content: "";
  position: absolute;
  top: -10px;
  left: -10px;
  right: -10px;
  bottom: -10px;
  background: radial-gradient(
    ellipse at center,
    rgba(255, 71, 87, 0.6) 0%,
    rgba(255, 71, 87, 0.3) 50%,
    transparent 70%
  );
  border-radius: 55px;
  z-index: -1;
  animation: breathingAuraPWA 2.5s ease-in-out infinite;
  pointer-events: none;
}

.pwa-start-btn:hover,
.pwa-start-btn:active {
  transform: translateY(-2px);
  background: rgba(255, 71, 87, 0.45);
  border-color: rgba(255, 71, 87, 1);
  box-shadow:
    0 6px 25px rgba(255, 71, 87, 0.6),
    0 0 35px rgba(255, 71, 87, 0.4);
}

.pwa-start-btn:active {
  transform: scale(0.97);
}

.pwa-start-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  background: rgba(255, 107, 107, 0.5);
}

.pwa-start-btn.is-starting:disabled {
  opacity: 1;
  cursor: progress;
  box-shadow:
    0 4px 20px rgba(255, 71, 87, 0.5),
    0 0 30px rgba(255, 71, 87, 0.3);
}

/* ================================================
       CHAT INTERFACE - TOUS APPAREILS
       ================================================ */
.pwa-main-content {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #0a0a0a;
  position: relative;
  z-index: 2;
  overflow: visible;
  padding-bottom: 0 !important;
  /* No padding needed - input is now fixed, chat-container handles spacing */
  /* overflow: visible allows child components to handle their own scrolling */
}

.pwa-chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
  background: var(--pwa-bg-main);
  /* Reserve space for the measured fixed composer plus the tab bar. */
  padding-bottom: calc(var(--pwa-chat-input-height, 110px) + 55px) !important;
}

.pwa-chat-container .scroll-to-bottom-fab--pwa {
  position: fixed;
  width: 26px;
  height: 26px;
  right: max(16px, calc(env(safe-area-inset-right, 0px) + 12px));
  bottom: calc(
    var(--pwa-chat-input-height, 72px) + 69px +
      env(safe-area-inset-bottom, 0px) * 0.35
  );
  z-index: 10001;
  border-color: rgba(255, 107, 107, 0.24);
  box-shadow:
    0 5px 14px rgba(0, 0, 0, 0.22),
    0 0 0 1px rgba(255, 107, 107, 0.05);
}

.pwa-chat-container .scroll-to-bottom-fab--pwa.is-pulsing {
  animation: scrollToBottomFabPulsePwa 1.8s ease-in-out infinite;
}

@keyframes scrollToBottomFabPulsePwa {
  0%,
  100% {
    box-shadow:
      0 5px 14px rgba(0, 0, 0, 0.22),
      0 0 0 0 rgba(255, 107, 107, 0.1);
  }

  50% {
    box-shadow:
      0 7px 16px rgba(0, 0, 0, 0.24),
      0 0 0 6px rgba(255, 107, 107, 0);
  }
}

.pwa-scroll-bottom-sentinel {
  width: 100%;
  height: 1px;
  flex: 0 0 1px;
  pointer-events: none;
}

.pwa-scroll-debug-badge {
  position: fixed;
  top: calc(78px + var(--safe-top, 0px));
  left: 12px;
  z-index: 10002;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(10, 10, 10, 0.92);
  border: 1px solid rgba(255, 107, 107, 0.26);
  color: #f7f7f7;
  font-size: 11px;
  line-height: 1.25;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.34);
  pointer-events: none;
}

/* ✅ FIX: Dashboard Progress sections - Full height with space for tab bar */
.pwa-dashboard-container {
  flex: 1 !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  /* padding-bottom moved to .pwa-progress-scroll to avoid double padding */
  padding-bottom: 0 !important;
  height: 100% !important;
}

/* ✅ FIX: TextLab container - Full height with proper scroll */
.pwa-textlab-container {
  flex: 1 !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important;
}

/* ✅ FIX iOS: TextLab container padding-top - fallback (overridden by PWATextLabScreen.css) */
body.is-ios .pwa-textlab-container {
  padding-top: calc(120px + var(--safe-top, 0px)) !important;
}

/* ✅ FIX: Loading state - no padding (same positioning as Scan) */
body.is-ios .pwa-textlab-container.is-loading {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

/* ✅ FIX: Progress nav sticky - container scrollable */
.pwa-progress-scroll {
  flex: 1 !important;
  min-height: 0 !important;
  display: block !important;
  position: relative !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior: contain !important;
  /* Space for tab bar at bottom - aligned with Context/Scan */
  padding-bottom: calc(
    70px + env(safe-area-inset-bottom, 0px) * 0.5
  ) !important;
}

/* ✅ FIX: Progress nav sticky - la nav elle-même */
.pwa-progress-nav {
  position: -webkit-sticky !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 100 !important;
  background: #0a0a0a !important;
  padding: 10px 8px !important;
  box-sizing: border-box !important;
}

/* ✅ FIX iOS: La nav Progress doit être COLLÉE au header PWA */
/* Le header fait ~48-50px de hauteur visible (sans safe-area) */
body.is-ios .pwa-progress-nav {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  z-index: 999 !important;
  background: #0a0a0a !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding-top: 6px !important;
  padding-bottom: 6px !important;
  padding-left: 8px !important;
  padding-right: 8px !important;
  min-height: 44px !important;
  box-sizing: border-box !important;
  border-bottom: 1px solid rgba(255, 107, 107, 0.15) !important;
  border-top: none !important;
  /* Header visible height ~56px + safe-top */
  top: calc(39px + var(--safe-top, 0px)) !important;
}

/* ✅ FIX iOS PWA: Scroll padding - compensate for fixed header + tabs */
/* Header (~39px + safe-top) + Tabs (~50px) = ~89px + safe-top (same as Scan) */
body.is-ios .pwa-progress-scroll {
  padding-top: calc(89px + var(--safe-top, 0px)) !important;
}

/* ═══════════════════════════════════════════════════════════════
   iOS MOBILE BROWSER FIX (not PWA standalone) - Progress page
   In mobile browser, --safe-top is 0, so we need fixed values
   ═══════════════════════════════════════════════════════════════ */

@media not (display-mode: standalone) {
  body.is-ios .pwa-progress-nav {
    /* Mobile browser: header ~58px (no safe-top) */
    top: 58px !important;
  }

  body.is-ios .pwa-progress-scroll {
    /* Mobile browser: header(58px) + tabs(50px) = 108px */
    padding-top: 108px !important;
  }
}

/* ✅ FIX: Boutons de section en PWA */
.pwa-progress-nav button {
  font-size: 10px !important;
  padding: 0.35rem 0.55rem !important;
}

.pwa-progress-nav button svg {
  width: 12px !important;
  height: 12px !important;
}

/* ⭐ MESSAGES AREA - Scroll professionnel */
.pwa-messages-area {
  /* Layout */
  flex: 1;
  min-height: 0;
  position: relative;
  z-index: 1;

  /* Scroll comportement */
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  touch-action: pan-y;

  /* Optimisation performance */
  will-change: scroll-position;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);

  /* Padding simple - input is now in flex flow, not fixed */
  padding: 12px 16px 12px 16px;
}

.pwa-messages-area > .pwa-story-section,
.pwa-messages-area > .pwa-radar-section,
.pwa-messages-area > .pwa-toxicity-widget,
.pwa-messages-area [data-block="trend"],
.pwa-messages-area [data-ui-block="trend"] {
  display: none;
}

.pwa-analysis-panel .pwa-story-section,
.pwa-analysis-panel .pwa-radar-section,
.pwa-analysis-panel .pwa-toxicity-widget {
  display: block;
}

/* Messages */
.pwa-welcome-message {
  padding: 40px 20px;
  text-align: center;
}

.pwa-welcome-text {
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  background: linear-gradient(45deg, #ff4757, #ff6b6b, #ff8a8a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-family: "Courier New", monospace;
  white-space: pre-wrap;
  line-height: 1.6;
  display: block;
  max-width: 90%;
  margin: 0 auto;
  text-align: center;
}

.pwa-welcome-highlight {
  position: relative;
  margin: 18px auto 0;
  display: inline-block;
  max-width: calc(100vw - 28px);
  padding: 18px 0 0;
  color: rgba(255, 224, 224, 0.92);
  font-size: 0.8rem;
  font-style: italic;
  font-weight: 720;
  line-height: 1.32;
  letter-spacing: 0;
  text-align: center;
  white-space: normal;
  text-shadow: 0 0 18px rgba(255, 107, 107, 0.32);
  isolation: isolate;
  will-change: filter, text-shadow;
}

.pwa-welcome-highlight .intro-highlight-line {
  position: relative;
  z-index: 1;
  display: block;
  white-space: nowrap;
}

.pwa-welcome-highlight .intro-highlight-line.is-bridge {
  color: rgba(255, 244, 244, 0.98);
  font-style: normal;
  letter-spacing: 0;
}

.pwa-welcome-highlight .intro-highlight-line.is-detail {
  margin-top: 4px;
  opacity: 0.96;
}

@media (min-width: 360px) {
  .pwa-welcome-highlight {
    font-size: 0.84rem;
  }
}

@media (min-width: 390px) {
  .pwa-welcome-highlight {
    font-size: 0.88rem;
  }
}

@media (min-width: 430px) {
  .pwa-welcome-highlight {
    font-size: 0.94rem;
  }
}

@media (min-width: 520px) {
  .pwa-welcome-highlight {
    font-size: 1.02rem;
  }
}

.pwa-welcome-highlight::before {
  content: "";
  display: block;
  width: 100%;
  height: 1px;
  margin: 0 auto 14px;
  background: linear-gradient(
    90deg,
    rgba(255, 107, 107, 0),
    rgba(255, 107, 107, 0.7),
    rgba(255, 107, 107, 0)
  );
  transform-origin: left center;
  position: relative;
  z-index: 1;
}

.pwa-welcome-highlight::after {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 14px -28px -10px;
  border-radius: 999px;
  background: radial-gradient(
    ellipse at center,
    rgba(255, 107, 107, 0.3) 0%,
    rgba(255, 71, 87, 0.18) 38%,
    rgba(255, 71, 87, 0) 72%
  );
  filter: blur(16px);
  opacity: 0.28;
  pointer-events: none;
}

.pwa-welcome-highlight.is-animated::after {
  animation: pwaWelcomeHighlightAura 2.6s ease-in-out infinite;
}

.pwa-welcome-highlight.is-paused,
.pwa-welcome-highlight.is-paused::before,
.pwa-welcome-highlight.is-paused::after {
  animation: none;
}

@keyframes pwaWelcomeHighlightAura {
  0%,
  100% {
    filter: blur(16px);
    opacity: 0.22;
  }
  50% {
    filter: blur(20px);
    opacity: 0.62;
  }
}

.pwa-messages-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 8px;
  /* Extra space for last message action buttons */
}

.pwa-message-wrapper {
  display: flex;
  animation: msgAppear 0.2s ease-out;
}

.pwa-message-wrapper.user {
  justify-content: flex-end;
}

.pwa-message-wrapper.assistant {
  justify-content: flex-start;
}

.pwa-message-bubble {
  max-width: 75%;
  min-width: 60px;
  display: flex;
  flex-direction: column;
  contain: content;
}

.pwa-message-text {
  padding: 9px 14px;
  font-size: 14px;
  line-height: 1.4;
  border-radius: 18px;
  word-wrap: break-word;
  white-space: pre-wrap;
  color: white;
}

.pwa-message-wrapper.user .pwa-message-text {
  background: rgba(255, 107, 107, 0.12);
  color: #cccccc;
  border: 1.5px solid rgba(255, 107, 107, 0.35);
  border-bottom-right-radius: 4px;
  box-shadow:
    0 4px 16px rgba(255, 107, 107, 0.18),
    0 1px 2px rgba(0, 0, 0, 0.15);
}

.pwa-message-wrapper.assistant .pwa-message-text {
  background: rgba(20, 20, 20, 0.95);
  color: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 71, 87, 0.3);
  border-bottom-left-radius: 4px;
  position: relative;
}

/* Liseré rouge en haut du message bot (identique Web) */
.pwa-message-wrapper.assistant .pwa-message-text::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 71, 87, 0.5),
    transparent
  );
  border-radius: 18px 18px 0 0;
}

.pwa-message-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}

/* ✅ P1 FIX: Message actions row styling */
.pwa-message-actions-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  margin-top: 6px;
}

.pwa-action-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  min-width: 28px;
  min-height: 28px;
  padding: 6px;
  border-radius: 6px;
  color: rgba(180, 180, 180, 0.6);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pwa-action-btn:hover,
.pwa-action-btn:active {
  color: var(--pwa-primary);
  background: rgba(255, 107, 107, 0.1);
}

/* ✅ P1 FIX: Active feedback states */
.pwa-action-btn.active-feedback {
  color: #ff6b6b !important;
  transform: scale(1.15);
}

.pwa-action-btn.active-feedback-neg {
  color: #ff4757 !important;
  transform: scale(1.15);
}

.pwa-action-btn.copied {
  color: var(--pwa-primary) !important;
}

/* ✅ FIX: Selected feedback states - two-tone red/rose from brand palette */
.pwa-action-btn.feedback-selected {
  color: #ff6b6b !important;
  cursor: default;
  opacity: 1 !important;
  animation: feedbackPop 0.3s ease;
}

.pwa-action-btn.feedback-selected-neg {
  color: #ff4757 !important;
  cursor: default;
  opacity: 1 !important;
  animation: feedbackPop 0.3s ease;
}

@keyframes feedbackPop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

.pwa-action-btn:disabled {
  cursor: default;
  pointer-events: none;
}

/* ✅ AUDIT FIX: WCAG 2.4.7 Focus visible for keyboard navigation */
.pwa-action-btn:focus-visible {
  outline: 2px solid #ff6b6b;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.2);
}

.pwa-action-btn:focus:not(:focus-visible) {
  outline: none;
}

/* Feedback thumb buttons - gris clair discret */
.pwa-action-btn.pwa-action-thumb {
  color: rgba(160, 160, 160, 0.5);
}

.pwa-action-btn.pwa-action-thumb:hover:not(:disabled),
.pwa-action-btn.pwa-action-thumb:active:not(:disabled) {
  color: rgba(200, 200, 200, 0.8);
  background: rgba(255, 255, 255, 0.05);
}

/* Miniatures d'images */
.pwa-message-thumbnails {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
  flex-wrap: nowrap;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.pwa-message-thumbnails::-webkit-scrollbar {
  height: 3px;
}

.pwa-message-thumbnails::-webkit-scrollbar-track {
  background: transparent;
}

.pwa-message-thumbnails::-webkit-scrollbar-thumb {
  background: rgba(255, 107, 107, 0.2);
  border-radius: 1.5px;
}

.pwa-message-thumbnails::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 107, 107, 0.5);
}

.pwa-thumbnail-btn {
  width: 50px;
  height: 50px;
  min-width: 50px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: rgba(0, 0, 0, 0.1);
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  transition: all 0.15s ease;
}

.pwa-thumbnail-btn:active {
  transform: scale(0.95);
  opacity: 0.8;
}

.pwa-thumbnail-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pwa-thumbnail-more {
  width: 50px;
  height: 50px;
  min-width: 50px;
  border-radius: 8px;
  background: rgba(255, 107, 107, 0.05);
  border: 0.5px solid rgba(255, 107, 107, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #ff6b6b;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pwa-thumbnail-more:active {
  transform: scale(0.95);
  background: rgba(255, 107, 107, 0.08);
}

.pwa-message-wrapper.user .pwa-message-thumbnails {
  justify-content: flex-end;
}

.pwa-message-wrapper.user .pwa-thumbnail-btn {
  border-color: rgba(255, 107, 107, 0.2);
}

.pwa-message-wrapper.assistant .pwa-message-thumbnails {
  justify-content: flex-start;
}

.pwa-message-thumbnails.expanded {
  flex-wrap: wrap;
  max-width: 280px;
  gap: 6px;
}

.pwa-thumbnail-less {
  width: auto;
  padding: 4px 12px;
  height: 50px;
  min-width: 60px;
  border-radius: 8px;
  background: rgba(255, 107, 107, 0.08);
  border: 0.5px solid rgba(255, 107, 107, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #ff6b6b;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pwa-thumbnail-less:active {
  transform: scale(0.95);
  background: rgba(255, 107, 107, 0.12);
}

@media (hover: hover) {
  .pwa-thumbnail-btn::after {
    content: "🖼";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.2s;
  }

  .pwa-thumbnail-btn:hover::after {
    opacity: 1;
  }
}

/* ================================================
       ZONE DE SAISIE ET TAB BAR - TOUS APPAREILS
       ================================================ */
.pwa-input-area {
  position: fixed;
  /* Position exactly above tab bar (55px + half safe-area = 72px on iPhone) */
  bottom: calc(55px + env(safe-area-inset-bottom, 0px) * 0.5);
  left: 0;
  right: 0;
  width: 100%;
  padding: 4px 16px 4px 16px;
  background: rgba(10, 10, 10, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: none;
  z-index: 10000;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* DISCLAIMER - texte légal AU-DESSUS des boutons (compact) */
.pwa-disclaimer {
  text-align: center;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
  letter-spacing: 0.2px;
  line-height: 1;
  margin: 0;
  padding: 0;
}

.pwa-ai-mode-pill {
  display: flex;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 16px;
  padding: 2px;
  margin-bottom: 2px;
  gap: 2px;
  width: 100%;
}

.pwa-ai-mode-pill .pwa-mode-option {
  flex: 1;
  padding: 5px 10px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
  font-weight: 600;
  border-radius: 14px;
  transition: all 0.2s ease;
  cursor: pointer;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.pwa-ai-mode-pill .pwa-mode-option.active {
  background: rgba(255, 107, 107, 0.12);
  color: #ff6b6b;
  box-shadow: 0 1px 4px rgba(255, 107, 107, 0.15);
}

.pwa-ai-mode-pill .pwa-mode-option:not(.active):hover {
  color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.02);
}

.pwa-input-group {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
  position: relative;
}

.pwa-message-input {
  flex: 1;
  min-width: 0;
  padding: 9px 14px;
  font-size: 15px;
  line-height: 1.45;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #ffffff;
  outline: none;
  font-family: inherit;
  -webkit-appearance: none;
  /* ⚠️ ANDROID FIX: Pas de transition:all - cause des mouvements involontaires */
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
  min-height: 36px;
  height: 36px;
  max-height: 120px;
  resize: none;
  overflow-y: hidden;
  overscroll-behavior: contain;
  box-sizing: border-box;
  display: block;
}

.pwa-message-input:focus {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 107, 107, 0.2);
}

.pwa-message-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
  font-size: 14px;
}

.pwa-message-input[data-empty="true"] {
  white-space: nowrap;
  overflow-x: hidden;
}

.pwa-message-input[data-empty="false"] {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.chat-pwa-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 18px;
  background: #4d1a20;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  color: white;
  border: 1.5px solid rgba(255, 107, 107, 0.5);
  box-shadow: 0 0 15px rgba(255, 107, 107, 0.3);
}

.chat-pwa-send-btn:not(:disabled):active {
  transform: scale(0.95);
  background: #63222a;
}

.chat-pwa-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: #331215;
  border-color: rgba(255, 107, 107, 0.2);
  box-shadow: none;
}

.chat-pwa-send-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

.chat-pwa-send-btn:not(:disabled) svg {
  stroke: #ff6b6b;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-pwa-send-btn.image-read-ready {
  background: linear-gradient(135deg, #8b2e35, #c64545);
  border-color: rgba(255, 107, 107, 0.78);
  box-shadow:
    0 0 0 1px rgba(255, 107, 107, 0.22),
    0 0 18px rgba(255, 71, 87, 0.42),
    0 0 34px rgba(255, 71, 87, 0.22);
  animation:
    pwa-image-read-ready-flare 0.75s ease-out 1,
    pwa-image-read-ready-breathe 2.2s ease-in-out 0.75s infinite;
}

.chat-pwa-send-btn.image-read-ready.image-read-ready-soft {
  background: linear-gradient(135deg, #7a3034, #a64749);
  border-color: rgba(255, 107, 107, 0.55);
  box-shadow:
    0 0 0 1px rgba(255, 107, 107, 0.16),
    0 0 12px rgba(255, 71, 87, 0.25),
    0 0 22px rgba(255, 71, 87, 0.12);
}

.chat-pwa-send-btn.image-read-ready svg {
  stroke: #ffffff;
}

@keyframes pwa-image-read-ready-flare {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 71, 87, 0);
  }

  45% {
    transform: scale(1.12);
    box-shadow:
      0 0 0 1px rgba(255, 107, 107, 0.32),
      0 0 24px rgba(255, 71, 87, 0.56),
      0 0 42px rgba(255, 71, 87, 0.32);
  }

  100% {
    transform: scale(1);
    box-shadow:
      0 0 0 1px rgba(255, 107, 107, 0.22),
      0 0 18px rgba(255, 71, 87, 0.42),
      0 0 34px rgba(255, 71, 87, 0.22);
  }
}

@keyframes pwa-image-read-ready-breathe {
  0%,
  100% {
    box-shadow:
      0 0 0 1px rgba(255, 107, 107, 0.22),
      0 0 18px rgba(255, 71, 87, 0.38),
      0 0 32px rgba(255, 71, 87, 0.2);
  }

  50% {
    box-shadow:
      0 0 0 1px rgba(255, 107, 107, 0.28),
      0 0 24px rgba(255, 71, 87, 0.48),
      0 0 40px rgba(255, 71, 87, 0.26);
  }
}

@media (hover: hover) and (pointer: fine) {
  .chat-pwa-send-btn:not(:disabled):hover {
    background: #63222a;
    transform: scale(1.05);
    border-color: rgba(255, 107, 107, 0.7);
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.5);
  }

  .chat-pwa-send-btn.image-read-ready:not(:disabled):hover {
    background: linear-gradient(135deg, #9c313a, #d85757);
    border-color: rgba(255, 107, 107, 0.86);
    box-shadow:
      0 0 0 1px rgba(255, 107, 107, 0.26),
      0 0 22px rgba(255, 71, 87, 0.5),
      0 0 40px rgba(255, 71, 87, 0.28);
  }
}

.chat-pwa-send-btn.pwa-upload-btn {
  background: #331215;
  border-color: rgba(255, 107, 107, 0.2);
  box-shadow: none;
}

.chat-pwa-send-btn.pwa-upload-btn svg {
  stroke: rgba(255, 255, 255, 0.4);
}

.pwa-upload-native-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chat-pwa-send-btn.pwa-upload-btn:not(:disabled):active {
  border-color: rgba(255, 107, 107, 0.5);
  box-shadow: 0 0 15px rgba(255, 107, 107, 0.3);
}

.chat-pwa-send-btn.pwa-upload-btn:not(:disabled):active svg {
  stroke: #ff6b6b;
}

@media (hover: hover) and (pointer: fine) {
  .chat-pwa-send-btn.pwa-upload-btn:hover svg {
    stroke: #ff6b6b;
  }
}

.pwa-loading-indicator {
  margin: 8px 16px;
  padding: 10px 16px;
  background: rgba(255, 107, 107, 0.06);
  border: 0.5px solid rgba(255, 107, 107, 0.15);
  border-radius: 16px;
  font-size: 13px;
  color: #ff6b6b;
  animation: pulseLoad 1.5s ease-in-out infinite;
}

/* Tab bar - Hauteur de base, iOS override si nécessaire */
.pwa-tab-bar {
  position: fixed;
  bottom: 0 !important;
  left: 0;
  right: 0;
  width: 100%;
  background: #0a0a0a;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: none;
  z-index: 9999;
  display: flex;
  /* ✅ Par défaut: centre le contenu (Android-friendly) */
  align-items: center;
  justify-content: center;
  /* ✅ Hauteur fixe 50px - safe-area géré par padding */
  height: 50px;
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  margin: 0 !important;
  flex-shrink: 0;
  box-sizing: content-box; /* padding s'ajoute à height */
}

/* iOS spécifique: alignement flex-start pour safe-area */
body.is-ios .pwa-tab-bar {
  align-items: flex-start !important;
  height: calc(55px + env(safe-area-inset-bottom, 0px) * 0.5) !important;
  padding: 10px 0 calc(env(safe-area-inset-bottom, 0px) * 0.5) 0 !important;
  box-sizing: border-box !important;
}

.pwa-tab-bar-content {
  display: flex;
  justify-content: space-around;
  align-items: center !important;
  height: 100%; /* Remplit le conteneur */
  min-height: 50px;
  padding: 0 !important;
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
}

/* iOS spécifique: hauteur fixe pour le contenu */
body.is-ios .pwa-tab-bar-content {
  height: 45px !important;
}

/* Limite largeur tab bar sur très grands écrans */
@media (min-width: 769px) {
  .pwa-tab-bar-content {
    max-width: 600px;
  }
}

.pwa-tab-button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  height: 45px;
  min-height: 45px;
}

.pwa-tab-button:active {
  transform: scale(0.92);
}

.pwa-tab-icon-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pwa-tab-icon {
  width: 22px;
  height: 22px;
  transition: all 0.2s;
}

.pwa-tab-icon svg {
  stroke: rgba(255, 107, 107, 0.4);
  stroke-width: 2;
}

.pwa-tab-button.active .pwa-tab-icon svg {
  stroke: #ff6b6b;
  filter: drop-shadow(0 0 3px rgba(255, 107, 107, 0.5));
}

.pwa-tab-label {
  font-size: 9px;
  font-weight: 500;
  color: rgba(255, 107, 107, 0.4);
  letter-spacing: -0.2px;
  transition: all 0.2s;
  margin-top: 1px;
}

.pwa-tab-button.active .pwa-tab-label {
  color: #ff6b6b;
  font-weight: 600;
}

.pwa-tab-indicator {
  position: absolute;
  top: -2px;
  width: 24px;
  height: 2px;
  background: #ff6b6b;
  border-radius: 1px;
  opacity: 0;
  transition: all 0.2s;
  box-shadow: 0 0 6px rgba(255, 107, 107, 0.6);
}

.pwa-tab-button.active .pwa-tab-indicator {
  opacity: 1;
}

.pwa-tab-button.active::before {
  content: "";
  position: absolute;
  inset: 2px;
  background: radial-gradient(
    circle,
    rgba(255, 107, 107, 0.08) 0%,
    transparent 70%
  );
  border-radius: 12px;
  z-index: -1;
}

/* ================================================
       MODAL SETTINGS - TOUS APPAREILS
       ================================================ */
.pwa-settings-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.2s ease;
}

.pwa-settings-modal {
  width: 100%;
  height: 100%;
  background: linear-gradient(
    135deg,
    rgba(10, 10, 10, 0.98) 0%,
    rgba(20, 10, 15, 0.95) 100%
  );
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.pwa-settings-close {
  position: fixed;
  top: calc(20px + var(--safe-top));
  right: 20px;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 2px solid rgba(255, 107, 107, 0.6);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 99999;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.8),
    0 0 15px rgba(255, 107, 107, 0.3);
}

.pwa-settings-close:hover {
  border-color: rgba(255, 107, 107, 0.8);
  color: #ff6b6b;
  background: rgba(0, 0, 0, 0.95);
  transform: scale(1.05);
}

.pwa-settings-close:active {
  transform: scale(0.95);
}

/* ⭐ SETTINGS CONTENT - Scroll professionnel */
.pwa-settings-content {
  /* Layout */
  flex: 1;
  min-height: 0;
  background: transparent;

  /* Scroll comportement */
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;

  /* Padding avec safe-areas */
  padding: calc(20px + var(--safe-top)) 16px calc(30px + var(--safe-bottom))
    16px;

  /* Scrollbar personnalisée */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 107, 107, 0.3) transparent;
}

.pwa-settings-content::-webkit-scrollbar {
  width: 4px;
}

.pwa-settings-content::-webkit-scrollbar-track {
  background: transparent;
}

.pwa-settings-content::-webkit-scrollbar-thumb {
  background: rgba(255, 107, 107, 0.3);
  border-radius: 2px;
}

.pwa-account-section {
  margin-bottom: 24px;
  padding: 16px;
  background: linear-gradient(
    135deg,
    rgba(255, 107, 107, 0.08) 0%,
    rgba(255, 107, 107, 0.03) 100%
  );
  border-radius: 16px;
  border: 1px solid rgba(255, 107, 107, 0.2);
  position: relative;
  overflow: hidden;
}

.pwa-account-email {
  font-size: 15px;
  color: #ffffff;
  margin-bottom: 4px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.pwa-account-type {
  font-size: 12px;
  color: rgba(255, 107, 107, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.pwa-card-group {
  margin-bottom: 20px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 16px;
  border: 1px solid rgba(255, 107, 107, 0.15);
  overflow: hidden;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.pwa-settings-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  background: transparent;
  border: none;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}

.pwa-settings-card:hover {
  background: rgba(255, 107, 107, 0.05);
}

.pwa-settings-card:active {
  background: rgba(255, 107, 107, 0.08);
  transform: scale(0.98);
}

.pwa-settings-card:not(:last-child)::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 107, 107, 0.1) 50%,
    transparent 100%
  );
}

.pwa-card-info {
  flex: 1;
}

.pwa-card-info h3 {
  font-size: 15px;
  font-weight: 500;
  color: #ffffff;
  margin: 0;
  letter-spacing: -0.2px;
}

.pwa-ios-toggle {
  width: 50px;
  height: 28px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.pwa-ios-toggle.active {
  background: rgba(255, 107, 107, 0.2);
  border-color: #ff6b6b;
  box-shadow: 0 0 10px rgba(255, 107, 107, 0.3);
}

.pwa-ios-toggle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transform: translateY(-50%);
}

.pwa-ios-toggle.active::after {
  transform: translateX(24px) translateY(-50%);
  background: linear-gradient(135deg, #ff6b6b, #ff8787);
}

/* Loading state for notification toggle */
.pwa-ios-toggle.loading {
  background: rgba(255, 200, 100, 0.2);
  border-color: rgba(255, 200, 100, 0.6);
}

.pwa-ios-toggle.loading::after {
  background: linear-gradient(135deg, #ffcc66, #ffaa33);
  animation: togglePulse 1s ease-in-out infinite;
}

@keyframes togglePulse {
  0%,
  100% {
    opacity: 1;
    transform: translateX(12px) translateY(-50%);
  }

  50% {
    opacity: 0.6;
    transform: translateX(12px) translateY(-50%) scale(0.9);
  }
}

@keyframes checkmark-pop {
  0% {
    transform: scale(0);
    opacity: 0;
  }

  50% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.pwa-chevron-right {
  width: 18px;
  height: 18px;
  color: rgba(255, 107, 107, 0.4);
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.pwa-settings-card:hover .pwa-chevron-right {
  color: rgba(255, 107, 107, 0.6);
  transform: translateX(2px);
}

.pwa-danger-card {
  background: rgba(255, 68, 68, 0.02);
}

.pwa-danger-card h3 {
  color: #ff4444;
  font-weight: 600;
}

/* ================================================
       AUTH MESSAGES & CONTEXT POPUP - COMMUNS
       ================================================ */
.pwa-auth-message-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 40px 24px;
  position: fixed;
  top: -50px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
}

.pwa-auth-message-card-small {
  background: linear-gradient(
    135deg,
    rgba(10, 10, 10, 0.95) 0%,
    rgba(20, 10, 15, 0.85) 100%
  );
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1.5px solid rgba(255, 107, 107, 0.3);
  border-radius: 20px;
  padding: 24px 20px;
  text-align: center;
  max-width: 260px;
  width: 90%;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 0 20px rgba(255, 107, 107, 0.1),
    0 4px 16px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  animation: authCardSlide 0.5s ease-out;
}

.pwa-auth-title-small {
  font-size: 18px;
  font-weight: 600;
  color: #ff6b6b;
  margin-bottom: 12px;
  letter-spacing: -0.3px;
  text-shadow: 0 0 12px rgba(255, 107, 107, 0.2);
}

.pwa-auth-text-small {
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.1px;
  font-weight: 400;
  margin: 0;
}

/* Context popup */
.pwa-ctx-wrapper {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.pwa-ctx-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.pwa-ctx-modal {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: #0a0a0a;
  border-radius: 20px 20px 0 0;
  padding: 0;
  animation: slideUp 0.3s ease;
  border-top: 0.5px solid rgba(255, 107, 107, 0.2);
  /* Hauteur maximale professionnelle: viewport - marge sécurité */
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
}

.pwa-ctx-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 0 12px;
  width: 100%;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.pwa-ctx-close {
  position: absolute;
  right: 12px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  flex-shrink: 0;
}

.pwa-ctx-back {
  position: absolute;
  left: 12px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  flex-shrink: 0;
}

.pwa-ctx-progress {
  width: 120px;
  height: 2px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 100px;
  overflow: hidden;
}

.pwa-ctx-progress-fill {
  height: 100%;
  background: #ff6b6b;
  transition: width 0.4s ease;
}

.pwa-ctx-question {
  padding: 16px 12px 12px 12px;
  text-align: center;
  flex-shrink: 0;
}

.pwa-ctx-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  display: block;
  margin-bottom: 4px;
  color: #ff6b6b;
  opacity: 0.7;
  text-align: center;
}

.pwa-ctx-question h2 {
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  letter-spacing: -0.3px;
  text-align: center;
}

/* Zone scrollable - LE CŒUR DU SYSTÈME */
.pwa-ctx-options {
  /* Scrolling professionnel */
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  /* Padding interne pour le contenu */
  padding: 0 12px 12px 12px;
  /* Grid layout */
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  align-content: start;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  /* Scrollbar personnalisée */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 107, 107, 0.3) transparent;
}

.pwa-ctx-options::-webkit-scrollbar {
  width: 4px;
}

.pwa-ctx-options::-webkit-scrollbar-track {
  background: transparent;
}

.pwa-ctx-options::-webkit-scrollbar-thumb {
  background: rgba(255, 107, 107, 0.3);
  border-radius: 2px;
}

/* Actions footer - toujours visible en bas */
.pwa-ctx-actions {
  padding: 12px;
  padding-bottom: calc(12px + var(--safe-bottom));
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  background: #0a0a0a;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.pwa-ctx-option {
  position: relative;
  /* Padding généreux pour border-radius 12px: minimum 14px horizontal */
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 74px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}

.pwa-ctx-option:active {
  transform: scale(0.97);
}

.pwa-ctx-option.selected {
  background: rgba(255, 107, 107, 0.1);
  border-color: #ff6b6b;
}

.pwa-ctx-option-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 100%;
  /* Limite à 88% pour sécurité maximale */
  max-width: 88%;
  padding: 0 6px;
  overflow: hidden;
}

.pwa-ctx-option-main {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  line-height: 1.15;
  max-width: 100%;
  width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  /* Padding interne supplémentaire */
  padding: 0 4px;
}

.pwa-ctx-option-detail {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.3);
  line-height: 1.3;
  max-width: 100%;
  width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  /* Padding interne supplémentaire */
  padding: 0 4px;
}

.pwa-ctx-option.selected .pwa-ctx-option-main {
  color: #ff6b6b;
}

.pwa-ctx-check {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ff6b6b;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 9px;
  font-weight: bold;
}

.pwa-ctx-actions {
  padding-top: 4px;
  width: 100%;
  max-width: 320px;
  display: flex;
  justify-content: center;
}

.pwa-ctx-skip,
.pwa-ctx-submit {
  width: 100%;
  max-width: 200px;
  padding: 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.pwa-ctx-skip {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.4);
}

.pwa-ctx-skip:active {
  background: rgba(255, 255, 255, 0.08);
  transform: scale(0.97);
}

.pwa-ctx-submit {
  background: linear-gradient(135deg, #ff6b6b, #ff8787);
  border: none;
  color: white;
  box-shadow: 0 2px 10px rgba(255, 107, 107, 0.2);
}

.pwa-ctx-submit:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(255, 107, 107, 0.2);
}

/* ================================================
       LIGHTBOX POUR IMAGES - TOUS APPAREILS
       ================================================ */
.pwa-lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
  padding: 20px;
  cursor: zoom-out;
}

.pwa-lightbox-content {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pwa-lightbox-image {
  max-width: 85%;
  max-height: 70vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.6),
    0 0 80px rgba(255, 107, 107, 0.05);
  cursor: default;
  animation: zoomIn 0.3s ease;
  border: 0.5px solid rgba(255, 255, 255, 0.1);
}

.pwa-lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ff4757;
  border: 2px solid #ff6b6b;
  color: white;
  font-size: 20px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 10001;
  box-shadow: 0 4px 15px rgba(255, 71, 87, 0.5);
  line-height: 1;
  padding: 0;
  font-family: Arial, sans-serif;
}

.pwa-lightbox-close:hover {
  background: #ff5252;
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(255, 71, 87, 0.6);
}

.pwa-lightbox-close:active {
  transform: scale(0.95);
  background: #ff4757;
}

/* ================================================
       SCROLLBARS - TOUS APPAREILS
       ================================================ */
::-webkit-scrollbar {
  width: 3px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 107, 107, 0.2);
  border-radius: 1.5px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 107, 107, 0.5);
}

/* ================================================
       iOS - PETIT ÉCRAN (≤375px) - iPhone SE
       ================================================ */

body.is-ios {
  @media (max-width: 375px) {
    /* Header iPhone SE - augmenté pour plus d'espace */
    .pwa-header-container {
      padding-top: calc(16px + var(--safe-top));
      padding-bottom: 12px;
      /* ✅ AJOUTÉ : espace en bas */
      height: 56px;
      /* ✅ AJOUTÉ : hauteur augmentée */
      min-height: 56px;
      /* ✅ AJOUTÉ */
    }

    /* Header Pro iPhone SE - plus d'espace */
    .pwa-header-pro {
      padding-top: 8px;
      /* ✅ AJOUTÉ */
      padding-bottom: 12px;
      /* ✅ AJOUTÉ */
    }

    /* Actions group iPhone SE - plus d'espace vertical */
    .pwa-header-actions-group {
      gap: 10px;
      margin-bottom: 6px;
    }

    /* Logo section iPhone SE - légèrement plus grand */
    .pwa-logo-wrapper,
    .pwa-logo-icon {
      width: 34px;
      height: 34px;
    }

    .pwa-header-main-title {
      font-size: 16px;
    }

    /* Boutons action iPhone SE - légèrement plus grands */
    .pwa-header-action-btn:not(.pwa-cta-btn) {
      width: 32px;
      height: 32px;
      border-radius: 16px;
    }

    .pwa-header-action-btn svg {
      width: 16px;
      height: 16px;
    }

    /* Profile button iPhone SE */
    .pwa-profile-btn {
      width: 34px;
      height: 34px;
    }

    .pwa-profile-btn svg {
      width: 22px;
      height: 22px;
    }

    /* Start button iPhone SE - REMONTÉ POUR ÉVITER COLLISION */
    .pwa-start-btn {
      margin-top: 15px;
      margin-bottom: 40px;
    }

    /* Landing content compacté */
    .pwa-landing-content {
      padding: 0 18px env(safe-area-inset-bottom, 20px) 18px;
    }

    .pwa-main-title {
      font-size: 30px;
    }

    .pwa-subtitle {
      font-size: 13px;
    }

    .pwa-question-container {
      max-width: 340px;
    }

    .pwa-question-text {
      font-size: 1.15rem;
      padding: 1.6rem 1.2rem 1.2rem;
    }

    .pwa-radar-grid {
      grid-template-columns: 1fr;
    }

    .pwa-header-pro {
      padding-top: 4px;
      padding-bottom: 8px;
    }

    .pwa-header-actions-group {
      margin-bottom: 4px;
    }

    /* NOTE: Pas de padding-bottom sur .pwa-input-area - géré par .pwa-main-content */
  }
}

/* ================================================
       iOS - MOYEN/GRAND ÉCRAN (376px - 430px)
       iPhone 12/13/14, iPhone 14 Pro/Pro Max
       ================================================ */

body.is-ios {
  @media (min-width: 376px) and (max-width: 430px) {
    /* Safe-area optimisée pour notch */
    .pwa-header-container {
      padding-top: calc(22px + var(--safe-top));
      /* ✅ ICI : 18px → 22px */
    }

    .pwa-header-pro {
      padding-bottom: 8px;
    }

    .pwa-header-actions-group {
      margin-bottom: 4px;
    }

    /* NOTE: Pas de padding-bottom sur .pwa-input-area - géré par .pwa-main-content */
  }
}

/* ================================================
       iOS - iPhone 14 Pro SPÉCIFIQUE (393x852)
       ================================================ */

body.is-ios {
  @media only screen and (device-width: 393px) and (device-height: 852px) and (-webkit-device-pixel-ratio: 3) {
    .pwa-header-container {
      padding-top: calc(24px + var(--safe-top));
      /* ✅ CHANGÉ : 0px → 24px (notch Dynamic Island) */
    }

    .pwa-landing-content {
      padding-top: 0;
      padding-bottom: env(safe-area-inset-bottom, 20px);
    }

    .pwa-title-section {
      padding-top: 15px;
      padding-bottom: 15px;
    }

    .pwa-main-title {
      font-size: 30px;
      margin-bottom: 12px;
    }

    .pwa-question-container {
      margin: 20px auto;
    }

    .pwa-start-btn {
      margin-top: 25px;
      margin-bottom: 5px;
    }
  }
}

/* ================================================
       ANDROID - PETIT ÉCRAN (≤375px)
       ✅ FIX: Syntaxe CSS valide - @media au niveau racine
       ================================================ */
@media (max-width: 375px) {
  body:not(.is-ios) .pwa-header-container {
    padding-top: calc(18px + var(--safe-top));
  }

  body:not(.is-ios) .pwa-start-btn {
    margin-top: 30px;
  }

  body:not(.is-ios) .pwa-landing-content {
    padding: 0 18px env(safe-area-inset-bottom, 20px) 18px;
  }

  body:not(.is-ios) .pwa-main-title {
    font-size: 30px;
  }

  body:not(.is-ios) .pwa-subtitle {
    font-size: 13px;
  }

  body:not(.is-ios) .pwa-question-container {
    max-width: 340px;
  }

  body:not(.is-ios) .pwa-question-text {
    font-size: 1.15rem;
    padding: 1.6rem 1.2rem 1.2rem;
  }

  body:not(.is-ios) .pwa-radar-grid {
    grid-template-columns: 1fr;
  }

  body:not(.is-ios) .pwa-header-pro {
    padding-bottom: 6px;
  }

  body:not(.is-ios) .pwa-header-actions-group {
    margin-bottom: 4px;
  }
}

/* ================================================
       ANDROID - MOYEN/GRAND ÉCRAN (376px - 430px)
       ================================================ */
@media (min-width: 376px) and (max-width: 430px) {
  body:not(.is-ios) .pwa-header-container {
    padding-top: calc(16px + var(--safe-top));
  }

  body:not(.is-ios) .pwa-header-pro {
    padding-bottom: 8px;
  }

  body:not(.is-ios) .pwa-header-actions-group {
    margin-bottom: 4px;
  }
}

/* ================================================
       ANDROID - STABILISATION INPUT AREA
       Évite les mouvements involontaires causés par:
       - calc() dynamique avec env(safe-area-inset-bottom)
       - backdrop-filter (désactivé plus bas)
       ✅ FIX: Ajout safe-area-inset pour notch/punch-hole Android
       ================================================ */
body:not(.is-ios) .pwa-input-area {
  /* Position aligned with new strict 50px tab bar */
  bottom: calc(50px + env(safe-area-inset-bottom, 0px)) !important;
}

body:not(.is-ios) .pwa-tab-bar {
  /* ✅ FIX: Hauteur FIXE 50px - le safe-area est géré par padding-bottom UNIQUEMENT */
  /* NE PAS ajouter safe-area à la hauteur, sinon ça crée un espace noir */
  height: 50px !important;
  min-height: 50px !important;
  max-height: 50px !important;
  padding: 0 !important;
  padding-bottom: env(safe-area-inset-bottom, 0px) !important;
  margin: 0 !important;
  align-items: center !important;
  justify-content: center !important;
  background: #0a0a0a !important;
  box-sizing: content-box !important; /* padding s'ajoute à la hauteur */
}

/* ✅ FIX: Le contenu remplit 100% du conteneur */
body:not(.is-ios) .pwa-tab-bar-content {
  height: 100% !important;
  min-height: 50px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-around !important;
  padding: 0 !important;
  margin: 0 !important;
}

body:not(.is-ios) .pwa-header-container {
  /* Safe-area pour punch-hole/notch en haut */
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
}

/* ================================================
       ANDROID - DÉSACTIVER BACKDROP-FILTER
       Le backdrop-filter est très gourmand en GPU sur Android
       et cause des repaints qui font bouger les éléments
       ================================================ */
body:not(.is-ios) .pwa-header-container,
body:not(.is-ios) .pwa-input-area,
body:not(.is-ios) .pwa-tab-bar {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  /* Utiliser un background solide à la place */
  background: rgba(10, 10, 10, 0.98) !important;
}

body:not(.is-ios) .pwa-modal-backdrop,
body:not(.is-ios) .pwa-ctx-overlay,
body:not(.is-ios) .pwa-modal-overlay {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: rgba(0, 0, 0, 0.85) !important;
}

/* ✅ FIX: Désactiver backdrop-filter sur TOUS les éléments Android
       Couvre les inline styles des composants PWA */
body:not(.is-ios) .pwa-modes-overlay > *,
body:not(.is-ios) .pwa-ctx-panel > *,
body:not(.is-ios) .pwa-ctx-wrapper > *,
body:not(.is-ios) .pwa-settings-modal > *,
body:not(.is-ios) .pwa-help-overlay > *,
body:not(.is-ios) .pwa-analysis-panel > *,
body:not(.is-ios) .pwa-lightbox-overlay > *,
body:not(.is-ios) [class*="modal"] > *,
body:not(.is-ios) [class*="overlay"] > *,
body:not(.is-ios) [class*="backdrop"] > * {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Désactiver aussi les divs avec position fixed/absolute dans modals */
body:not(.is-ios) .pwa-modes-sheet div[style],
body:not(.is-ios) .pwa-ctx-panel div[style],
body:not(.is-ios) .pwa-settings-modal div[style] {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* ================================================
       ANDROID - PWA INSTALL PROMPT STABILISATION
       ✅ FIX: Supprimé les sélecteurs attribute trop larges (div[style*=...])
       ✅ FIX: Supprimé le sélecteur universel * qui tuait les transitions enfants
       ================================================ */
body:not(.is-ios) .pwa-install-prompt,
body.is-android .pwa-install-prompt {
  /* Pas de transform pour éviter les micro-mouvements */
  transform: none !important;
  -webkit-transform: none !important;
  /* Centrage sans transform */
  left: 5% !important;
  right: 5% !important;
  width: auto !important;
  margin: 0 !important;
  /* Bloquer animation container seulement */
  animation: none !important;
  -webkit-animation: none !important;
  /* Contain sans size */
  contain: layout paint !important;
  will-change: auto !important;
  /* Anti-repaint */
  backface-visibility: hidden !important;
  -webkit-backface-visibility: hidden !important;
}

/* ✅ Les boutons enfants GARDENT leurs transitions pour le feedback visuel */

/* ================================================
       PETITS ÉCRANS - HAUTEUR RÉDUITE (≤740px)
       TOUS OS
       ================================================ */

@media (max-height: 740px) {
  .pwa-title-section {
    padding-top: 15px;
    padding-bottom: 15px;
  }

  .pwa-main-title {
    font-size: 28px;
    margin-bottom: 12px;
  }

  .pwa-question-container {
    margin: 20px auto;
  }

  .pwa-start-btn {
    margin-top: 30px;
    margin-bottom: 50px;
  }
}

@media (max-height: 667px) {
  .pwa-landing-content {
    padding-bottom: env(safe-area-inset-bottom, 20px);
  }
}

/* ================================================
       DESKTOP & TABLETTES (>430px) - TOUS OS
       ================================================ */

@media (min-width: 430px) {
  .pwa-settings-modal-overlay {
    align-items: center;
    justify-content: center;
    padding: 20px;
  }

  .pwa-settings-modal {
    max-width: 400px;
    height: auto;
    max-height: 600px;
    border-radius: 24px;
    border: 2px solid rgba(255, 107, 107, 0.3);
    box-shadow:
      0 0 40px rgba(255, 107, 107, 0.2),
      0 20px 60px rgba(0, 0, 0, 0.5);
  }
}

/* ================================================
       RESPONSIVE CONTEXT POPUP - SYSTÈME EXPERT
       Padding en cascade: Option → Content → Labels
       Border-radius 12px requiert minimum 14px padding horizontal
       ================================================ */

/* Très petits écrans (≤350px): Maximum compression tout en gardant lisibilité */
@media (max-width: 350px) {
  .pwa-ctx-modal {
    padding: 8px;
    padding-bottom: calc(20px + var(--safe-bottom));
  }

  .pwa-ctx-options {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    max-width: 100%;
  }

  .pwa-ctx-option {
    min-height: 76px;
    padding: 12px 12px;
    /* Total: 12px */
  }

  .pwa-ctx-option-content {
    max-width: 85%;
    /* Très sécuritaire */
    padding: 0 5px;
    /* +5px */
  }

  .pwa-ctx-option-main {
    font-size: 11px;
    line-height: 1.2;
    padding: 0 3px;
    /* +3px = Total 20px par côté */
  }

  .pwa-ctx-option-detail {
    font-size: 8px;
    line-height: 1.3;
    padding: 0 3px;
  }
}

/* Petits écrans (351-375px, iPhone SE): Équilibre confort/espace */
@media (min-width: 351px) and (max-width: 375px) {
  .pwa-ctx-option {
    min-height: 75px;
    padding: 12px 13px;
    /* Total: 13px */
  }

  .pwa-ctx-option-content {
    max-width: 86%;
    padding: 0 5px;
    /* +5px */
  }

  .pwa-ctx-option-main {
    font-size: 12px;
    line-height: 1.2;
    padding: 0 4px;
    /* +4px = Total 22px par côté */
  }

  .pwa-ctx-option-detail {
    font-size: 9px;
    line-height: 1.3;
    padding: 0 4px;
  }
}

/* Écrans moyens (376-430px): Confort standard */
@media (min-width: 376px) and (max-width: 430px) {
  .pwa-ctx-option {
    min-height: 74px;
    /* Hérite du padding base: 12px 14px */
  }

  .pwa-ctx-option-content {
    /* Hérite du max-width base: 88% */
  }

  .pwa-ctx-option-main {
    /* Hérite de la taille base: 13px */
  }

  .pwa-ctx-option-detail {
    /* Hérite de la taille base: 9px */
  }
}

/* Grands écrans (≥431px): Maximum confort */
@media (min-width: 431px) {
  .pwa-ctx-options {
    max-width: 360px;
    gap: 10px;
  }

  .pwa-ctx-option {
    min-height: 76px;
    padding: 14px 16px;
    /* Total: 16px - Très généreux */
  }

  .pwa-ctx-option-content {
    max-width: 90%;
    /* Plus de liberté */
    padding: 0 6px;
    /* +6px */
  }

  .pwa-ctx-option-main {
    font-size: 14px;
    line-height: 1.2;
    padding: 0 4px;
    /* +4px = Total 26px par côté */
  }

  .pwa-ctx-option-detail {
    font-size: 10px;
    line-height: 1.3;
    padding: 0 4px;
  }
}

/* ================================================
       OPTIMISATION PETITS ÉCRANS (≤500px)
       TOUS OS
       ================================================ */

@media (max-width: 500px) {
  /* iPhone SE garde ses propres règles */
  body:not(.is-ios) .pwa-header,
  body.is-ios .pwa-header {
    padding: 10px 14px;
    padding-top: calc(10px + var(--safe-top));
    min-height: 48px;
  }

  /* Sauf iPhone SE qui a un header plus grand */
  body.is-ios {
    @media (max-width: 375px) {
      .pwa-header {
        min-height: 56px;
        /* ✅ Exception iPhone SE */
      }
    }
  }

  .pwa-logo-wrapper,
  .pwa-logo-icon {
    width: 28px;
    height: 28px;
  }

  /* Sauf iPhone SE */
  body.is-ios {
    @media (max-width: 375px) {
      .pwa-logo-wrapper,
      .pwa-logo-icon {
        width: 34px;
        /* ✅ Exception iPhone SE */
        height: 34px;
      }
    }
  }

  .pwa-logo-text {
    font-size: 13px;
    letter-spacing: -0.3px;
  }

  .pwa-logo-heartbreak {
    font-size: 6.5px;
  }

  .pwa-profile-btn {
    width: 28px;
    height: 28px;
  }

  /* Sauf iPhone SE */
  body.is-ios {
    @media (max-width: 375px) {
      .pwa-profile-btn {
        width: 34px;
        /* ✅ Exception iPhone SE */
        height: 34px;
      }

      .pwa-profile-btn svg {
        width: 22px;
        /* ✅ Exception iPhone SE */
        height: 22px;
      }
    }
  }

  .pwa-profile-btn svg {
    width: 17px;
    height: 17px;
  }
}

/* ================================================
       LIGHTBOX RESPONSIVE MOBILE
       ================================================ */

@media (max-width: 768px) {
  .pwa-lightbox-close {
    position: fixed;
    top: calc(20px + var(--safe-top));
    right: 20px;
    background: #ff4757;
    backdrop-filter: blur(10px);
    border: 2px solid #ff6b6b;
    color: white;
  }

  .pwa-lightbox-overlay {
    padding: 20px;
  }

  .pwa-lightbox-image {
    border-radius: 12px;
    max-height: 75vh;
    max-width: 90%;
  }
}

@supports (touch-action: manipulation) {
  .pwa-lightbox-image {
    touch-action: pinch-zoom;
  }
}

/* ================================================
       GRANDS SMARTPHONES & PETITES TABLETTES (431px - 768px)
       iOS et Android - AJOUTÉ POUR FIX
       ================================================ */

@media (min-width: 431px) and (max-width: 768px) {
  /* Container plus large */
  .pwa-app-container {
    max-width: 100%;
  }

  /* Header plus spacieux */
  .pwa-header-container {
    padding: 14px 24px;
    padding-top: calc(20px + var(--safe-top));
    height: 60px;
  }

  .pwa-header-pro {
    padding-bottom: 10px;
  }

  /* Logo et titres plus grands */
  .pwa-logo-wrapper,
  .pwa-logo-icon {
    width: 36px;
    height: 36px;
  }

  .pwa-header-main-title {
    font-size: 17px;
  }

  /* Boutons header plus grands */
  .pwa-header-action-btn:not(.pwa-cta-btn) {
    width: 34px;
    height: 34px;
    border-radius: 17px;
  }

  .pwa-header-action-btn svg {
    width: 16px;
    height: 16px;
  }

  /* Messages area avec plus d'espace */
  .pwa-messages-area {
    padding: 20px 24px;
  }

  /* Bubbles messages plus larges */
  .pwa-msg-bubble {
    max-width: 75%;
    font-size: 15px;
    padding: 12px 16px;
  }

  /* Main content - no padding, chat-container handles it */
  .pwa-main-content {
    padding-bottom: 0;
  }

  /* Chat container padding for fixed input + tab bar */
  .pwa-chat-container {
    padding-bottom: calc(var(--pwa-chat-input-height, 120px) + 65px) !important;
  }

  .pwa-tab-bar {
    height: 65px;
    padding-bottom: 0;
  }

  .pwa-tab-bar-content {
    height: 65px;
    padding-bottom: 0;
    align-items: center;
  }

  /* ✅ FIX Android tablettes: hauteur fixe sans espace noir */
  body:not(.is-ios) .pwa-tab-bar {
    height: 50px !important;
    min-height: 50px !important;
    max-height: 50px !important;
    padding: 0 !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    box-sizing: content-box !important;
  }

  body:not(.is-ios) .pwa-tab-bar-content {
    height: 100% !important;
    min-height: 50px !important;
  }

  body:not(.is-ios) .pwa-input-area {
    bottom: calc(50px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Input area fixed above tab bar + 10px gap */
  .pwa-input-area {
    bottom: 65px;
    padding: 16px 24px;
  }

  .pwa-input-box {
    padding: 14px 16px;
    font-size: 15px;
  }

  .pwa-tab-button {
    gap: 3px;
    padding: 6px;
  }

  /* Landing page plus spacieuse */
  .pwa-landing-content {
    padding: 0 40px 40px 40px;
  }

  .pwa-main-title {
    font-size: 40px;
  }

  .pwa-subtitle {
    font-size: 16px;
  }

  .pwa-question-text {
    font-size: 1.4rem;
    padding: 2rem 1.6rem;
  }

  .pwa-start-btn {
    padding: 16px 40px;
    font-size: 16px;
    margin-top: 40px;
  }

  /* Modals plus grandes */
  .pwa-settings-modal,
  .pwa-ctx-modal {
    max-width: 500px;
    padding: 24px;
  }
}

/* ================================================
       TABLETTES & DESKTOP (>768px)
       iOS et Android - AJOUTÉ POUR FIX
       ================================================ */

@media (min-width: 769px) {
  /* Container centré avec max-width */
  .pwa-app-container {
    max-width: 600px;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
  }

  /* Header desktop-like */
  .pwa-header-container {
    padding: 16px 32px;
    padding-top: calc(24px + var(--safe-top));
    height: 64px;
  }

  .pwa-logo-wrapper,
  .pwa-logo-icon {
    width: 40px;
    height: 40px;
  }

  .pwa-header-main-title {
    font-size: 18px;
  }

  /* Messages area style desktop */
  .pwa-messages-area {
    padding: 24px 40px;
  }

  .pwa-msg-bubble {
    max-width: 70%;
    font-size: 16px;
    padding: 14px 18px;
  }

  /* Main content - no padding, chat-container handles it */
  .pwa-main-content {
    padding-bottom: 0;
  }

  /* Chat container padding for fixed input + tab bar */
  .pwa-chat-container {
    padding-bottom: calc(var(--pwa-chat-input-height, 125px) + 70px) !important;
  }

  .pwa-tab-bar {
    height: 70px;
    padding-bottom: 0;
  }

  .pwa-tab-bar-content {
    height: 70px;
    padding-bottom: 0;
    align-items: center;
  }

  /* ✅ FIX Android desktop: hauteur fixe sans espace noir */
  body:not(.is-ios) .pwa-tab-bar {
    height: 50px !important;
    min-height: 50px !important;
    max-height: 50px !important;
    padding: 0 !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    box-sizing: content-box !important;
  }

  body:not(.is-ios) .pwa-tab-bar-content {
    height: 100% !important;
    min-height: 50px !important;
  }

  body:not(.is-ios) .pwa-input-area {
    bottom: calc(50px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Input area fixed above tab bar + 10px gap */
  .pwa-input-area {
    bottom: 70px;
    padding: 20px 40px;
  }

  .pwa-input-box {
    padding: 16px 20px;
    font-size: 16px;
    border-radius: 16px;
  }

  /* Landing page desktop */
  .pwa-landing-content {
    padding: 0 60px 60px 60px;
  }

  .pwa-main-title {
    font-size: 48px;
  }

  .pwa-subtitle {
    font-size: 18px;
  }

  .pwa-question-text {
    font-size: 1.6rem;
    padding: 2.4rem 2rem;
  }

  .pwa-radar-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
}

/* ================================================
       ANDROID MEGA FIX - STABILISATION COMPLETE
       Désactive TOUT ce qui peut causer des mouvements
       involontaires sur Android mobile
       ================================================ */

/* 1. DÉSACTIVER TRANSITIONS SUR ANDROID
       transition:all anime des propriétés non voulues */
body:not(.is-ios) .pwa-header-action-btn,
body:not(.is-ios) .pwa-profile-btn,
body:not(.is-ios) .pwa-menu-overlay,
body:not(.is-ios) .pwa-menu-option,
body:not(.is-ios) .pwa-mode-option,
body:not(.is-ios) .pwa-modes-help-btn,
body:not(.is-ios) .pwa-panel-close,
body:not(.is-ios) .pwa-panel-item,
body:not(.is-ios) .pwa-choice-btn,
body:not(.is-ios) .pwa-start-btn,
body:not(.is-ios) .pwa-action-btn,
body:not(.is-ios) .pwa-thumbnail-btn,
body:not(.is-ios) .pwa-thumbnail-more,
body:not(.is-ios) .pwa-thumbnail-less,
body:not(.is-ios) .pwa-ai-mode-pill,
body:not(.is-ios) .chat-pwa-send-btn,
body:not(.is-ios) .pwa-tab-button,
body:not(.is-ios) .pwa-tab-label,
body:not(.is-ios) .pwa-settings-close,
body:not(.is-ios) .pwa-settings-card,
body:not(.is-ios) .pwa-settings-switch,
body:not(.is-ios) .pwa-settings-toggle,
body:not(.is-ios) .pwa-chevron-right,
body:not(.is-ios) .pwa-ctx-option,
body:not(.is-ios) .pwa-ctx-skip,
body:not(.is-ios) .pwa-lightbox-close {
  transition: none !important;
}

/* ✅ P0 FIX: EXCEPTION - Feedback buttons keep minimal animation */
body:not(.is-ios) .pwa-action-btn.pwa-action-copy,
body:not(.is-ios) .pwa-action-btn.pwa-action-thumb {
  transition:
    transform 0.15s ease,
    color 0.15s ease !important;
}

body:not(.is-ios) .pwa-action-btn.pwa-action-thumb.active-feedback {
  transform: scale(1.2);
  color: #ff6b6b !important;
}

body:not(.is-ios) .pwa-action-btn.pwa-action-thumb.active-feedback-neg {
  transform: scale(1.2);
  color: #ff4757 !important;
}

/* 2. DÉSACTIVER BACKDROP-FILTER PARTOUT SUR ANDROID
       GPU très gourmand = repaints constants */
body:not(.is-ios) [class*="pwa-"],
body:not(.is-ios) .chat-interface,
body:not(.is-ios) .messages-list {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* 3. BACKGROUNDS OPAQUES AU LIEU DE BLUR */
body:not(.is-ios) .pwa-header-pro,
body:not(.is-ios) .pwa-header-container {
  background: #0a0a0a !important;
}

body:not(.is-ios) .pwa-menu-container,
body:not(.is-ios) .pwa-modes-content,
body:not(.is-ios) .pwa-settings-modal {
  background: #111111 !important;
}

/* 4. DÉSACTIVER ANIMATIONS INFINIES */
body:not(.is-ios) .pwa-snowflake,
body:not(.is-ios) .pwa-analysis-pulse,
body:not(.is-ios) [class*="pulse"],
body:not(.is-ios) [class*="shimmer"],
body:not(.is-ios) [class*="glow"] {
  animation: none !important;
}

/* 5. DÉSACTIVER WILL-CHANGE QUI FORCE GPU LAYERS */
body:not(.is-ios) .pwa-messages-area,
body:not(.is-ios) .pwa-tab-bar-content,
body:not(.is-ios) .pwa-modes-sheet,
body:not(.is-ios) .pwa-modes-overlay,
body:not(.is-ios) [style*="will-change"] {
  will-change: auto !important;
}

/* 6. DÉSACTIVER SCROLL-BEHAVIOR SMOOTH
       Peut causer des boucles avec auto-scroll JS */
body:not(.is-ios) .pwa-messages-area,
body:not(.is-ios) .pwa-help-list,
body:not(.is-ios) .pwa-panel-content,
body:not(.is-ios) .pwa-settings-content,
body:not(.is-ios) .pwa-ctx-options {
  scroll-behavior: auto !important;
}

/* 7. POSITION FIXED STABLE - SANS TRANSFORM
       ⚠️ IMPORTANT: transform sur position:fixed crée un nouveau containing block
       sur Android Chrome, ce qui casse le positionnement par rapport au viewport.
       On utilise backface-visibility seul pour la stabilité GPU. */
body:not(.is-ios) .pwa-input-area,
body:not(.is-ios) .pwa-tab-bar {
  /* ❌ RETIRÉ: transform: translate3d(0, 0, 0) - cause instabilité sur Android */
  backface-visibility: hidden !important;
  -webkit-backface-visibility: hidden !important;
}

/* ================================================
       8. HEADER STICKY ANDROID
       Le header doit rester fixe en haut sur Android.
       On utilise sticky au lieu de fixed pour éviter les
       problèmes de stacking context avec le layout flex.
       ================================================ */
body:not(.is-ios) .pwa-header-pro {
  position: sticky !important;
  top: 0 !important;
  z-index: 100 !important;
  /* Background opaque obligatoire pour couvrir le contenu scrollé */
  background: #0a0a0a !important;
}

/* ================================================
       8b. HEADER FIXED iOS WEB
       FIX: Le header doit rester fixe en haut sur iOS web.
       On utilise position: fixed car sticky ne fonctionne pas
       (le header n'est pas enfant direct de l'élément scrollable).
       ================================================ */
body.is-ios .pwa-header-pro {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  z-index: 1000 !important;
  /* Background opaque obligatoire pour couvrir le contenu scrollé */
  background: #0a0a0a !important;
  /* Empêcher le backdrop-filter de causer des bugs */
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Compenser la hauteur du header fixed sur iOS
       Le padding doit être sur .pwa-messages-area (zone scrollable)
       pour que le premier message ne soit pas caché sous le header */
body.is-ios .pwa-messages-area {
  padding-top: calc(68px + var(--safe-top, 0px)) !important;
}

/* Ajustement pour iPhone SE (petit écran) */
@media (max-width: 375px) {
  body.is-ios .pwa-messages-area {
    padding-top: calc(76px + var(--safe-top, 0px)) !important;
  }
}

/* ================================================
       9. RETIRER TRANSFORMS SUR MESSAGES AREA ANDROID
       Le transform: translateZ(0) crée un nouveau stacking context
       qui peut causer des problèmes de scroll sur Android.
       ================================================ */
body:not(.is-ios) .pwa-messages-area {
  transform: none !important;
  -webkit-transform: none !important;
  /* Garder les autres optimisations scroll */
}

/* ================================================
       10. VERROUILLAGE SCROLL ANDROID
       Empêche le scroll de "remonter" au body/html sur Android.
       Le scroll doit être contenu dans .pwa-messages-area uniquement.
       ✅ FIX: touch-action: pan-y pinch-zoom au lieu de none
       Permet le zoom accessibilité (WCAG 2.1) tout en bloquant scroll body
       ================================================ */
body:not(.is-ios):not(.admin-page-active) {
  overflow: hidden !important;
  /* ✅ FIX: Permettre pinch-zoom pour accessibilité (WCAG 1.4.4) */
  touch-action: pan-y pinch-zoom !important;
  overscroll-behavior: none !important;
}

body:not(.is-ios):not(.admin-page-active) #root {
  overflow: hidden !important;
  height: 100% !important;
  touch-action: pan-y pinch-zoom !important;
}

/* Admin page Android - allow scroll in content */
body:not(.is-ios).admin-page-active {
  overflow: hidden !important;
  position: relative !important;
}

body:not(.is-ios).admin-page-active #root {
  overflow: visible !important;
  position: relative !important;
  height: 100dvh !important;
}

body:not(.is-ios) .pwa-app-container {
  overflow: hidden !important;
  height: 100% !important;
  max-height: 100vh !important;
  max-height: 100dvh !important;
  touch-action: pan-y pinch-zoom !important;
  overscroll-behavior: contain !important;
}

body:not(.is-ios) .pwa-main-content {
  overflow: visible !important;
  flex: 1 !important;
  min-height: 0 !important;
  touch-action: pan-y pinch-zoom !important;
}

body:not(.is-ios) .pwa-chat-container {
  overflow: hidden !important;
  flex: 1 !important;
  min-height: 0 !important;
  touch-action: pan-y pinch-zoom !important;
}

body:not(.is-ios) .pwa-messages-area {
  /* SEUL élément qui peut scroller sur Android */
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: auto !important;
  overscroll-behavior: contain !important;
  touch-action: pan-y pinch-zoom !important;
}

/* ✅ FIX: Permettre scroll dans les modals/panels Android */
body:not(.is-ios) .pwa-settings-content,
body:not(.is-ios) .pwa-panel-content,
body:not(.is-ios) .pwa-help-list,
body:not(.is-ios) .pwa-ctx-options,
body:not(.is-ios) .pwa-modal-body {
  overflow-y: auto !important;
  touch-action: pan-y pinch-zoom !important;
  overscroll-behavior: contain !important;
}

/* ✅ FIX: Permettre scroll dans la page Admin Android */
body:not(.is-ios) .admin-panel {
  touch-action: pan-y pinch-zoom !important;
  overscroll-behavior: contain !important;
}

body:not(.is-ios) .admin-content {
  overflow-y: auto !important;
  touch-action: pan-y pinch-zoom !important;
  overscroll-behavior: contain !important;
  -webkit-overflow-scrolling: touch !important;
}

/* Permettre les interactions tactiles sur les éléments interactifs Android */
body:not(.is-ios) .pwa-input-area,
body:not(.is-ios) .pwa-tab-bar,
body:not(.is-ios) button,
body:not(.is-ios) input,
body:not(.is-ios) textarea,
body:not(.is-ios) a,
body:not(.is-ios) [role="button"] {
  touch-action: manipulation !important;
}

/* ================================================
       11. CLAVIER VIRTUEL ANDROID
       Gère le repositionnement des éléments fixes quand
       le clavier virtuel est ouvert (prend ~50% viewport)
       ================================================ */
@media (max-height: 500px) {
  body:not(.is-ios) .pwa-tab-bar {
    /* Masquer tab bar quand clavier ouvert */
    display: none !important;
  }

  body:not(.is-ios) .pwa-input-area {
    /* Coller au bas visible */
    bottom: 0 !important;
    padding-bottom: env(safe-area-inset-bottom, 8px) !important;
  }

  body:not(.is-ios) .pwa-messages-area {
    /* Réduire padding bottom pour laisser place à l'input */
    padding-bottom: 80px !important;
  }

  body:not(.is-ios) .pwa-chat-container .scroll-to-bottom-fab--pwa {
    bottom: calc(
      var(--pwa-chat-input-height, 72px) + 14px +
        env(safe-area-inset-bottom, 8px)
    );
  }

  body:not(.is-ios) .pwa-header-pro {
    /* Header plus compact */
    padding: 8px 16px !important;
  }
}

/* Android keyboard detected via visualViewport API (more reliable than max-height) */
html.keyboard-open body:not(.is-ios) .pwa-tab-bar {
  display: none !important;
}

html.keyboard-open body:not(.is-ios) .pwa-input-area {
  bottom: 0 !important;
  padding-bottom: env(safe-area-inset-bottom, 8px) !important;
}

html.keyboard-open body:not(.is-ios) .pwa-chat-container {
  padding-bottom: calc(
    var(--pwa-chat-input-height, 72px) + env(safe-area-inset-bottom, 8px)
  ) !important;
}

html.keyboard-open
  body:not(.is-ios)
  .pwa-chat-container
  .scroll-to-bottom-fab--pwa {
  bottom: calc(
    var(--pwa-chat-input-height, 72px) + 14px + env(safe-area-inset-bottom, 8px)
  );
}

html.keyboard-open body:not(.is-ios) .pwa-messages-area {
  padding-bottom: calc(var(--pwa-chat-input-height, 72px) + 12px) !important;
}

/* ================================================
       12. ORIENTATION LANDSCAPE ANDROID
       Support tablettes et téléphones en mode paysage
       ================================================ */
@media (orientation: landscape) and (max-width: 915px) {
  body:not(.is-ios) .pwa-header-container {
    padding: 8px 16px;
  }

  body:not(.is-ios) .pwa-header-pro {
    padding: 6px 16px !important;
  }

  body:not(.is-ios) .pwa-tab-bar {
    height: 50px !important;
    min-height: 50px !important;
    max-height: 50px !important;
    padding: 0 !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    box-sizing: content-box !important;
  }

  body:not(.is-ios) .pwa-tab-bar-content {
    height: 100% !important;
    min-height: 50px !important;
  }

  body:not(.is-ios) .pwa-input-area {
    bottom: calc(50px + env(safe-area-inset-bottom, 0px)) !important;
    padding: 6px 16px !important;
  }

  body:not(.is-ios) .pwa-message-bubble {
    padding: 10px 14px;
    font-size: 14px;
  }

  body:not(.is-ios) .pwa-landing-content {
    padding-top: 20px;
  }

  body:not(.is-ios) .pwa-main-title {
    font-size: 24px;
  }
}

/* Tablettes Android en landscape (>915px) */
@media (orientation: landscape) and (min-width: 916px) {
  body:not(.is-ios) .pwa-app-container {
    max-width: 900px;
    margin: 0 auto;
  }
}

/* ================================================
       13. PREFERS-REDUCED-MOTION (Accessibilité)
       Désactive les animations pour les utilisateurs sensibles
       ================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .pwa-modes-sheet {
    transition: none !important;
  }
}

/* ================================================
       14. Z-INDEX HIÉRARCHIE CORRIGÉE
       Évite les chevauchements non déterministes
       ================================================ */
body:not(.is-ios) .pwa-header-pro {
  z-index: 100 !important;
}

body:not(.is-ios) .pwa-tab-bar {
  z-index: 1000 !important;
}

body:not(.is-ios) .pwa-input-area {
  z-index: 1001 !important;
}

body:not(.is-ios) .pwa-ctx-wrapper,
body:not(.is-ios) .pwa-ctx-panel {
  z-index: 10000 !important;
}

body:not(.is-ios) .pwa-lightbox-overlay {
  z-index: 10500 !important;
}

body:not(.is-ios) .pwa-settings-overlay,
body:not(.is-ios) .pwa-settings-modal {
  z-index: 11000 !important;
}

/* ================================================
       15. PROTECTION :HOVER POUR TOUCH DEVICES
       Évite l'effet "collé" sur Android après tap
       ================================================ */
@media (hover: hover) and (pointer: fine) {
  /* Ces hovers ne s'appliquent QUE sur desktop avec souris */
  .pwa-header-action-btn:hover,
  .pwa-profile-btn:hover,
  .pwa-panel-close:hover,
  .pwa-choice-btn:hover,
  .pwa-start-btn:hover,
  .pwa-action-btn:hover,
  .pwa-settings-close:hover,
  .pwa-settings-card:hover,
  .pwa-lightbox-close:hover,
  .pwa-menu-option:hover,
  .pwa-mode-option:hover {
    /* Styles hover préservés pour desktop */
  }
}

/* Sur touch devices, utiliser :active au lieu de :hover */
@media (hover: none) {
  .pwa-header-action-btn:hover,
  .pwa-profile-btn:hover,
  .pwa-panel-close:hover,
  .pwa-choice-btn:not(.selected):hover,
  .pwa-start-btn:hover,
  .pwa-action-btn:hover,
  .pwa-settings-close:hover,
  .pwa-settings-card:hover,
  .pwa-menu-option:hover,
  .pwa-mode-option:not(.active):hover {
    /* Désactiver hover sur touch - MAIS préserver .active/.selected */
    background: inherit !important;
    transform: none !important;
    box-shadow: inherit !important;
  }

  /* ✅ FIX: Préserver le style rouge du bouton lightbox-close sur touch */
  .pwa-lightbox-close:hover {
    background: #ff4757 !important;
    transform: none !important;
    box-shadow: 0 4px 15px rgba(255, 71, 87, 0.5) !important;
  }

  /* ✅ FIX: Forcer la surbrillance active sur Android touch devices */
  .pwa-mode-option.active {
    background: rgba(255, 107, 107, 0.12) !important;
    color: #ff6b6b !important;
    box-shadow: 0 1px 4px rgba(255, 107, 107, 0.15) !important;
  }

  /* ✅ FIX: Préserver surbrillance .selected pour pwa-choice-btn (landing page) */
  .pwa-choice-btn.selected {
    background: rgba(255, 107, 107, 0.2) !important;
    border-color: rgba(255, 107, 107, 0.8) !important;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3) !important;
  }

  /* Active states pour feedback tactile */
  .pwa-header-action-btn:active,
  .pwa-profile-btn:active,
  .pwa-choice-btn:active,
  .pwa-start-btn:active,
  .pwa-action-btn:active,
  .pwa-settings-card:active,
  .pwa-menu-option:active,
  .pwa-mode-option:active {
    opacity: 0.7;
    transform: scale(0.98);
  }
}

/* ================================================
       16. FIREFOX ANDROID SPECIFIC FIXES
       Firefox Android a des bugs avec backface-visibility
       ================================================ */
body.firefox-android .pwa-input-area,
body.firefox-android .pwa-tab-bar {
  backface-visibility: visible !important;
  -webkit-backface-visibility: visible !important;
}

/* ================================================
       17. SAMSUNG BROWSER SPECIFIC FIXES
       Samsung Browser a des bugs avec position:fixed + backdrop
       ================================================ */
body.samsung-browser .pwa-input-area,
body.samsung-browser .pwa-tab-bar,
body.samsung-browser .pwa-header-container {
  /* Éviter flickering sur Samsung Browser */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

/* ================================================
       18. 🚨 ANDROID TAB BAR - FIX ESPACE NOIR FINAL
       Fix ultra-agressif pour supprimer l'espace noir
       au-dessus des boutons de navigation sur Android
       ================================================ */
body.is-android .pwa-tab-bar {
  /* Reset complet */
  height: 50px !important;
  min-height: 50px !important;
  max-height: 50px !important;
  padding: 0 !important;
  padding-top: 0 !important;
  padding-bottom: env(safe-area-inset-bottom, 0px) !important;
  margin: 0 !important;
  margin-top: 0 !important;
  /* Flex centré */
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  /* Box model */
  box-sizing: content-box !important;
  /* Position fixe en bas */
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  /* Background solide */
  background: #0a0a0a !important;
}

body.is-android .pwa-tab-bar-content {
  /* Remplit tout le conteneur */
  height: 100% !important;
  min-height: 50px !important;
  width: 100% !important;
  /* Reset margins/paddings */
  margin: 0 !important;
  margin-top: 0 !important;
  padding: 0 !important;
  padding-top: 0 !important;
  /* Flex centré */
  display: flex !important;
  align-items: center !important;
  justify-content: space-around !important;
}

body.is-android .pwa-tab-button {
  /* Reset margins */
  margin: 0 !important;
  margin-top: 0 !important;
  padding: 0 !important;
  /* Hauteur complète */
  height: 100% !important;
  min-height: 45px !important;
}

/* ================================================
   16. ADMIN PANEL - PWA MOBILE FIX
   Fix scroll chaining et responsive grids
   ================================================ */

/* CRITICAL: Override base.css restrictions when admin is active */
html.admin-page-active,
body.admin-page-active {
  overflow: hidden !important;
  position: relative !important;
  height: 100dvh !important;
  width: 100% !important;
}

html.admin-page-active #root,
body.admin-page-active #root {
  overflow: visible !important;
  position: relative !important;
  height: 100dvh !important;
  width: 100% !important;
}

/* Container Admin PWA - Fix scroll chaining */
.admin-panel.admin-pwa-mode {
  height: 100dvh !important;
  height: calc(var(--vh, 1vh) * 100) !important;
  position: relative !important;
  overflow: hidden !important;
  /* DO NOT use touch-action: none here - it blocks children from scrolling */
}

/* Zone scrollable Admin - SEUL élément qui scroll */
.admin-panel.admin-pwa-mode .admin-content {
  flex: 1 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior: contain !important;
  overscroll-behavior-y: contain !important;
  touch-action: pan-y !important;
}

/* Empêcher scroll body quand Admin ouvert */
body:has(.admin-panel.admin-pwa-mode) {
  overflow: hidden !important;
  position: fixed !important;
  width: 100% !important;
  height: 100% !important;
}

/* iOS Admin specifique */
body.is-ios .admin-panel.admin-pwa-mode .admin-content {
  -webkit-overflow-scrolling: touch !important;
}

/* Android Admin specifique */
body:not(.is-ios) .admin-panel.admin-pwa-mode .admin-content {
  touch-action: pan-y pinch-zoom !important;
  -webkit-overflow-scrolling: auto !important;
  overflow-y: auto !important;
}

/* ================================================
   17. ADMIN GRIDS RESPONSIVE
   ================================================ */

@media (max-width: 480px) {
  /* Force 1 colonne sur les grandes grilles */
  .admin-panel.admin-pwa-mode [style*="grid"] {
    gap: 12px !important;
  }

  /* Padding réduit sur mobile */
  .admin-panel.admin-pwa-mode .admin-content > div {
    padding: 0 !important;
  }

  .admin-panel.admin-pwa-mode .admin-content > div > div {
    margin-bottom: 12px !important;
  }
}

/* ================================================
   18. ADMIN TABLES RESPONSIVE
   ================================================ */

.admin-panel.admin-pwa-mode table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.admin-panel.admin-pwa-mode thead,
.admin-panel.admin-pwa-mode tbody,
.admin-panel.admin-pwa-mode tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}

.admin-panel.admin-pwa-mode td,
.admin-panel.admin-pwa-mode th {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .admin-panel.admin-pwa-mode td,
  .admin-panel.admin-pwa-mode th {
    padding: 8px 6px !important;
    font-size: 11px !important;
    max-width: 100px;
  }
}

/* ================================================
   19. ADMIN TEXT TRUNCATION
   ================================================ */

.admin-panel.admin-pwa-mode .truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* Emails et URLs */
.admin-panel.admin-pwa-mode [style*="monospace"] {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

/* Cards - empêcher débordement */
.admin-panel.admin-pwa-mode [style*="borderRadius"] {
  overflow: hidden;
}

/* Labels de stats */
.admin-panel.admin-pwa-mode [style*="fontSize: '10px'"],
.admin-panel.admin-pwa-mode [style*="fontSize: '11px'"],
.admin-panel.admin-pwa-mode [style*="fontSize: '12px'"] {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ================================================
       UNMASKED PULSE ANIMATION
       Pulses the Unmasked tab icon when profile is ready
       ================================================ */

@keyframes unmasked-pulse {
  0%,
  100% {
    filter: drop-shadow(0 0 4px rgba(255, 107, 107, 0.3));
    transform: scale(1);
  }
  50% {
    filter: drop-shadow(0 0 12px rgba(255, 107, 107, 0.8));
    transform: scale(1.1);
  }
}

.pwa-tab-unmasked-pulse .pwa-tab-icon {
  animation: unmasked-pulse 2s ease-in-out infinite;
}

.pwa-tab-unmasked-pulse .pwa-tab-label {
  text-shadow: 0 0 8px rgba(255, 107, 107, 0.3);
}

/* ================================================
       CONTEXT EYE PUPIL GLOW ANIMATION
       Glows only the pupil (center) of the Eye icon
       when MyStory context is filled. Uses two SVG circles:
       - .context-pupil-halo = larger circle behind pupil (glow)
       - .context-pupil-core = the pupil itself, pulses bright
       ================================================ */

@keyframes pupilHaloPulse {
  0%,
  100% {
    fill: rgba(255, 107, 107, 0.15);
    r: 4.5;
  }
  50% {
    fill: rgba(255, 107, 107, 0.45);
    r: 5.5;
  }
}

@keyframes pupilCorePulse {
  0%,
  100% {
    fill: #ff6b6b;
    opacity: 0.8;
  }
  50% {
    fill: #ff4757;
    opacity: 1;
  }
}

.context-pupil-halo {
  fill: rgba(255, 107, 107, 0.2);
  animation: pupilHaloPulse 2s ease-in-out infinite;
}

.context-pupil-core {
  animation: pupilCorePulse 2s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .context-pupil-halo {
    animation: none !important;
    fill: rgba(255, 107, 107, 0.25);
  }
  .context-pupil-core {
    animation: none !important;
    fill: #ff6b6b;
    opacity: 1;
  }
}

/* Performance: Skip rendering of off-screen messages */
.pwa-messages-list > *,
.pwa-messages-area > .pwa-message-wrapper,
.messages-list > * {
  content-visibility: auto;
  contain-intrinsic-size: auto 80px;
}

/* During refresh auto-scroll, force real layout so scrollHeight is accurate. */
.pwa-chat-container[data-scroll-lock-active="true"] .pwa-messages-list > *,
.pwa-messages-area[data-scroll-lock-active="true"] .pwa-messages-list > *,
.pwa-messages-list[data-scroll-lock-active="true"] > *,
.messages-list[data-scroll-lock-active="true"] > * {
  content-visibility: visible;
  contain-intrinsic-size: auto;
}

.pwa-chat-container[data-scroll-lock-active="true"],
.pwa-messages-area[data-scroll-lock-active="true"],
.pwa-messages-list[data-scroll-lock-active="true"],
.messages-list[data-scroll-lock-active="true"] {
  scroll-behavior: auto !important;
  overflow-anchor: none;
}

/* ================================================ */
/* === TABLET BREAKPOINT (769px - 1024px) === */
/* ================================================ */

@media (min-width: 769px) and (max-width: 1024px) {
  .pwa-app-container {
    max-width: 100%;
  }

  .pwa-main-content {
    padding: 0 24px;
  }

  .pwa-tab-bar {
    max-width: 600px;
    margin: 0 auto;
    border-radius: 16px 16px 0 0;
  }
}

/* ================================================
       FIN DU FICHIER pwa-mobile.css
       ================================================ */
