/* ===== VARIABLES & RESET ===== */
:root {
  --brume-aube: #F5F3EE;
  --sauge-lien: #DDE9E2;
  --terracotta-soft: #D4A38F;
  --gris-anthracite: #3A3A3A;
  --sauge: #8BAF9A;
  --font-serif: 'Vollkorn', Georgia, serif;
  --font-sans: 'Lato', Arial, sans-serif;
  --fade-in: 600ms;
}

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

body {
  font-family: var(--font-sans);
  background: linear-gradient(160deg, #F5F3EE 0%, #EDE8E0 40%, #F0EDE7 100%);
  color: var(--gris-anthracite);
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100dvh;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

/* Grain subtil pour donner de la texture */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ===== APP CONTAINER ===== */
.app-container {
  width: 100%;
  max-width: 420px;
  padding: 30px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* ===== SCREENS ===== */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  flex: 1;
  text-align: center;
  animation: fadeIn var(--fade-in) ease-in-out;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}
.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== TYPOGRAPHIE ===== */
h1 {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 15px;
  color: var(--gris-anthracite);
}

.screen > p {
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 30px;
  opacity: 0.85;
  max-width: 340px;
}

.note-legale {
  font-size: 0.85rem;
  opacity: 0.6;
  max-width: 340px;
}

.screen-icon {
  font-size: 50px;
  margin-bottom: 15px;
}

/* ===== LOGO ===== */
.logo-wrapper { margin-bottom: 10px; }
.logo-img, .logo-img-mini, .header-logo-img {
  display: block;
  filter: drop-shadow(0 2px 8px rgba(139,175,154,0.3));
}
.logo-img { width: 100px; height: 100px; }
.logo-img-mini { width: 60px; height: 60px; }
.header-logo-img { width: 32px; height: 32px; filter: none; }

/* ===== BOUTONS PRIMAIRE & SECONDAIRE ===== */
.btn-primaire {
  background: linear-gradient(135deg, var(--terracotta-soft), #c4917c);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 16px 0;
  width: 100%;
  max-width: 320px;
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(212, 163, 143, 0.35);
  margin-bottom: 15px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.btn-primaire:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(212, 163, 143, 0.45); }
.btn-primaire:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.lien-secondaire {
  color: var(--gris-anthracite);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: bold;
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  transition: opacity 200ms;
}
.lien-secondaire:hover { opacity: 0.6; }

/* ===== FORMULAIRES AUTH ===== */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  margin-bottom: 15px;
}

.auth-form input[type="email"],
.auth-form input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--gris-anthracite);
  background: white;
  outline: none;
  transition: border-color 200ms;
}
.auth-form input[type="email"]:focus,
.auth-form input[type="password"]:focus {
  border-color: var(--sauge);
}
.auth-form input::placeholder {
  color: #aaa;
}

.age-selector {
  display: flex;
  gap: 8px;
  width: 100%;
}

.age-option {
  flex: 1;
  cursor: pointer;
}

.age-option input[type="radio"] {
  display: none;
}

.age-label {
  display: block;
  text-align: center;
  padding: 10px 8px;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: #888;
  background: white;
  transition: all 200ms;
}

.age-option input[type="radio"]:checked + .age-label {
  border-color: var(--sauge);
  color: var(--gris-anthracite);
  background: var(--sauge-lien);
  font-weight: 600;
}

/* ===== ACCESSIBILITY FORM ===== */
.accessibility-section {
  width: 100%;
  margin-top: 4px;
}
.accessibility-title {
  font-size: 0.82rem;
  color: #888;
  margin-bottom: 8px;
  text-align: left;
}
.accessibility-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.access-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.access-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--sauge);
}
.access-label {
  font-size: 0.88rem;
  color: var(--gris-anthracite);
}

/* ===== CONSENT CHECKBOXES (RGPD) ===== */
.consent-section {
  width: 100%;
  margin-top: 8px;
}
.consent-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  margin-bottom: 8px;
}
.consent-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--sauge);
  margin-top: 2px;
  flex-shrink: 0;
}
.consent-label {
  font-size: 0.82rem;
  color: var(--gris-anthracite);
  line-height: 1.4;
}
.consent-link {
  color: var(--sauge);
  text-decoration: underline;
  font-weight: 600;
}
.consent-link:hover { opacity: 0.7; }

/* ===== TOGGLE SWITCHES ===== */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  cursor: pointer;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}
.toggle-label {
  font-size: 0.88rem;
  color: var(--gris-anthracite);
  flex: 1;
}
.toggle-input {
  display: none;
}
.toggle-switch {
  width: 42px;
  height: 24px;
  background: #ddd;
  border-radius: 12px;
  position: relative;
  transition: background 200ms;
  flex-shrink: 0;
}
.toggle-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform 200ms;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle-input:checked + .toggle-switch {
  background: var(--sauge);
}
.toggle-input:checked + .toggle-switch::after {
  transform: translateX(18px);
}

/* ===== VOICE BUTTON ===== */
.voice-btn {
  background: none;
  border: none;
  color: var(--sauge);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 4px;
  transition: color 200ms;
  flex-shrink: 0;
}
.voice-btn:hover { color: var(--terracotta-soft); }
.voice-btn.recording { color: #d45050; animation: pulse 1s infinite; }
.voice-btn.hidden { display: none; }

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

/* ===== LARGE TEXT MODE ===== */
body.large-text .msg { font-size: 1.15rem; line-height: 1.7; }
body.large-text .chat-input textarea { font-size: 1.1rem; }
body.large-text .btn-choix { font-size: 1.15rem; padding: 22px 24px; }
body.large-text .choix-label { font-size: 1.15rem; }
body.large-text .emergency-banner p { font-size: 1.05rem; }
body.large-text .emergency-banner a { font-size: 1.15rem; }
body.large-text .footer-link-visible { font-size: 0.95rem; padding: 10px 18px; }

.auth-error {
  font-size: 0.82rem;
  color: #d45050;
  text-align: center;
  margin: 0;
}
.auth-error.hidden { display: none; }

/* ===== BOUTON GOOGLE + SEPARATEUR ===== */
.auth-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
  width: 100%;
}
.auth-separator::before,
.auth-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(0,0,0,0.08);
}
.auth-separator span {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: #aaa;
}
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 0;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 50px;
  background: white;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gris-anthracite);
  text-decoration: none;
  cursor: pointer;
  transition: all 200ms;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.btn-google:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
body[class*="ambiance-"] .btn-google { background: var(--bg-card); border-color: var(--border); color: var(--text); }
body[class*="ambiance-"] .auth-separator::before,
body[class*="ambiance-"] .auth-separator::after { background: var(--border); }
body[class*="ambiance-"] .auth-separator span { color: var(--text-dim); }

.auth-success {
  text-align: center;
  animation: fadeIn var(--fade-in) ease;
}
.auth-success h2 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  margin-bottom: 10px;
  color: var(--gris-anthracite);
}
.auth-success p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #555;
  max-width: 300px;
}
.auth-success strong {
  color: var(--sauge);
}

/* ===== BOUTONS CHOIX MODULE ===== */
.btn-choix {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--gris-anthracite);
  border: 1px solid rgba(139,175,154,0.15);
  border-left: 3px solid var(--sauge);
  border-radius: 20px;
  padding: 18px 20px;
  margin-bottom: 12px;
  width: 100%;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.04), 0 1px 3px rgba(139,175,154,0.08);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  text-align: left;
}
.btn-choix:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.07), 0 2px 8px rgba(139,175,154,0.12);
  border-left-color: var(--terracotta-soft);
}

.choix-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.choix-text { display: flex; flex-direction: column; }

.choix-label {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.05rem;
}
.choix-sub {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: #888;
  margin-top: 2px;
}

/* ===== LANDING FOOTER ===== */
.landing-footer {
  margin-top: 20px;
  width: 100%;
}

.emergency-banner {
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(212, 163, 143, 0.2);
  border-radius: 12px;
  padding: 10px 16px;
  text-align: center;
  margin-bottom: 12px;
}
.emergency-banner p {
  font-size: 0.9rem;
  color: var(--gris-anthracite);
  margin: 0;
  opacity: 1;
}
.emergency-banner a {
  color: var(--terracotta-soft);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
}
.emergency-banner a:hover { text-decoration: underline; }

.footer-links {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-link-visible {
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(0,0,0,0.04);
  border-radius: 20px;
  padding: 8px 14px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--gris-anthracite);
  cursor: pointer;
  transition: all 200ms;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}
.footer-link-visible:hover {
  background: var(--sauge-lien);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(139,175,154,0.15);
}

/* ===== MODALES (Pourquoi Lien / Ressources) ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  animation: fadeIn 400ms ease;
}
.modal-overlay.hidden { display: none; }

.modal-card {
  background: #fff;
  border-radius: 20px;
  padding: 2rem 1.8rem;
  max-width: 380px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  text-align: left;
}

.modal-card h2 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  margin-bottom: 1rem;
  color: var(--gris-anthracite);
}

.modal-card h3 {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 700;
  margin: 1rem 0 0.5rem;
  color: var(--gris-anthracite);
}

.modal-card p {
  font-size: 0.88rem;
  line-height: 1.6;
  color: #555;
  margin-bottom: 0.6rem;
}

.manifeste-list,
.ressources-list {
  list-style: none;
  padding: 0;
  margin-bottom: 0.8rem;
}

.manifeste-list li {
  font-size: 0.88rem;
  line-height: 1.6;
  color: #555;
  padding: 0.3rem 0;
  padding-left: 1rem;
  position: relative;
}
.manifeste-list li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--sauge);
}

.ressources-list li {
  font-size: 0.88rem;
  line-height: 1.6;
  color: #555;
  padding: 0.25rem 0;
}
.ressources-list li strong {
  color: var(--terracotta-soft);
}
.ressources-list a {
  color: var(--sauge);
  text-decoration: underline;
  font-weight: 600;
}
.ressources-list a:hover { opacity: 0.7; }

.manifeste-closing {
  font-family: var(--font-serif);
  font-style: italic;
  margin-top: 1.2rem;
  color: var(--gris-anthracite);
  font-size: 0.92rem;
  text-align: center;
}

.manifeste-subtitle {
  font-size: 0.82rem;
  color: var(--sauge);
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.manifeste-point {
  font-size: 0.88rem;
  line-height: 1.6;
  color: #555;
  margin-bottom: 0.8rem;
  padding-left: 0.8rem;
  border-left: 2px solid var(--sauge-lien);
}

.ressources-note {
  font-size: 0.82rem;
  font-style: italic;
  opacity: 0.7;
  margin-top: 1rem;
}

.modal-close-btn {
  display: block;
  margin: 1.2rem auto 0;
  background: none;
  border: 1px solid #ddd;
  border-radius: 50px;
  padding: 0.5rem 2rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: #888;
  cursor: pointer;
  transition: border-color 200ms, color 200ms;
}
.modal-close-btn:hover {
  border-color: var(--sauge);
  color: var(--gris-anthracite);
}

/* ===== RGPD BUTTONS ===== */
.rgpd-section { margin-top: 1rem; }

.btn-danger-outline {
  width: 100%;
  padding: 12px;
  border: 1.5px solid #d45050;
  border-radius: 12px;
  background: none;
  color: #d45050;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 200ms;
  margin-bottom: 4px;
}
.btn-danger-outline:hover { background: #fef2f2; }

.btn-danger {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: #d45050;
  color: white;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 200ms;
  margin-top: 12px;
  margin-bottom: 4px;
}
.btn-danger:hover { background: #c03030; }

.rgpd-hint {
  font-size: 0.72rem;
  color: #aaa;
  margin-bottom: 8px;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  z-index: 200;
  animation: fadeIn 300ms ease;
  max-width: 340px;
  text-align: center;
}
.toast.error { background: #d45050; color: white; }
.toast.success { background: var(--sauge); color: white; }
.toast.warning { background: var(--terracotta-soft); color: white; }

/* ===== MON ESPACE ===== */
#screen-profile {
  text-align: left;
  justify-content: flex-start;
  padding-top: 0;
}

.profile-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem 0;
  width: 100%;
}

.profile-section {
  margin-bottom: 1.8rem;
}

.profile-section-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  color: var(--gris-anthracite);
  margin-bottom: 0.8rem;
}

/* Avatar grid */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.avatar-item {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid transparent;
  border-radius: 14px;
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 200ms;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.avatar-item:hover {
  border-color: var(--sauge);
  transform: translateY(-2px);
}
.avatar-item.selected {
  border-color: var(--sauge);
  background: var(--sauge-lien);
}
.avatar-item svg {
  width: 28px;
  height: 28px;
}

/* Quota bar */
.quota-bar-wrapper { width: 100%; }

.quota-bar {
  width: 100%;
  height: 10px;
  background: #e4e8eb;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 6px;
}

.quota-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--sauge), var(--sauge-lien));
  border-radius: 10px;
  transition: width 600ms ease;
}

.quota-text {
  font-size: 0.8rem;
  color: #888;
}

.plan-text {
  font-size: 0.9rem;
  color: #666;
}

/* ===== CHAT HEADER ===== */
.chat-header {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid #e4e8eb;
  overflow: hidden;
}
/* Le bouton retour ne doit jamais etre ecrase */
.chat-header > .header-action-btn:first-child {
  flex-shrink: 0;
  min-width: 32px;
  padding: 4px;
}
.chat-header button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gris-anthracite);
  display: flex;
  align-items: center;
}
.header-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--sauge);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex-shrink: 1;
}

.header-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  margin-left: auto;
}

.header-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px 6px;
  border: none;
  background: none;
  cursor: pointer;
  color: #888;
  border-radius: 8px;
  transition: all 200ms;
  min-width: 42px;
}
.header-action-btn:hover { background: rgba(0,0,0,0.04); color: var(--gris-anthracite); }

.header-action-label {
  font-family: var(--font-sans);
  font-size: 0.58rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Music playing state */
.header-action-btn.playing { color: var(--terracotta-soft); }

body[class*="ambiance-"] .header-action-btn { color: var(--text-dim); }
body[class*="ambiance-"] .header-action-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-light); }
body[class*="ambiance-"] .header-action-btn.playing { color: #d4a38f; }

/* ===== CHAT SCREEN ===== */
#screen-chat {
  text-align: left;
  justify-content: flex-start;
  overflow: hidden;
  height: 100%;
}

/* ===== MESSAGES ===== */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  width: 100%;
}

.msg {
  max-width: 88%;
  padding: 1rem 1.2rem;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.75;
  letter-spacing: 0.01em;
}
.msg.lien {
  align-self: flex-start;
  background: linear-gradient(135deg, #DDE9E2 0%, #d0e2d8 100%);
  font-family: var(--font-serif);
  font-size: 0.96rem;
  color: var(--gris-anthracite);
  animation: messageAppear 800ms ease;
  box-shadow: 0 2px 12px rgba(139,175,154,0.12);
}
.msg.user {
  align-self: flex-end;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-family: var(--font-sans);
  font-weight: 300;
  color: var(--gris-anthracite);
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  animation: messageAppear 400ms ease;
}

@keyframes messageAppear {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 0.8rem 0;
}
.typing-indicator.hidden { display: none; }
.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sauge);
  opacity: 0.4;
  animation: breathe 1.8s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.3s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.6s; }

@keyframes breathe {
  0%, 100% { opacity: 0.3; transform: scale(0.85); }
  50%      { opacity: 1;   transform: scale(1); }
}

/* ===== CHAT INPUT ===== */
.chat-input {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0;
  border-top: 1px solid #e4e8eb;
  width: 100%;
}

.input-wrapper {
  flex: 1;
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 14px;
  padding: 0 14px;
  transition: border-color 200ms, box-shadow 200ms;
}
.input-wrapper:focus-within { border-color: var(--sauge); box-shadow: 0 0 0 3px rgba(139,175,154,0.1); }

.chat-input textarea {
  width: 100%;
  border: none;
  outline: none;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  padding: 0.7rem 0;
  color: var(--gris-anthracite);
  background: transparent;
  resize: none;
  overflow-y: hidden;
  line-height: 1.4;
  max-height: 120px;
}
.chat-input textarea::placeholder { color: #b0b0b0; }

.send-btn {
  background: linear-gradient(135deg, var(--terracotta-soft), #c4917c);
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 200ms, transform 200ms, box-shadow 200ms;
  flex-shrink: 0;
  box-shadow: 0 3px 12px rgba(212,163,143,0.35);
}
.send-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 18px rgba(212,163,143,0.45); }
.send-btn:active { transform: scale(0.93); }

body[class*="ambiance-"] .input-wrapper { background: var(--bg-card); border-color: var(--border); }
body[class*="ambiance-"] .input-wrapper:focus-within { border-color: var(--accent); }
body[class*="ambiance-"] .chat-input textarea { color: var(--text); }
body[class*="ambiance-"] .chat-input textarea::placeholder { color: var(--text-dim); }

/* ===== CRISIS OVERLAY ===== */
.crisis-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 400ms ease;
}
.crisis-overlay.hidden { display: none; }

.crisis-card {
  background: #fff;
  border-radius: 20px;
  padding: 2rem;
  max-width: 360px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}
.crisis-card h2 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  margin-bottom: 0.8rem;
  color: var(--gris-anthracite);
}
.crisis-card p {
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 1.2rem;
  color: #555;
}
.crisis-contacts {
  list-style: none;
  margin-bottom: 1.5rem;
}
.crisis-contacts li {
  padding: 0.5rem 0;
  font-size: 0.95rem;
}
.crisis-contacts li strong {
  color: var(--terracotta-soft);
  font-size: 1.15rem;
}
.crisis-close-btn {
  background: var(--terracotta-soft);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0.7rem 2rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 200ms;
  display: block;
  width: 100%;
  margin-bottom: 0.6rem;
}
.crisis-close-btn:hover { background: #c4917c; }

.crisis-dismiss-btn {
  background: none;
  border: 1px solid #ccc;
  border-radius: 12px;
  padding: 0.6rem 1.5rem;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: #777;
  cursor: pointer;
  transition: border-color 200ms, color 200ms;
  display: block;
  width: 100%;
}
.crisis-dismiss-btn:hover {
  border-color: var(--sauge);
  color: var(--gris-anthracite);
}

/* ===== RELAIS LOCAL (Géolocalisation jetable) ===== */
.relay-consent-btn {
  display: block;
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--sauge);
  border-radius: 14px;
  background: var(--sauge-lien);
  color: var(--gris-anthracite);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 200ms;
  margin-bottom: 4px;
}
.relay-consent-btn:hover {
  background: var(--sauge);
  color: white;
  transform: translateY(-1px);
}
.relay-consent-btn:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.relay-hint {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  color: #aaa;
  text-align: center;
}

.relay-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.relay-title {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gris-anthracite);
  margin: 0 0 4px;
}

.relay-card {
  background: white;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.relay-name {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gris-anthracite);
}

.relay-dist {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: #888;
}

.relay-phone {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  color: var(--terracotta-soft);
  font-weight: 600;
  text-decoration: none;
}
.relay-phone:hover { text-decoration: underline; }

.relay-no-phone {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: #bbb;
  font-style: italic;
}

.relay-footer {
  font-family: var(--font-sans);
  font-size: 0.68rem;
  color: #bbb;
  text-align: center;
  margin: 4px 0 0;
}

/* ===== SCROLL ANCHOR ===== */
#messages-anchor {
  height: 0;
  width: 0;
  flex-shrink: 0;
}

/* ===== LOGO MINI (écran 3 + header) ===== */
.logo-mini {
  margin-bottom: 12px;
}
.header-logo {
  flex-shrink: 0;
}

/* ===== AMBIANCE GRID ===== */
.ambiance-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.ambiance-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: white;
  cursor: pointer;
  transition: all 200ms;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.ambiance-item:hover { border-color: var(--sauge); transform: translateY(-2px); }
.ambiance-item.selected { border-color: var(--sauge); background: var(--sauge-lien); }

.ambiance-preview {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: block;
}
.ambiance-preview-sauge { background: linear-gradient(135deg, #F0F4F7, #DDE9E2); }
.ambiance-preview-nuit { background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460); }
.ambiance-preview-foret { background: linear-gradient(135deg, #2d5016, #4a7c2e, #8baa6f); }
.ambiance-preview-ocean { background: linear-gradient(135deg, #0c2d48, #145374, #2e8bc0); }

.ambiance-name {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  color: #888;
}

/* ===== AMBIANCE THEMES — Système CSS Variables ===== */
/* Chaque thème définit ses variables, un seul bloc de règles pour tous */

body.ambiance-nuit {
  --bg: #1a1a2e; --bg-card: #16213e; --bg-active: #0f3460;
  --text: #d4d4d8; --text-light: #e4e4e7; --text-muted: #a0a0b0; --text-dim: #6a6a8a;
  --accent: #7ec8a0; --border: #2a2a4a;
}
body.ambiance-foret {
  --bg: #1e3a1e; --bg-card: #2d5016; --bg-active: #3a6b24;
  --text: #d4ddd4; --text-light: #e4ede4; --text-muted: #a8bda8; --text-dim: #6a8a6a;
  --accent: #a8d48a; --border: #3a5a2a;
}
body.ambiance-ocean {
  --bg: #0c2d48; --bg-card: #145374; --bg-active: #1a6fa0;
  --text: #c8dce8; --text-light: #d8e8f4; --text-muted: #8aaabe; --text-dim: #5a7a8e;
  --accent: #6ec4e8; --border: #1a4a6a;
}

/* Règles communes pour les 3 thèmes sombres */
body.ambiance-nuit, body.ambiance-foret, body.ambiance-ocean {
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg-card) 50%, var(--bg) 100%);
  color: var(--text);
}
body.ambiance-nuit::before, body.ambiance-foret::before, body.ambiance-ocean::before {
  opacity: 0.015;
}

/* Layout */
body[class*="ambiance-"] .app-container { color: var(--text); }

/* Typo */
body[class*="ambiance-"] h1 { color: var(--text-light); }
body[class*="ambiance-"] .screen > p,
body[class*="ambiance-"] .note-legale { color: var(--text-muted); }

/* Logo — fond arrondi s'adapte au thème */
body[class*="ambiance-"] .logo-wrapper,
body[class*="ambiance-"] .logo-mini,
body[class*="ambiance-"] .header-logo { color: var(--accent); }

/* Auth forms */
body[class*="ambiance-"] .auth-form input[type="email"],
body[class*="ambiance-"] .auth-form input[type="password"] {
  background: var(--bg-card); border-color: var(--border); color: var(--text);
}
body[class*="ambiance-"] .auth-form input::placeholder { color: var(--text-dim); }
body[class*="ambiance-"] .age-label { background: var(--bg-card); border-color: var(--border); color: var(--text-muted); }
body[class*="ambiance-"] .age-option input[type="radio"]:checked + .age-label {
  background: var(--bg-active); border-color: var(--accent); color: var(--text-light);
}
body[class*="ambiance-"] .accessibility-title { color: var(--text-dim); }
body[class*="ambiance-"] .access-label { color: var(--text); }
body[class*="ambiance-"] .access-option input[type="checkbox"] { accent-color: var(--accent); }
body[class*="ambiance-"] .consent-label { color: var(--text-muted); }
body[class*="ambiance-"] .consent-link { color: var(--accent); }
body[class*="ambiance-"] .consent-option input[type="checkbox"] { accent-color: var(--accent); }
body[class*="ambiance-"] .lien-secondaire { color: #d4a38f; }
body[class*="ambiance-"] .btn-primaire { background-color: #d4a38f; color: var(--bg); }
body[class*="ambiance-"] .screen-icon { filter: grayscale(0.2); }
body[class*="ambiance-"] .auth-success h2 { color: var(--text-light); }
body[class*="ambiance-"] .auth-success p { color: var(--text-muted); }
body[class*="ambiance-"] .auth-success strong { color: var(--accent); }
body[class*="ambiance-"] .auth-error { color: #f87171; }

/* Chat */
body[class*="ambiance-"] .msg.lien { background: var(--bg-card); color: var(--text); }
body[class*="ambiance-"] .msg.user { background: var(--bg-active); color: var(--text-light); box-shadow: none; }
body[class*="ambiance-"] .chat-input input { color: var(--text); }
body[class*="ambiance-"] .chat-input { border-top-color: var(--border); }
body[class*="ambiance-"] .chat-header { border-bottom-color: var(--border); }
body[class*="ambiance-"] .header-title { color: var(--accent); }
body[class*="ambiance-"] .typing-indicator span { background: var(--accent); }
body[class*="ambiance-"] .voice-btn { color: var(--accent); }

/* Module choice */
body[class*="ambiance-"] .btn-choix { background: var(--bg-card); color: var(--text); border-color: var(--border); }
body[class*="ambiance-"] .btn-choix:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.2); }
body[class*="ambiance-"] .btn-choix .choix-icon svg path,
body[class*="ambiance-"] .btn-choix .choix-icon svg circle { stroke: var(--accent); fill: none; }
body[class*="ambiance-"] .btn-choix .choix-icon svg circle[fill] { fill: var(--accent); }
body[class*="ambiance-"] .choix-sub { color: var(--text-dim); }
body[class*="ambiance-"] .choix-label { color: var(--text-light); }

/* Footer */
body[class*="ambiance-"] .emergency-banner { background: var(--bg-card); border-color: var(--border); }
body[class*="ambiance-"] .emergency-banner p { color: var(--text-muted); }
body[class*="ambiance-"] .emergency-banner a { color: #d4a38f; }
body[class*="ambiance-"] .footer-link-visible { background: var(--bg-card); border-color: var(--border); color: var(--text-muted); }
body[class*="ambiance-"] .footer-link-visible:hover { background: var(--bg-active); }

/* Modales */
body[class*="ambiance-"] .modal-card { background: var(--bg-card); box-shadow: 0 8px 30px rgba(0,0,0,0.4); }
body[class*="ambiance-"] .modal-card h2,
body[class*="ambiance-"] .modal-card h3 { color: var(--text-light); }
body[class*="ambiance-"] .modal-card p { color: var(--text-muted); }
body[class*="ambiance-"] .manifeste-subtitle { color: var(--accent); }
body[class*="ambiance-"] .manifeste-point { color: var(--text-muted); border-left-color: var(--bg-active); }
body[class*="ambiance-"] .manifeste-closing { color: var(--text); }
body[class*="ambiance-"] .modal-close-btn { border-color: var(--border); color: var(--text-dim); }
body[class*="ambiance-"] .modal-close-btn:hover { border-color: var(--accent); color: var(--text-light); }
body[class*="ambiance-"] .ressources-list li { color: var(--text-muted); }
body[class*="ambiance-"] .ressources-list li strong { color: #d4a38f; }
body[class*="ambiance-"] .ressources-list a { color: var(--accent); }
body[class*="ambiance-"] .ressources-note { color: var(--text-dim); }

/* Profile / Mon Espace */
body[class*="ambiance-"] .profile-section-title { color: var(--text-light); }
body[class*="ambiance-"] .profile-content { color: var(--text-muted); }
body[class*="ambiance-"] .avatar-item { background: var(--bg-card); box-shadow: none; }
body[class*="ambiance-"] .avatar-item:hover { border-color: var(--accent); }
body[class*="ambiance-"] .avatar-item.selected { background: var(--bg-active); border-color: var(--accent); }
body[class*="ambiance-"] .quota-bar { background: var(--border); }
body[class*="ambiance-"] .quota-fill { background: linear-gradient(90deg, var(--accent), var(--bg-active)); }
body[class*="ambiance-"] .quota-text { color: var(--text-dim); }
body[class*="ambiance-"] .toggle-row { border-bottom-color: var(--border); }
body[class*="ambiance-"] .toggle-label { color: var(--text); }
body[class*="ambiance-"] .toggle-switch { background: var(--border); }
body[class*="ambiance-"] .toggle-input:checked + .toggle-switch { background: var(--accent); }
body[class*="ambiance-"] .plan-text { color: var(--text-muted); }
body[class*="ambiance-"] .rgpd-hint { color: var(--text-dim); }
body[class*="ambiance-"] .btn-danger-outline { border-color: #d45050; color: #d45050; }
body[class*="ambiance-"] .btn-danger-outline:hover { background: rgba(212,80,80,0.1); }
body[class*="ambiance-"] .btn-danger { background: #d45050; }
body[class*="ambiance-"] .btn-danger:hover { background: #c03030; }

/* Ambiance & Music items */
body[class*="ambiance-"] .ambiance-item { background: var(--bg-card); }
body[class*="ambiance-"] .ambiance-item:hover { border-color: var(--accent); }
body[class*="ambiance-"] .ambiance-item.selected { background: var(--bg-active); border-color: var(--accent); }
body[class*="ambiance-"] .ambiance-name { color: var(--text-dim); }
body[class*="ambiance-"] .music-item { background: var(--bg-card); border-color: var(--border); color: var(--text-muted); }
body[class*="ambiance-"] .music-item:hover { border-color: var(--accent); }
body[class*="ambiance-"] .music-item.playing { border-color: #d4a38f; background: rgba(212,163,143,0.1); }
body[class*="ambiance-"] .music-stop-btn { border-color: var(--border); color: var(--text-dim); }
body[class*="ambiance-"] .music-stop-btn:hover { border-color: var(--accent); color: var(--text); }

/* Crisis */
body[class*="ambiance-"] .crisis-card { background: var(--bg-card); }
body[class*="ambiance-"] .crisis-card h2 { color: var(--text-light); }
body[class*="ambiance-"] .crisis-card p { color: var(--text-muted); }
body[class*="ambiance-"] .crisis-contacts li { color: var(--text-muted); }
body[class*="ambiance-"] .crisis-contacts li strong { color: #d4a38f; }
body[class*="ambiance-"] .crisis-close-btn { background: #d4a38f; color: var(--bg); }
body[class*="ambiance-"] .crisis-dismiss-btn { border-color: var(--border); color: var(--text-dim); }
body[class*="ambiance-"] .crisis-dismiss-btn:hover { border-color: var(--accent); color: var(--text); }

/* Toast */
body[class*="ambiance-"] .toast.error { background: #d45050; }
body[class*="ambiance-"] .toast.success { background: var(--accent); color: var(--bg); }
body[class*="ambiance-"] .toast.warning { background: #d4a38f; color: var(--bg); }

/* Volume slider */
body[class*="ambiance-"] .volume-slider { background: var(--border); }
body[class*="ambiance-"] .volume-slider::-webkit-slider-thumb { background: var(--accent); }
body[class*="ambiance-"] .volume-slider::-moz-range-thumb { background: var(--accent); }
body[class*="ambiance-"] .volume-label { color: var(--text-muted); }

/* Relay local dark */
body[class*="ambiance-"] .relay-consent-btn { background: var(--bg-card); border-color: var(--accent); color: var(--text); }
body[class*="ambiance-"] .relay-consent-btn:hover { background: var(--accent); color: var(--bg); }
body[class*="ambiance-"] .relay-card { background: var(--bg-card); border-color: var(--border); }
body[class*="ambiance-"] .relay-name { color: var(--text-light); }
body[class*="ambiance-"] .relay-dist { color: var(--text-dim); }
body[class*="ambiance-"] .relay-phone { color: #d4a38f; }
body[class*="ambiance-"] .relay-hint { color: var(--text-dim); }
body[class*="ambiance-"] .relay-footer { color: var(--text-dim); }

/* ===== MUSIC CONTROLS ===== */
.music-item {
  padding: 10px 8px;
  border: 1.5px solid rgba(0,0,0,0.06);
  border-radius: 12px;
  background: white;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 200ms;
  text-align: center;
}
.music-item:hover { border-color: var(--sauge); transform: translateY(-1px); }
.music-item.playing { border-color: var(--terracotta-soft); background: #fef2f2; }

.music-stop-btn {
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: none;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: #888;
  cursor: pointer;
  transition: all 200ms;
}
.music-stop-btn:hover { border-color: var(--terracotta-soft); color: var(--gris-anthracite); }
.music-stop-btn.hidden { display: none; }

/* ===== VOLUME SLIDER ===== */
.volume-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 0 4px;
}
.volume-label {
  font-size: 0.82rem;
  flex-shrink: 0;
}
.volume-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #e4e8eb;
  border-radius: 4px;
  outline: none;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--sauge);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.volume-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--sauge);
  cursor: pointer;
  border: none;
}
body.ambiance-nuit .volume-slider { background: #2a2a4a; }
body.ambiance-nuit .volume-slider::-webkit-slider-thumb { background: #7ec8a0; }

/* ===== VOLUME SLIDER ===== */
.volume-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 0 4px;
}
.volume-label {
  font-size: 0.82rem;
  flex-shrink: 0;
}
.volume-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #e4e8eb;
  border-radius: 4px;
  outline: none;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--sauge);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.volume-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--sauge);
  cursor: pointer;
  border: none;
}

/* ===== ÉCRANS COURTS : centrage vertical ===== */
#screen1, #screen-login, #screen2 {
  justify-content: center;
}

/* ===== ÉCRANS LONGS : scroll depuis le haut ===== */
#screen3 {
  justify-content: flex-start;
  padding-top: 20px;
}

/* ===== AVATARS DANS LE CHAT ===== */
.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 92%;
  animation: messageAppear 600ms ease;
}
.msg-row.user {
  align-self: flex-end;
  flex-direction: row;
}
.msg-row.lien {
  align-self: flex-start;
  flex-direction: row;
}

.msg-avatar {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  border-radius: 50%;
  background: rgba(0,0,0,0.03);
  margin-top: 2px;
}

.msg-row .msg {
  max-width: 100%;
  align-self: auto;
}

body[class*="ambiance-"] .msg-avatar { background: rgba(255,255,255,0.06); }

/* ===== BULLE DE RESPIRATION ===== */
.breathing-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 110;
  animation: fadeIn 800ms ease;
}
.breathing-overlay.hidden { display: none; }

.breathing-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.breathing-circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, var(--sauge-lien), var(--sauge));
  display: flex;
  align-items: center;
  justify-content: center;
  animation: breatheCycle 19s ease-in-out infinite;
  box-shadow: 0 0 60px rgba(141,163,153,0.3);
}

.breathing-inner-text {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: white;
  text-shadow: 0 1px 8px rgba(0,0,0,0.2);
  animation: breatheLabel 10s ease-in-out infinite;
}

/* 4-7-8 : Inspire 4s (0%→21%) / Bloque 7s (21%→58%) / Expire 8s (58%→100%) = 19s */
@keyframes breatheCycle {
  0%   { transform: scale(0.5); opacity: 0.35; box-shadow: 0 0 40px rgba(141,163,153,0.15); }
  21%  { transform: scale(1.25); opacity: 1; box-shadow: 0 0 60px rgba(141,163,153,0.4); }
  22%  { transform: scale(1.25); opacity: 1; }
  57%  { transform: scale(1.22); opacity: 0.9; box-shadow: 0 0 70px rgba(141,163,153,0.25), inset 0 0 20px rgba(255,255,255,0.08); }
  58%  { transform: scale(1.22); opacity: 0.9; }
  100% { transform: scale(0.5); opacity: 0.35; box-shadow: 0 0 40px rgba(141,163,153,0.15); }
}

@keyframes breatheLabel {
  0%        { content: ""; }
  0%, 39%   { opacity: 1; }
  40%, 41%  { opacity: 0; }
  42%, 100% { opacity: 1; }
}

/* Le texte change via une astuce CSS : on utilise deux spans */
.breathing-circle .breathing-inner-text {
  animation: breatheTextSwap 10s ease-in-out infinite;
}

@keyframes breatheTextSwap {
  0%, 38%  { opacity: 1; }
  39%, 42% { opacity: 0; }
  43%, 100% { opacity: 1; }
}

.breathing-sub {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: rgba(255,255,255,0.45);
  margin: 0;
}

.breathing-close-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 50px;
  padding: 12px 36px;
  color: rgba(255,255,255,0.8);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 300ms;
  margin-top: 8px;
}
.breathing-close-btn:hover {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.5);
  color: white;
}

/* Thèmes */
body.ambiance-nuit .breathing-circle { background: radial-gradient(circle at 40% 40%, #0f3460, #7ec8a0); box-shadow: 0 0 60px rgba(126,200,160,0.2); }
body.ambiance-foret .breathing-circle { background: radial-gradient(circle at 40% 40%, #2d5016, #a8d48a); box-shadow: 0 0 60px rgba(168,212,138,0.2); }
body.ambiance-ocean .breathing-circle { background: radial-gradient(circle at 40% 40%, #145374, #6ec4e8); box-shadow: 0 0 60px rgba(110,196,232,0.2); }

/* ===== MOOD TRACKER ===== */
.mood-card {
  text-align: center;
}
.mood-choices {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 1.2rem 0;
}
.mood-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 10px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: rgba(0,0,0,0.02);
  cursor: pointer;
  transition: all 200ms;
  font-size: 1.6rem;
  min-width: 56px;
}
.mood-btn span {
  font-family: var(--font-sans);
  font-size: 0.65rem;
  color: #888;
}
.mood-btn:hover { border-color: var(--sauge); transform: translateY(-3px); }
.mood-btn.selected { border-color: var(--sauge); background: var(--sauge-lien); }

body[class*="ambiance-"] .mood-btn { background: rgba(255,255,255,0.04); }
body[class*="ambiance-"] .mood-btn span { color: var(--text-dim); }
body[class*="ambiance-"] .mood-btn:hover { border-color: var(--accent); }
body[class*="ambiance-"] .mood-btn.selected { border-color: var(--accent); background: var(--bg-active); }

/* ===== MOOD CHART (Courbe SVG) ===== */
.mood-chart {
  width: 100%;
  min-height: 80px;
}
.mood-empty {
  font-size: 0.82rem;
  color: #aaa;
  text-align: center;
  font-style: italic;
}
.mood-svg {
  width: 100%;
  height: auto;
}
.mood-line {
  animation: drawLine 1s ease forwards;
}
@keyframes drawLine {
  from { stroke-dasharray: 1000; stroke-dashoffset: 1000; }
  to { stroke-dasharray: 1000; stroke-dashoffset: 0; }
}
.mood-point-emoji {
  font-size: 12px;
}
.mood-day-label {
  font-family: var(--font-sans);
  font-size: 8px;
  fill: #aaa;
}

body[class*="ambiance-"] .mood-svg .mood-day-label { fill: var(--text-dim); }
body[class*="ambiance-"] .mood-svg circle { stroke: var(--bg-card); }
body[class*="ambiance-"] .mood-empty { color: var(--text-dim); }

/* ===== RELAIS LOCAL — Mon Espace ===== */
.relay-profile-btn {
  width: 100%;
  padding: 14px;
  border: 1.5px solid var(--sauge);
  border-radius: 14px;
  background: var(--sauge-lien);
  color: var(--gris-anthracite);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 200ms;
  margin-bottom: 6px;
}
.relay-profile-btn:hover { background: var(--sauge); color: white; transform: translateY(-1px); }
.relay-profile-btn:disabled { opacity: 0.6; cursor: wait; transform: none; }

.relay-card-profile {
  background: white;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.relay-actions {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}
.relay-directions {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--sauge);
  font-weight: 600;
  text-decoration: none;
}
.relay-directions:hover { text-decoration: underline; }

body[class*="ambiance-"] .relay-profile-btn { background: var(--bg-card); border-color: var(--accent); color: var(--text); }
body[class*="ambiance-"] .relay-profile-btn:hover { background: var(--accent); color: var(--bg); }
body[class*="ambiance-"] .relay-card-profile { background: var(--bg-card); border-color: var(--border); }
body[class*="ambiance-"] .relay-directions { color: var(--accent); }

/* ===== MOT DE PASSE OUBLIÉ ===== */
.forgot-link {
  background: none;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--sauge);
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  transition: opacity 200ms;
}
.forgot-link:hover { opacity: 0.7; }

.forgot-success {
  font-size: 0.85rem;
  color: var(--sauge);
  text-align: center;
  margin-top: 8px;
  animation: fadeIn 400ms ease;
}
.forgot-success.hidden { display: none; }

body[class*="ambiance-"] .forgot-link { color: var(--accent); }
body[class*="ambiance-"] .forgot-success { color: var(--accent); }

/* ===== CHOIX VOIX HOMME/FEMME ===== */
.voice-gender-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}
.voice-gender-row.hidden { display: none; }

.voice-gender-btns {
  display: flex;
  gap: 6px;
}
.voice-gender-btn {
  padding: 6px 14px;
  border: 1.5px solid rgba(0,0,0,0.08);
  border-radius: 10px;
  background: white;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 200ms;
}
.voice-gender-btn:hover { border-color: var(--sauge); }
.voice-gender-btn.selected { border-color: var(--sauge); background: var(--sauge-lien); font-weight: 600; }

body[class*="ambiance-"] .voice-gender-btn { background: var(--bg-card); border-color: var(--border); color: var(--text-muted); }
body[class*="ambiance-"] .voice-gender-btn:hover { border-color: var(--accent); }
body[class*="ambiance-"] .voice-gender-btn.selected { background: var(--bg-active); border-color: var(--accent); color: var(--text-light); }

/* ===== TUTORIAL CARD ===== */
.tuto-card {
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 2rem 1.8rem 2.4rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
  position: relative;
  animation: slideUp 400ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
/* Positionner la modale en bas */
#soft-onboarding { align-items: flex-end; }

.tuto-close {
  position: absolute;
  top: 14px; right: 16px;
  background: rgba(0,0,0,0.05);
  border: none;
  border-radius: 50%;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; color: #888;
  cursor: pointer;
  transition: background 200ms;
}
.tuto-close:hover { background: rgba(0,0,0,0.1); }

.tuto-icon {
  display: block;
  font-size: 2.2rem;
  margin-bottom: 0.6rem;
}
.tuto-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gris-anthracite);
  margin-bottom: 0.6rem;
  line-height: 1.3;
}
.tuto-desc {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  line-height: 1.65;
  color: #666;
  margin-bottom: 1.4rem;
}
.tuto-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-bottom: 1.4rem;
}
.tuto-dot {
  height: 6px; width: 6px;
  border-radius: 3px;
  background: #e0e0e0;
  transition: all 300ms ease;
}
.tuto-dot.active {
  width: 22px;
  background: var(--sauge);
}
.tuto-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tuto-skip {
  background: none; border: none;
  font-family: var(--font-sans);
  font-size: 0.82rem; color: #aaa;
  cursor: pointer; padding: 6px;
  transition: color 200ms;
}
.tuto-skip:hover { color: #666; }

/* Thèmes sombres */
body[class*="ambiance-"] .tuto-card { background: var(--bg-card); }
body[class*="ambiance-"] .tuto-title { color: var(--text-light); }
body[class*="ambiance-"] .tuto-desc { color: var(--text-muted); }
body[class*="ambiance-"] .tuto-dot { background: var(--border); }
body[class*="ambiance-"] .tuto-dot.active { background: var(--accent); }
body[class*="ambiance-"] .tuto-skip { color: var(--text-dim); }

/* ===== DESCRIPTIONS MODULES ===== */
.choix-desc {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  color: #999;
  margin-top: 4px;
  line-height: 1.4;
}
body[class*="ambiance-"] .choix-desc { color: var(--text-dim); }

/* ===== BOUTON DECONNEXION ===== */
.btn-logout {
  width: 100%;
  padding: 12px;
  border: 1.5px solid #aaa;
  border-radius: 12px;
  background: none;
  color: #888;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 200ms;
}
.btn-logout:hover { border-color: var(--gris-anthracite); color: var(--gris-anthracite); }
body[class*="ambiance-"] .btn-logout { border-color: var(--border); color: var(--text-dim); }
body[class*="ambiance-"] .btn-logout:hover { border-color: var(--text-muted); color: var(--text); }

/* ===== BOUTON EXPORT PDF ===== */
.btn-export {
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--sauge);
  border-radius: 12px;
  background: var(--sauge-lien);
  color: var(--gris-anthracite);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 200ms;
  margin-bottom: 4px;
}
.btn-export:hover { background: var(--sauge); color: white; transform: translateY(-1px); }
body[class*="ambiance-"] .btn-export { background: var(--bg-card); border-color: var(--accent); color: var(--text); }
body[class*="ambiance-"] .btn-export:hover { background: var(--accent); color: var(--bg); }

/* ===== INSIGHTS HEBDOMADAIRES ===== */
.weekly-insights {
  margin-top: 12px;
}
.insights-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.insight-item {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--gris-anthracite);
  background: white;
  padding: 10px 14px;
  border-radius: 12px;
  border-left: 3px solid var(--sauge);
  line-height: 1.5;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}
body[class*="ambiance-"] .insight-item {
  background: var(--bg-card);
  color: var(--text);
  border-left-color: var(--accent);
  box-shadow: none;
}

/* ===== MODALE EXPORT PDF ===== */
.export-hint {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: #888;
  line-height: 1.6;
  margin-bottom: 12px;
}
.export-textarea {
  width: 100%;
  min-height: 200px;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  padding: 14px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--gris-anthracite);
  resize: vertical;
  outline: none;
}
.export-textarea:focus { border-color: var(--sauge); }
.export-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
body[class*="ambiance-"] .export-hint { color: var(--text-dim); }
body[class*="ambiance-"] .export-textarea { background: var(--bg); border-color: var(--border); color: var(--text); }
body[class*="ambiance-"] .export-textarea:focus { border-color: var(--accent); }

/* ===== SELECTEUR LANGUE ===== */
.lang-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: white;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  transition: all 200ms;
  z-index: 10;
}
.lang-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.08); }

.lang-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 1rem 0;
}
.lang-item {
  padding: 12px;
  border: 1.5px solid rgba(0,0,0,0.06);
  border-radius: 12px;
  background: white;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 200ms;
  text-align: center;
}
.lang-item:hover { border-color: var(--sauge); transform: translateY(-1px); }

body[class*="ambiance-"] .lang-btn { background: var(--bg-card); border-color: var(--border); }
body[class*="ambiance-"] .lang-item { background: var(--bg-card); border-color: var(--border); color: var(--text); }
body[class*="ambiance-"] .lang-item:hover { border-color: var(--accent); }

/* ===== SOS BUTTON ===== */
.sos-header-btn { color: #d45050 !important; }
.sos-header-btn:hover { background: rgba(212,80,80,0.08) !important; }
.sos-card h2 { color: #d45050; }

/* ===== SOS COUNTRY SELECTOR ===== */
.sos-country-selector {
  margin-bottom: 12px;
}
.sos-country-label {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: #888;
  display: block;
  margin-bottom: 6px;
}
.sos-country-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  color: var(--gris-anthracite);
  background: white;
  outline: none;
}
.sos-country-select:focus { border-color: var(--sauge); }
body[class*="ambiance-"] .sos-country-select { background: var(--bg); border-color: var(--border); color: var(--text); }
body[class*="ambiance-"] .sos-country-label { color: var(--text-dim); }

/* ===== RESPONSIVE MOBILE ===== */
@media (max-width: 420px) {
  .app-container { padding: 16px; }
  .header-action-btn { padding: 3px 4px; min-width: 32px; }
  .header-action-label { font-size: 0.5rem; }
  .header-title { font-size: 0.85rem; }
  .header-logo { width: 20px; height: 20px; }
  .chat-header { gap: 0.3rem; padding: 0.5rem 0; }
  .send-btn { width: 38px; height: 38px; }
  .msg { padding: 0.7rem 0.9rem; font-size: 0.88rem; }
  .msg-avatar { width: 24px; height: 24px; font-size: 0.8rem; }
  .btn-choix { padding: 14px 16px; }
  .choix-label { font-size: 0.95rem; }
  .choix-desc { font-size: 0.68rem; }
  .lang-btn { width: 32px; height: 32px; font-size: 0.95rem; top: 8px; right: 8px; }
  h1 { font-size: 1.5rem; }
}

/* ===== LANGUE PROFILE BTN ===== */
.lang-profile-btn {
  padding: 6px 14px;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 10px;
  background: white;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 200ms;
  color: var(--sauge);
  font-weight: 600;
}
.lang-profile-btn:hover { border-color: var(--sauge); }
body[class*="ambiance-"] .lang-profile-btn { background: var(--bg-card); border-color: var(--border); color: var(--accent); }

/* ===== JOURNAL INTIME ===== */
.journal-textarea {
  width: 100%;
  min-height: 120px;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  padding: 14px;
  font-family: var(--font-serif);
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--gris-anthracite);
  resize: vertical;
  outline: none;
  background: white;
}
.journal-textarea:focus { border-color: var(--sauge); }
.journal-textarea::placeholder { color: #bbb; font-style: italic; }
.journal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}
.journal-status {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  color: var(--sauge);
}
.journal-clear-btn {
  background: none;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: #d45050;
  cursor: pointer;
  text-decoration: underline;
}
.journal-clear-btn:hover { opacity: 0.7; }
body[class*="ambiance-"] .journal-textarea { background: var(--bg); border-color: var(--border); color: var(--text); }
body[class*="ambiance-"] .journal-textarea:focus { border-color: var(--accent); }
body[class*="ambiance-"] .journal-textarea::placeholder { color: var(--text-dim); }
body[class*="ambiance-"] .journal-status { color: var(--accent); }

/* ===== MON COCON (Journal) ===== */
#screen-journal {
  text-align: left;
  justify-content: flex-start;
}
.journal-container {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1rem 0;
  width: 100%;
}
.journal-new-entry {
  margin-bottom: 16px;
}
.journal-date-now {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--sauge);
  font-weight: 600;
  margin-bottom: 8px;
}
.journal-input {
  width: 100%;
  min-height: 100px;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  padding: 14px;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--gris-anthracite);
  resize: vertical;
  outline: none;
  background: white;
}
.journal-input:focus { border-color: var(--sauge); }
.journal-input::placeholder { color: #bbb; font-style: italic; }
.journal-divider {
  height: 1px;
  background: rgba(0,0,0,0.06);
  margin: 16px 0;
}
.journal-entries {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.journal-empty {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: #aaa;
  text-align: center;
  font-style: italic;
  padding: 20px 0;
}
.journal-entry {
  background: white;
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
  position: relative;
}
.journal-entry-date {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--sauge);
  font-weight: 600;
  margin-bottom: 6px;
}
.journal-entry-text {
  font-family: var(--font-serif);
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--gris-anthracite);
}
.journal-delete-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  font-size: 0.8rem;
  cursor: pointer;
  opacity: 0.3;
  transition: opacity 200ms;
}
.journal-delete-btn:hover { opacity: 1; }
.btn-choix-journal {
  border: 1.5px dashed var(--sauge);
  background: rgba(141,163,153,0.04);
}
body[class*="ambiance-"] .journal-input { background: var(--bg-card); border-color: var(--border); color: var(--text); }
body[class*="ambiance-"] .journal-input:focus { border-color: var(--accent); }
body[class*="ambiance-"] .journal-entry { background: var(--bg-card); box-shadow: none; }
body[class*="ambiance-"] .journal-entry-date { color: var(--accent); }
body[class*="ambiance-"] .journal-entry-text { color: var(--text); }
body[class*="ambiance-"] .journal-empty { color: var(--text-dim); }
body[class*="ambiance-"] .journal-date-now { color: var(--accent); }
body[class*="ambiance-"] .journal-divider { background: var(--border); }
body[class*="ambiance-"] .btn-choix-journal { border-color: var(--accent); background: rgba(255,255,255,0.02); }

/* ===== MODALE RESUME SEANCE ===== */
.summary-card { text-align: center; }
.summary-text {
  font-family: var(--font-serif);
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--gris-anthracite);
  background: rgba(141,163,153,0.08);
  border-radius: 12px;
  padding: 16px;
  margin: 16px 0;
  text-align: left;
}
.summary-module-msg {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--sauge);
  font-style: italic;
  margin-bottom: 16px;
}
body[class*="ambiance-"] .summary-text { background: rgba(255,255,255,0.05); color: var(--text); }
body[class*="ambiance-"] .summary-module-msg { color: var(--accent); }

/* ===== MOOD TREND MESSAGE ===== */
.mood-trend-msg {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--sauge);
  text-align: center;
  margin-top: 8px;
  font-style: italic;
  min-height: 1.2em;
}
body[class*="ambiance-"] .mood-trend-msg { color: var(--accent); }

/* ===== LOGO IMAGES ===== */
.logo-img { display: block; margin: 0 auto; width: clamp(120px, 18vw, 180px); height: auto; color: var(--sauge); }
.logo-img-mini { display: block; margin: 0 auto; width: 56px; height: auto; color: var(--sauge); }
.header-logo-img { flex-shrink: 0; height: 24px; width: auto; color: var(--sauge); }
body[class*="ambiance-"] .logo-img,
body[class*="ambiance-"] .logo-img-mini,
body[class*="ambiance-"] .header-logo-img { color: var(--accent); }
body[class*="ambiance-"] .logo-img,
body[class*="ambiance-"] .logo-img-mini,
body[class*="ambiance-"] .header-logo-img { background: transparent; }

/* =============================================
   FOOTER T.E.Y.L.A STUDIO
   ============================================= */
#teyla-footer {
  width: 100%;
  text-align: center;
  font-family: 'Lato', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: rgba(0, 0, 0, 0.25);
  padding: 10px 0 14px;
  background: transparent;
  pointer-events: none;
  user-select: none;
}
body[class*="ambiance-"] #teyla-footer {
  color: rgba(255, 255, 255, 0.35);
}
