/* Nox : bordeaux et noir, à la manière d'iOS. Le mode sombre suit celui du téléphone. */
:root {
  --fond: #f2f2f7;
  --fond-chat: #ffffff;
  --surface: #ffffff;
  --surface-2: #e9e9eb;
  --surface-3: #f2f2f7;
  --accent: #a3294f;
  --accent-fonce: #7a1f3d;
  --accent-doux: rgba(163, 41, 79, 0.12);
  --rouge: #ff3b30;
  --vert: #34c759;
  --texte: #000000;
  --texte-2: rgba(60, 60, 67, 0.6);
  --texte-3: rgba(60, 60, 67, 0.3);
  --separateur: rgba(60, 60, 67, 0.18);
  --verre: rgba(249, 249, 249, 0.78);
  --ombre-douce: 0 1px 1px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.06);
  --ombre-haute: 0 20px 60px rgba(0, 0, 0, 0.25), 0 4px 14px rgba(0, 0, 0, 0.12);
  --ressort: cubic-bezier(0.34, 1.45, 0.64, 1);
  --ios: cubic-bezier(0.32, 0.72, 0, 1);
  --police: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, Roboto, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #000000;
    --fond-chat: #000000;
    --surface: #1c1c1e;
    --surface-2: #262628;
    --surface-3: #2c2c2e;
    --accent: #c43a66;
    --accent-fonce: #7a1f3d;
    --accent-doux: rgba(196, 58, 102, 0.18);
    --rouge: #ff453a;
    --vert: #30d158;
    --texte: #ffffff;
    --texte-2: rgba(235, 235, 245, 0.6);
    --texte-3: rgba(235, 235, 245, 0.3);
    --separateur: rgba(84, 84, 88, 0.6);
    --verre: rgba(22, 22, 24, 0.72);
    --ombre-douce: 0 1px 1px rgba(0, 0, 0, 0.4);
    --ombre-haute: 0 24px 70px rgba(0, 0, 0, 0.7), 0 4px 14px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--fond-chat);
  color: var(--texte);
  font: 17px/1.35 var(--police);
  letter-spacing: -0.2px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

/* Une aurore bordeaux, lente, derrière tout (mode sombre surtout) */
.aurore { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; opacity: 0.55; }
.aurore span {
  position: absolute;
  width: 140vmax;
  height: 140vmax;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(196, 58, 102, 0.22), transparent 70%);
  animation: derive 26s ease-in-out infinite alternate;
}
.aurore span:last-child {
  right: -60vmax;
  bottom: -70vmax;
  background: radial-gradient(closest-side, rgba(122, 31, 61, 0.28), transparent 70%);
  animation-duration: 34s;
  animation-direction: alternate-reverse;
}
.aurore span:first-child { left: -70vmax; top: -80vmax; }
@media (prefers-color-scheme: light) { .aurore { opacity: 0.35; } }

/* --- L'en-tête, translucide comme dans Messages --------------------------------- */
.entete {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: calc(env(safe-area-inset-top) + 6px) 8px 8px;
  background: var(--verre);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-bottom: 0.5px solid var(--separateur);
}
.entete-gauche { justify-self: start; }
.entete-droite { justify-self: end; display: flex; gap: 2px; }
.identite {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 2px 10px;
  color: var(--texte);
  background: none;
  border: 0;
  border-radius: 14px;
  transition: transform 0.25s var(--ressort);
}
.identite:active { transform: scale(0.94); }
.avatar {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 0.5px var(--separateur), 0 4px 14px rgba(163, 41, 79, 0.35);
}
.avatar img { width: 100%; height: 100%; display: block; }
.avatar::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 70%, rgba(255, 255, 255, 0.55) 80%, transparent 90%);
  mix-blend-mode: overlay;
  animation: tourne 6s linear infinite;
  opacity: 0;
  transition: opacity 0.4s;
}
body.reflexion .avatar::after { opacity: 1; animation-duration: 1.4s; }
.nom { display: flex; align-items: center; font-size: 13px; font-weight: 600; }
.nom svg { width: 12px; height: 12px; margin-left: 1px; fill: none; stroke: var(--texte-3); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.etat { font-size: 11px; color: var(--texte-2); display: flex; align-items: center; gap: 4px; }
.etat::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--vert); transition: background 0.3s; }
.etat.reflechit::before { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.etat.hors-ligne::before { background: var(--texte-3); }
.etat.arrete::before { background: var(--rouge); }
.etat.arrete { color: var(--rouge); }

.icone-bouton {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: transparent;
  border: 0;
  border-radius: 50%;
  transition: transform 0.25s var(--ressort), background 0.2s;
}
.icone-bouton:active { transform: scale(0.86); background: var(--accent-doux); }
.icone-bouton svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icone-bouton.petit { width: 30px; height: 30px; }
.icone-bouton.petit svg { width: 18px; height: 18px; }
.entete-droite .icone-bouton svg circle { fill: currentColor; stroke: none; }

.texte-bouton {
  padding: 8px 10px;
  font-size: 17px;
  color: var(--accent);
  background: none;
  border: 0;
  border-radius: 10px;
  transition: opacity 0.15s, transform 0.25s var(--ressort);
}
.texte-bouton:active { opacity: 0.4; transform: scale(0.96); }
.texte-bouton.gras { font-weight: 600; }
.texte-bouton.danger { color: var(--rouge); }

/* --- Le fil ---------------------------------------------------------------------- */
.chat { position: relative; z-index: 1; flex: 1; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.fil { list-style: none; margin: 0 auto; padding: 14px 12px 10px; max-width: 760px; display: flex; flex-direction: column; }
.jour {
  align-self: center;
  margin: 18px 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--texte-2);
  animation: fondu 0.4s ease-out;
}
.bulle {
  position: relative;
  max-width: 78%;
  margin-top: 2px;
  padding: 8px 13px 7px;
  font-size: 17px;
  line-height: 1.32;
  border-radius: 19px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.35s var(--ressort), opacity 0.2s, filter 0.2s;
}
.bulle.nouvelle.nox { animation: arrive-gauche 0.55s var(--ressort) both; }
.bulle.nouvelle.morty { animation: arrive-droite 0.5s var(--ressort) both; }
.bulle.debut-groupe { margin-top: 10px; }
.bulle .corps { display: block; }
.bulle .heure { display: block; margin-top: 2px; font-size: 11px; text-align: right; opacity: 0.55; letter-spacing: 0; }
.bulle.nox { align-self: flex-start; color: var(--texte); background: var(--surface-2); }
.bulle.morty {
  align-self: flex-end;
  color: #fff;
  background: linear-gradient(160deg, #c43a66 0%, #a3294f 45%, #7a1f3d 100%);
  background-attachment: fixed;
}
/* La petite queue des bulles, sur le dernier message d'un groupe */
.bulle.fin-groupe.nox { border-bottom-left-radius: 4px; }
.bulle.fin-groupe.morty { border-bottom-right-radius: 4px; }
.bulle.erreur { align-self: center; max-width: 90%; margin: 8px 0; padding: 4px 10px; font-size: 13px; color: var(--rouge); background: transparent; }
.bulle.appuyee { transform: scale(0.96); }
.bulle.cachee { opacity: 0; }

/* Nox qui écrit */
.bulle.ecrit { display: flex; gap: 4px; margin-top: 10px; padding: 13px 15px; animation: arrive-gauche 0.45s var(--ressort) both, respire 2s ease-in-out 0.45s infinite; }
.bulle.ecrit span { width: 8px; height: 8px; border-radius: 50%; background: var(--texte-2); animation: vague 1.3s infinite ease-in-out; }
.bulle.ecrit span:nth-child(2) { animation-delay: 0.16s; }
.bulle.ecrit span:nth-child(3) { animation-delay: 0.32s; }

/* Citation dans une bulle */
.cite {
  display: block;
  margin: 1px 0 6px;
  padding: 5px 9px;
  font-size: 14px;
  line-height: 1.3;
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: rgba(127, 127, 127, 0.14);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.cite b { display: block; font-size: 12px; }
.bulle.morty .cite { border-left-color: rgba(255, 255, 255, 0.85); background: rgba(0, 0, 0, 0.18); }

/* Les cartes : boutons sous le message */
.boutons { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 3px; }
.boutons button {
  flex: 1 1 auto;
  min-height: 38px;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(160deg, #c43a66, #7a1f3d);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(163, 41, 79, 0.3);
  transition: transform 0.3s var(--ressort), opacity 0.2s;
}
.boutons button:active { transform: scale(0.93); }
.boutons button.discret { color: var(--texte); background: var(--surface); box-shadow: 0 0 0 0.5px var(--separateur); }
.boutons button:disabled { opacity: 0.4; }
.resultat {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 7px;
  font-size: 14px;
  color: var(--texte-2);
  border-top: 0.5px solid var(--separateur);
  animation: fondu 0.35s ease-out;
}
.resultat::before {
  content: "✓";
  flex: none;
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  border-radius: 50%;
  background: var(--vert);
  animation: coche 0.5s var(--ressort);
}

/* --- La saisie ------------------------------------------------------------------- */
.saisie {
  position: relative;
  z-index: 3;
  padding: 7px 10px calc(env(safe-area-inset-bottom) + 8px);
  background: var(--verre);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-top: 0.5px solid var(--separateur);
}
.composeur { display: flex; align-items: flex-end; gap: 8px; max-width: 760px; margin: 0 auto; }
.champ {
  flex: 1;
  display: flex;
  align-items: flex-end;
  min-height: 38px;
  padding: 3px 3px 3px 14px;
  background: var(--fond-chat);
  border: 0.5px solid var(--texte-3);
  border-radius: 20px;
  transition: border-color 0.2s, box-shadow 0.3s;
}
.champ:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-doux); }
.champ textarea {
  flex: 1;
  min-height: 30px;
  max-height: 150px;
  padding: 5px 4px 5px 0;
  resize: none;
  font: 17px/1.3 var(--police);
  color: var(--texte);
  background: transparent;
  border: 0;
  outline: none;
}
.champ textarea::placeholder { color: var(--texte-3); }
.envoyer {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  margin: 1px;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 50%;
  transform: scale(1);
  transition: transform 0.35s var(--ressort), opacity 0.2s;
}
.envoyer svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.envoyer:disabled { transform: scale(0); opacity: 0; }
.envoyer:active { transform: scale(0.85); }
.micro {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: transparent;
  border: 0;
  border-radius: 50%;
  animation: pop 0.4s var(--ressort);
  transition: transform 0.3s var(--ressort), background 0.2s;
}
.micro svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.micro:active { transform: scale(0.85); background: var(--accent-doux); }

/* Répondre à un message */
.citation {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 760px;
  margin: 0 auto 7px;
  padding: 6px 6px 6px 12px;
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  animation: monte 0.4s var(--ressort);
}
.citation-texte { flex: 1; min-width: 0; font-size: 14px; }
.citation-texte b { display: block; font-size: 13px; color: var(--accent); }
.citation-texte span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--texte-2); }

/* Le vocal en cours : l'onde en direct */
.enregistrement { display: flex; align-items: center; gap: 8px; max-width: 760px; margin: 0 auto; animation: fondu 0.25s ease-out; }
.annuler-vocal { color: var(--rouge); }
.onde {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  background: var(--fond-chat);
  border: 0.5px solid var(--texte-3);
  border-radius: 20px;
}
.onde canvas { flex: 1; min-width: 0; height: 30px; }
.chrono { font: 600 15px/1 var(--police); font-variant-numeric: tabular-nums; }
.envoyer.pret { width: 34px; height: 34px; }
.point.rouge { width: 9px; height: 9px; border-radius: 50%; background: var(--rouge); animation: pulse 1s ease-in-out infinite; }

/* --- L'appui long : le message se soulève ------------------------------------------ */
.contexte { position: fixed; inset: 0; z-index: 8; }
.contexte-fond {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  animation: fondu 0.3s ease-out;
}
.contexte.part .contexte-fond { animation: fondu-inverse 0.25s ease-in forwards; }
.contexte-scene { position: absolute; left: 0; right: 0; display: flex; flex-direction: column; padding: 0 12px; }
.contexte-scene.morty { align-items: flex-end; }
.contexte-scene.nox { align-items: flex-start; }
.contexte-bulle .bulle { max-width: 82vw; box-shadow: var(--ombre-haute); animation: souleve 0.45s var(--ressort) both; }
.contexte.part .contexte-bulle .bulle { animation: pose 0.25s var(--ios) forwards; }
.reactions {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  padding: 6px;
  background: var(--surface);
  border-radius: 999px;
  box-shadow: var(--ombre-haute);
  animation: pop 0.45s var(--ressort) 0.04s both;
}
.reactions button {
  width: 44px;
  height: 44px;
  font-size: 24px;
  background: transparent;
  border: 0;
  border-radius: 50%;
  transition: transform 0.3s var(--ressort), background 0.2s;
}
.reactions button:active, .reactions button.choisie { transform: scale(1.25); background: var(--accent-doux); }
.contexte-actions {
  list-style: none;
  width: 250px;
  margin: 10px 0 0;
  padding: 0;
  overflow: hidden;
  background: var(--verre);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-radius: 14px;
  box-shadow: var(--ombre-haute);
  transform-origin: top center;
  animation: deplie 0.45s var(--ressort) 0.05s both;
}
.contexte.part .contexte-actions, .contexte.part .reactions { animation: replie 0.2s ease-in forwards; }
.contexte-actions li + li { border-top: 0.5px solid var(--separateur); }
.contexte-actions button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 17px;
  color: var(--texte);
  background: transparent;
  border: 0;
  text-align: left;
}
.contexte-actions button:active { background: var(--separateur); }
.contexte-actions button.danger { color: var(--rouge); }
.contexte-actions svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* Plusieurs messages choisis */
.bulle.choisissable { transition: transform 0.35s var(--ressort); }
.fil.selection .bulle.choisissable { transform: translateX(34px); }
.fil.selection .bulle.choisissable::before {
  content: "";
  position: absolute;
  left: -32px;
  top: 50%;
  width: 22px;
  height: 22px;
  margin-top: -11px;
  border: 1.5px solid var(--texte-3);
  border-radius: 50%;
  animation: pop 0.35s var(--ressort);
}
.fil.selection .bulle.morty.choisissable { transform: none; }
.fil.selection .bulle.morty.choisissable::before { left: auto; right: calc(100% + 10px); }
.fil.selection .bulle.choisie::before {
  content: "✓";
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}
.barre-selection {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(env(safe-area-inset-top) + 10px) 8px 10px;
  background: var(--verre);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-bottom: 0.5px solid var(--separateur);
  animation: descend 0.4s var(--ressort);
}
#nombre-choisis { flex: 1; text-align: center; font-weight: 600; }

/* --- Le menu : une feuille qui monte du bas ---------------------------------------- */
.feuille-cadre { position: fixed; inset: 0; z-index: 7; }
.feuille-fond { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.4); animation: fondu 0.35s ease-out; transition: opacity 0.3s; }
.feuille {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(100% - env(safe-area-inset-top) - 18px);
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--fond);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
  animation: feuille-monte 0.55s var(--ios);
  will-change: transform;
}
.feuille.part { transition: transform 0.32s var(--ios); transform: translateY(105%); }
.feuille-cadre.part .feuille-fond { opacity: 0; }
.poignee { display: grid; place-items: center; height: 22px; flex: none; touch-action: none; cursor: grab; }
.poignee span { width: 36px; height: 5px; border-radius: 3px; background: var(--texte-3); }
.pages { position: relative; flex: 1; overflow: hidden; }
.page {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 0 16px calc(env(safe-area-inset-bottom) + 30px);
  background: var(--fond);
  transition: transform 0.5s var(--ios), filter 0.4s, box-shadow 0.5s;
}
/* Comme sur iPhone : la page suivante glisse par-dessus, la précédente recule et s'assombrit. */
.page + .page { box-shadow: -12px 0 30px rgba(0, 0, 0, 0.25); }
.page.derriere { transform: translateX(-30%); filter: brightness(0.6); pointer-events: none; }
.page.devant-hors { transform: translateX(100%); box-shadow: none; }
.page-entete {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin: 0 -16px;
  padding: 4px 8px 10px;
  background: var(--fond);
}
.page-entete h2 { margin: 0; font-size: 17px; font-weight: 600; }
.page-entete > :last-child { justify-self: end; }
.retour { display: flex; align-items: center; padding-left: 0; }
.retour svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.liste { list-style: none; margin: 20px 0 0; padding: 0; overflow: hidden; background: var(--surface); border-radius: 12px; }
.liste > li + li .cellule, .liste > li + li.cellule { border-top: 0.5px solid var(--separateur); }
.cellule {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  font-size: 17px;
  text-align: left;
  color: var(--texte);
  background: transparent;
  border: 0;
  transition: background 0.2s;
}
button.cellule:active { background: var(--separateur); }
.cellule-texte { flex: 1; display: flex; flex-direction: column; }
.cellule-texte small { font-size: 13px; color: var(--texte-2); }
.chevron { width: 9px; height: 9px; margin-right: 4px; border-right: 2px solid var(--texte-3); border-top: 2px solid var(--texte-3); transform: rotate(45deg); }
.pastille { flex: none; width: 29px; height: 29px; display: grid; place-items: center; border-radius: 7px; color: #fff; }
.pastille svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.pastille.rouge { background: var(--rouge); }
.pastille.verte { background: var(--vert); }
.pastille.orange { background: #ff9500; }
.pastille.vert-wa { background: #25d366; }
.pastille.bleue { background: #007aff; }
.pastille.violette { background: #af52de; }
.note { margin: 7px 16px 0; font-size: 13px; color: var(--texte-2); }

/* L'interrupteur, comme sur iPhone */
.interrupteur { position: relative; flex: none; width: 51px; height: 31px; }
.interrupteur input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; z-index: 1; cursor: pointer; }
.interrupteur span { position: absolute; inset: 0; border-radius: 999px; background: var(--texte-3); transition: background 0.3s; }
.interrupteur span::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16);
  transition: transform 0.35s var(--ressort), width 0.2s;
}
.interrupteur input:checked + span { background: var(--vert); }
.interrupteur input:checked + span::after { transform: translateX(20px); }
.interrupteur input:active + span::after { width: 32px; }
.interrupteur input:checked:active + span::after { transform: translateX(15px); }

/* Les panneaux */
.contenu-panneau { display: flex; flex-direction: column; gap: 16px; padding-top: 8px; }
.texte-panneau {
  margin: 0;
  padding: 14px 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 16px;
  background: var(--surface);
  border-radius: 12px;
  animation: monte 0.45s var(--ressort);
}
.jauge { padding: 14px 16px; background: var(--surface); border-radius: 12px; animation: monte 0.45s var(--ressort) both; }
.jauge + .jauge { animation-delay: 0.06s; }
.jauge p { margin: 0 0 9px; font-weight: 600; display: flex; justify-content: space-between; }
.jauge p small { font-weight: 400; color: var(--texte-2); }
.jauge-fond { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.jauge-plein { height: 100%; width: 0; background: linear-gradient(90deg, #c43a66, #7a1f3d); border-radius: 999px; transition: width 1.1s var(--ios) 0.15s; }
.jauge-plein.haute { background: linear-gradient(90deg, #ff9500, var(--rouge)); }
.chargement { height: 60px; border-radius: 12px; background: linear-gradient(90deg, var(--surface) 25%, var(--surface-3) 50%, var(--surface) 75%); background-size: 200% 100%; animation: miroite 1.2s linear infinite; }
.champ-ligne { display: flex; gap: 8px; padding: 10px 16px; }
.champ-ligne input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  font: 600 20px/1.2 var(--police);
  letter-spacing: 4px;
  font-variant-numeric: tabular-nums;
  color: var(--texte);
  background: var(--surface-3);
  border: 0;
  border-radius: 10px;
  outline: none;
}
.bouton-plein {
  padding: 11px 18px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(160deg, #c43a66, #7a1f3d);
  border: 0;
  border-radius: 12px;
  transition: transform 0.3s var(--ressort), opacity 0.2s;
}
.bouton-plein:active { transform: scale(0.95); }
.bouton-plein.danger { background: var(--rouge); }

/* --- Relier cet appareil --------------------------------------------------------- */
.liaison { position: relative; z-index: 1; flex: 1; display: grid; place-items: center; padding: 24px 20px; }
.carte-liaison { width: 100%; max-width: 380px; text-align: center; animation: monte 0.7s var(--ressort); }
.halo { position: relative; width: 96px; height: 96px; margin: 0 auto; }
.halo img { position: relative; width: 96px; height: 96px; border-radius: 26px; box-shadow: 0 10px 40px rgba(163, 41, 79, 0.45); }
.halo::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 34px;
  background: conic-gradient(from 0deg, #c43a66, transparent 40%, #7a1f3d 60%, transparent 90%, #c43a66);
  filter: blur(12px);
  animation: tourne 4s linear infinite;
}
.carte-liaison h2 { margin: 26px 0 8px; font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.doux { margin: 0; color: var(--texte-2); }
.code { display: flex; justify-content: center; gap: 8px; margin: 28px 0 10px; min-height: 64px; }
.code span {
  width: 44px;
  height: 60px;
  display: grid;
  place-items: center;
  font: 700 32px/1 var(--police);
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--ombre-douce), 0 0 0 0.5px var(--separateur);
  animation: chiffre 0.6s var(--ressort) both;
}
.code span.espace { width: 10px; background: none; box-shadow: none; }
.attente { display: inline-flex; align-items: center; gap: 8px; margin: 18px 0 0; font-size: 15px; color: var(--texte-2); }
.attente .point { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
#nouveau-code { margin-top: 22px; }
.authentificateur { margin-top: 34px; padding-top: 22px; border-top: 0.5px solid var(--separateur); }
.authentificateur .champ-ligne { padding: 12px 0 0; }
.authentificateur .champ-ligne input { background: var(--surface); }
.graine {
  margin: 0;
  padding: 12px 16px;
  font: 600 17px/1.5 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 1px;
  word-spacing: 6px;
  text-align: center;
  -webkit-user-select: all;
  user-select: all;
}
.lien-cellule { text-decoration: none; }

/* --- Les animations ---------------------------------------------------------------- */
@keyframes arrive-gauche { from { opacity: 0; transform: translate(-14px, 18px) scale(0.7); } to { opacity: 1; transform: none; } }
@keyframes arrive-droite { from { opacity: 0; transform: translate(14px, 18px) scale(0.7); } to { opacity: 1; transform: none; } }
@keyframes respire { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@keyframes vague { 0%, 60%, 100% { transform: translateY(0); opacity: 0.45; } 30% { transform: translateY(-5px); opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.45; transform: scale(0.8); } }
@keyframes fondu { from { opacity: 0; } to { opacity: 1; } }
@keyframes fondu-inverse { from { opacity: 1; } to { opacity: 0; } }
@keyframes monte { from { opacity: 0; transform: translateY(18px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes descend { from { transform: translateY(-100%); } to { transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.4); } to { opacity: 1; transform: none; } }
@keyframes souleve { from { transform: scale(1); } to { transform: scale(1.04); } }
@keyframes pose { from { transform: scale(1.04); } to { transform: scale(1); opacity: 0.6; } }
@keyframes deplie { from { opacity: 0; transform: scale(0.6) translateY(-12px); } to { opacity: 1; transform: none; } }
@keyframes replie { to { opacity: 0; transform: scale(0.8); } }
@keyframes feuille-monte { from { transform: translateY(100%); } to { transform: none; } }
@keyframes tourne { to { transform: rotate(360deg); } }
@keyframes derive { from { transform: translate(0, 0) scale(1); } to { transform: translate(18vmax, 12vmax) scale(1.15); } }
@keyframes chiffre { from { opacity: 0; transform: translateY(20px) rotateX(80deg) scale(0.8); } to { opacity: 1; transform: none; } }
@keyframes coche { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes miroite { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* --- L'avis de Morty sur un message de Nox, comme un tapback --------------------------- */
.avis-badge {
  position: absolute;
  top: -10px;
  right: -8px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  font-size: 14px;
  background: var(--surface);
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--fond-chat), var(--ombre-douce);
  animation: pop 0.45s var(--ressort);
}
.contexte-scene.morty .reactions { display: none; }
.raisons {
  list-style: none;
  width: 260px;
  margin: 10px 0 0;
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--verre);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-radius: 14px;
  box-shadow: var(--ombre-haute);
  animation: deplie 0.4s var(--ressort) both;
}
.raisons p { width: 100%; margin: 0 0 2px; font-size: 13px; color: var(--texte-2); }
.raisons button {
  padding: 8px 12px;
  font-size: 15px;
  color: var(--texte);
  background: var(--surface);
  border: 0;
  border-radius: 999px;
  transition: transform 0.3s var(--ressort);
}
.raisons button:active { transform: scale(0.92); }

/* --- Chercher ------------------------------------------------------------------------- */
.recherche {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  background: var(--fond-chat);
  animation: fondu 0.25s ease-out;
}
.recherche-barre {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: calc(env(safe-area-inset-top) + 10px) 8px 10px 14px;
  background: var(--verre);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-bottom: 0.5px solid var(--separateur);
  animation: descend 0.4s var(--ressort);
}
.recherche-champ {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 10px;
  background: var(--surface-3);
  border-radius: 11px;
}
.recherche-champ svg { width: 18px; height: 18px; fill: none; stroke: var(--texte-2); stroke-width: 2.2; stroke-linecap: round; }
.recherche-champ input { flex: 1; min-width: 0; font: 17px var(--police); color: var(--texte); background: transparent; border: 0; outline: none; }
.resultats { list-style: none; flex: 1; overflow-y: auto; margin: 0; padding: 6px 16px 30px; }
.resultats li { animation: monte 0.4s var(--ressort) both; }
.resultats button {
  width: 100%;
  padding: 12px 0;
  text-align: left;
  color: var(--texte);
  background: none;
  border: 0;
  border-bottom: 0.5px solid var(--separateur);
}
.resultats b { display: flex; justify-content: space-between; font-size: 15px; }
.resultats b small { font-weight: 400; color: var(--texte-2); }
.resultats span { display: block; margin-top: 3px; font-size: 15px; color: var(--texte-2); }
.resultats mark { color: var(--texte); background: var(--accent-doux); border-radius: 4px; padding: 0 2px; }
.resultats .vide { padding: 40px 0; text-align: center; color: var(--texte-2); }
.bulle.retrouvee { animation: retrouve 1.6s ease-out; }
@keyframes retrouve { 0%, 30% { box-shadow: 0 0 0 3px var(--accent), 0 0 30px var(--accent); } 100% { box-shadow: none; } }

/* --- Aujourd'hui ---------------------------------------------------------------------- */
.date-du-jour { margin: 4px 0 2px; font-size: 32px; font-weight: 800; letter-spacing: -0.8px; animation: monte 0.5s var(--ressort) both; }
.carte-jour {
  padding: 14px 16px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--ombre-douce);
  animation: monte 0.55s var(--ressort) both;
}
.carte-jour h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; color: var(--texte-2); }
.carte-jour h3 .pastille { width: 22px; height: 22px; border-radius: 6px; }
.carte-jour h3 .pastille svg { width: 14px; height: 14px; }
.creneau { display: flex; gap: 12px; padding: 8px 0; }
.creneau + .creneau { border-top: 0.5px solid var(--separateur); }
.creneau .heures { flex: none; width: 52px; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.creneau .heures small { display: block; font-weight: 400; color: var(--texte-2); }
.creneau .quoi { flex: 1; min-width: 0; }
.creneau .quoi small { display: block; color: var(--texte-2); font-size: 14px; }
.creneau.passe { opacity: 0.45; }
.creneau.en_cours .heures { color: var(--accent); }
.creneau.en_cours .quoi::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
}
.attend { display: block; padding: 8px 0; }
.attend + .attend { border-top: 0.5px solid var(--separateur); }
.attend b { display: flex; justify-content: space-between; }
.attend b small { font-weight: 400; color: var(--texte-2); }
.attend span { display: block; color: var(--texte-2); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.carte-jour .rien { margin: 0; color: var(--texte-2); }

/* --- Ce que Nox sait de toi ------------------------------------------------------------ */
.fait { display: flex; align-items: flex-start; gap: 10px; }
.fait .cellule-texte { white-space: normal; }
.source { flex: none; margin-top: 3px; padding: 1px 7px; font-size: 11px; font-weight: 600; border-radius: 999px; color: var(--texte-2); background: var(--surface-3); }
.source.nox { color: #fff; background: var(--accent); }
.edition { display: flex; flex-direction: column; gap: 8px; width: 100%; padding: 10px 16px; animation: fondu 0.2s ease-out; }
.edition textarea {
  width: 100%;
  min-height: 64px;
  padding: 8px 10px;
  resize: vertical;
  font: 16px/1.35 var(--police);
  color: var(--texte);
  background: var(--surface-3);
  border: 0;
  border-radius: 10px;
  outline: none;
}
.edition .rangee-boutons { display: flex; gap: 8px; justify-content: flex-end; }
.ajouter-fait { color: var(--accent); }
.note + .liste { margin-top: 6px; }

/* --- Joindre une photo ou un PDF --------------------------------------------------------- */
.joindre {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--texte-2);
  background: var(--surface-2);
  border: 0;
  border-radius: 50%;
  transition: transform 0.3s var(--ressort), background 0.2s;
}
.joindre svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.joindre:active { transform: scale(0.85) rotate(90deg); }
.jointes { display: flex; gap: 8px; max-width: 760px; margin: 0 auto 8px; overflow-x: auto; padding: 4px 2px; }
.jointe {
  position: relative;
  flex: none;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--texte-2);
  background: var(--surface) center / cover no-repeat;
  border-radius: 12px;
  box-shadow: 0 0 0 0.5px var(--separateur);
  animation: pop 0.4s var(--ressort);
}
.jointe.envoi::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35) center / 22px no-repeat;
  animation: pulse 1s ease-in-out infinite;
}
.jointe.erreur { color: var(--rouge); box-shadow: 0 0 0 1.5px var(--rouge); }
.jointe button {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 13px;
  line-height: 1;
  color: #fff;
  background: rgba(0, 0, 0, 0.7);
  border: 0;
  border-radius: 50%;
}
.vignettes { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px -6px 6px; }
.vignettes img { width: 150px; max-width: 100%; height: 150px; object-fit: cover; border-radius: 14px; background: rgba(127, 127, 127, 0.2); animation: fondu 0.4s ease-out; }
.vignettes .document { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; font-size: 15px; font-weight: 600; background: rgba(0, 0, 0, 0.18); border-radius: 12px; }
.bulle a { color: inherit; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }

/* --- Une vraie urgence ------------------------------------------------------------------ */
.bulle.urgente { box-shadow: 0 0 0 2px var(--rouge), 0 0 24px rgba(255, 59, 48, 0.35); }
.bulle.urgente::before { content: "🚨 Urgent"; display: block; margin-bottom: 3px; font-size: 12px; font-weight: 700; color: var(--rouge); }
