/* ============================================================== tokens ==== */

:root {
  --font: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --radius: 22px;
  --bubble-radius: 20px;
  --shadow: 0 18px 50px -20px rgb(0 0 0 / 0.55);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* nuit — l'ambiance par défaut */
body[data-theme="dusk"] {
  --bg: #140e1f;
  --bg-2: #1d1430;
  --ink: #f3edff;
  --ink-soft: #b7abd0;
  --ink-faint: #7d7295;
  --glass: rgb(255 255 255 / 0.055);
  --glass-strong: rgb(255 255 255 / 0.1);
  --line: rgb(255 255 255 / 0.09);
  --accent: #f2789f;
  --accent-2: #a970ff;
  --mine-1: #f0709a;
  --mine-2: #b26bf0;
  --mine-ink: #fff;
  --theirs: rgb(255 255 255 / 0.075);
  --theirs-ink: #efe9fb;
  --blob-1: #ff5fa2;
  --blob-2: #7b4dff;
  --blob-3: #2f9cff;
  --blob-opacity: 0.3;
  --scrim: rgb(14 9 22 / 0.42);
}

/* rose — doux et clair */
body[data-theme="rose"] {
  --bg: #fdf3ee;
  --bg-2: #f7e6dd;
  --ink: #3b2a2a;
  --ink-soft: #8a6f68;
  --ink-faint: #b09a94;
  --glass: rgb(255 255 255 / 0.6);
  --glass-strong: rgb(255 255 255 / 0.8);
  --line: rgb(90 50 40 / 0.1);
  --accent: #e0655f;
  --accent-2: #d98a5a;
  --mine-1: #ef7168;
  --mine-2: #f0a06a;
  --mine-ink: #fff;
  --theirs: #fff;
  --theirs-ink: #4a3735;
  --blob-1: #ffb59d;
  --blob-2: #ffd9a8;
  --blob-3: #ffc2d1;
  --blob-opacity: 0.6;
  --scrim: rgb(255 245 238 / 0.4);
  --shadow: 0 18px 45px -22px rgb(120 60 40 / 0.35);
}

/* océan — calme et profond */
body[data-theme="ocean"] {
  --bg: #071a24;
  --bg-2: #0b2836;
  --ink: #e6f6ff;
  --ink-soft: #97b8c8;
  --ink-faint: #6b8a99;
  --glass: rgb(255 255 255 / 0.05);
  --glass-strong: rgb(255 255 255 / 0.1);
  --line: rgb(255 255 255 / 0.09);
  --accent: #43d6c4;
  --accent-2: #4aa8ff;
  --mine-1: #2fbfae;
  --mine-2: #3d8fe0;
  --mine-ink: #04222b;
  --theirs: rgb(255 255 255 / 0.07);
  --theirs-ink: #dff2fb;
  --blob-1: #00d3b8;
  --blob-2: #0a7bd8;
  --blob-3: #7a5cff;
  --blob-opacity: 0.26;
  --scrim: rgb(4 16 22 / 0.45);
}

/* ============================================================== base ===== */

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  transition: background 0.6s var(--ease), color 0.4s var(--ease);
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.screen[hidden], [hidden] { display: none !important; }

/* décor de fond */
.aurora {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: radial-gradient(140% 110% at 50% 0%, var(--bg-2) 0%, var(--bg) 62%);
  z-index: 0;
}

/* voile qui calme les couleurs pour garder le texte lisible */
.aurora::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.blob {
  position: absolute;
  width: 58vmax;
  height: 58vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: var(--blob-opacity);
  will-change: transform;
}

.b1 { background: var(--blob-1); top: -22vmax; left: -14vmax; animation: drift1 26s var(--ease) infinite alternate; }
.b2 { background: var(--blob-2); bottom: -26vmax; right: -16vmax; animation: drift2 32s var(--ease) infinite alternate; }
.b3 { background: var(--blob-3); top: 34%; left: 42%; width: 40vmax; height: 40vmax; opacity: calc(var(--blob-opacity) * 0.55); animation: drift3 38s var(--ease) infinite alternate; }

@keyframes drift1 { to { transform: translate3d(14vw, 10vh, 0) scale(1.15); } }
@keyframes drift2 { to { transform: translate3d(-12vw, -8vh, 0) scale(1.2); } }
@keyframes drift3 { to { transform: translate3d(-18vw, 12vh, 0) scale(0.85); } }

@media (prefers-reduced-motion: reduce) {
  .blob { animation: none; }
  * { scroll-behavior: auto !important; }
}

/* ============================================================ connexion == */

.login {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
}

.card {
  width: min(380px, 100%);
  padding: 38px 32px 32px;
  border-radius: 30px;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  box-shadow: var(--shadow);
  text-align: center;
  animation: rise 0.7s var(--ease) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(22px) scale(0.97); }
}

.mark {
  width: 58px;
  height: 58px;
  margin: 0 auto 28px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(140deg, var(--mine-1), var(--mine-2));
  box-shadow: 0 12px 28px -10px var(--mine-1);
}
.mark svg { width: 28px; height: 28px; fill: currentColor; stroke: none; }

.field { display: block; text-align: left; margin-bottom: 14px; }

.field > span {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.field input {
  width: 100%;
  padding: 13px 15px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--glass-strong);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input::placeholder { color: var(--ink-faint); }

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.who { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }

.who button {
  flex: 1;
  min-width: 100px;
  padding: 10px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--glass-strong);
  color: var(--ink-soft);
  font-size: 14px;
  transition: all 0.22s var(--ease);
}

.who button:hover { transform: translateY(-1px); color: var(--ink); }

.who button[aria-pressed="true"] {
  color: var(--mine-ink);
  border-color: transparent;
  background: linear-gradient(135deg, var(--mine-1), var(--mine-2));
  box-shadow: 0 10px 22px -12px var(--mine-1);
}

.primary {
  width: 100%;
  margin-top: 10px;
  padding: 14px;
  border-radius: 15px;
  font-weight: 500;
  color: var(--mine-ink);
  background: linear-gradient(135deg, var(--mine-1), var(--mine-2));
  box-shadow: 0 14px 30px -14px var(--mine-1);
  transition: transform 0.2s var(--ease), filter 0.2s, opacity 0.2s;
}
.primary:hover { transform: translateY(-2px); filter: brightness(1.06); }
.primary:active { transform: translateY(0) scale(0.99); }
.primary:disabled { opacity: 0.6; pointer-events: none; }

.error {
  min-height: 18px;
  margin: 4px 0 0;
  font-size: 13px;
  color: #ff8098;
}
body[data-theme="rose"] .error { color: #c9403c; }

/* ================================================================ chat === */

.chat {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  max-width: 820px;
  margin: 0 auto;
}

/* barre du haut */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.peer { display: flex; align-items: center; gap: 12px; min-width: 0; }

.avatar {
  position: relative;
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 600;
  font-size: 16px;
  color: #fff;
  background: linear-gradient(140deg, var(--accent-2), var(--accent));
  box-shadow: 0 8px 20px -10px var(--accent);
}

.dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink-faint);
  border: 2.5px solid var(--bg);
  transition: background 0.3s;
}
.dot.on { background: #45d97f; box-shadow: 0 0 0 0 rgb(69 217 127 / 0.6); animation: pulse 2s infinite; }

@keyframes pulse {
  70% { box-shadow: 0 0 0 7px rgb(69 217 127 / 0); }
  100% { box-shadow: 0 0 0 0 rgb(69 217 127 / 0); }
}

.peer-text { min-width: 0; }
.peer-text strong { display: block; font-weight: 500; font-size: 16px; }
.peer-text small { color: var(--ink-soft); font-size: 12.5px; }

.tools { display: flex; gap: 4px; }

.icon {
  width: 38px;
  height: 38px;
  padding: 9px;
  border-radius: 12px;
  color: var(--ink-soft);
  transition: background 0.2s, color 0.2s, transform 0.2s var(--ease);
}
.icon:hover { background: var(--glass-strong); color: var(--ink); }
.icon:active { transform: scale(0.92); }
.icon.small { width: 30px; height: 30px; padding: 7px; }

/* cloche : la barre oblique n'apparait que notifications coupees */
.bell .slash { opacity: 1; transition: opacity 0.2s; }
.bell.on { color: var(--accent); }
.bell.on .slash { opacity: 0; }

/* fil de discussion */
.thread {
  min-height: 0; /* sans ça la rangée 1fr grandit avec son contenu et pousse la saisie hors écran */
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 18px 16px 8px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.thread::-webkit-scrollbar { width: 7px; }
.thread::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.load-more {
  display: block;
  margin: 0 auto 18px;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--glass);
  border: 1px solid var(--line);
  transition: color 0.2s, background 0.2s;
}
.load-more:hover { color: var(--ink); background: var(--glass-strong); }

.day {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 22px 4px 18px;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.day::before, .day::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.empty {
  margin: 18vh auto;
  max-width: 300px;
  text-align: center;
  color: var(--ink-soft);
  animation: rise 0.8s var(--ease) both;
}
.empty span { font-size: 40px; display: block; margin-bottom: 12px; }
.empty p { margin: 0; font-family: var(--display); font-size: 19px; font-weight: 300; line-height: 1.5; }

/* bulles */
.row {
  display: flex;
  margin-bottom: 3px;
  animation: pop 0.42s var(--ease) both;
}
.row.mine { justify-content: flex-end; }
.row.tail { margin-bottom: 14px; }

@keyframes pop {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
}

.bubble {
  position: relative;
  max-width: min(76%, 480px);
  padding: 10px 15px 8px;
  border-radius: var(--bubble-radius);
  font-size: 15.5px;
  font-weight: 300;
  line-height: 1.48;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  transition: transform 0.18s var(--ease);
}
.bubble:active { transform: scale(0.985); }

.row.mine .bubble {
  color: var(--mine-ink);
  background: linear-gradient(135deg, var(--mine-1), var(--mine-2));
  border-bottom-right-radius: 7px;
  box-shadow: 0 10px 24px -16px var(--mine-1);
}
.row.theirs .bubble {
  color: var(--theirs-ink);
  background: var(--theirs);
  border: 1px solid var(--line);
  border-bottom-left-radius: 7px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.row:not(.tail).mine .bubble { border-bottom-right-radius: var(--bubble-radius); }
.row:not(.tail).theirs .bubble { border-bottom-left-radius: var(--bubble-radius); }

.bubble.deleted { font-style: italic; opacity: 0.55; font-size: 14px; }
.bubble a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }

/* un message fait uniquement d'emoji : pas de bulle, juste l'emoji en grand */
.row .bubble.jumbo {
  padding: 0 6px;
  color: var(--ink);
  background: none;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.bubble.jumbo .body { font-size: 46px; line-height: 1.2; }
.bubble.jumbo .meta { margin-top: -2px; }
/* hors bulle, la coche « lu » doit rester lisible sur le fond de l'app */
.bubble.jumbo .meta .check.seen { color: var(--accent); }
.bubble b { font-weight: 600; }

.quote {
  display: block;
  margin: -2px 0 7px;
  padding: 7px 11px;
  border-radius: 11px;
  border-left: 3px solid currentColor;
  background: rgb(0 0 0 / 0.14);
  font-size: 13.5px;
  opacity: 0.82;
}
.row.theirs .quote { background: rgb(127 127 127 / 0.12); }
.quote strong { display: block; font-weight: 500; font-size: 12px; margin-bottom: 1px; }
.quote span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
  font-size: 10.5px;
  opacity: 0.62;
  user-select: none;
}
.meta .check { width: 15px; height: 15px; }
.meta .edited { font-style: italic; opacity: 0.85; }
.meta .edited::before { content: "· "; }
.meta .check.seen { color: #8ce8ff; opacity: 1; }
body[data-theme="rose"] .meta .check.seen { color: #fff3c4; }

/* photos */
.bubble.photo { padding: 5px; overflow: hidden; }
.bubble.photo img {
  display: block;
  width: 100%;
  max-width: 320px;
  max-height: 400px;
  object-fit: cover;
  border-radius: 16px;
  cursor: zoom-in;
  background: var(--glass-strong);
}
.bubble.video video {
  display: block;
  width: 100%;
  max-width: 320px;
  max-height: 420px;
  border-radius: 16px;
  background: #000;
}
/* la barre de lecture occupe déjà le bas : on remonte l'heure hors du chemin */
.bubble.video .meta { position: static; padding: 5px 8px 2px; background: none; color: inherit; opacity: 0.62; }
body[data-theme="rose"] .row.mine .bubble.video .meta { color: #fff; opacity: 0.9; }

.bubble.photo .meta { position: absolute; right: 12px; bottom: 11px; padding: 2px 7px; border-radius: 999px; background: rgb(0 0 0 / 0.4); color: #fff; opacity: 1; backdrop-filter: blur(6px); }

/* ── fond photo ──────────────────────────────────────────────────────────── */

/* La photo remplace le décor animé. Un voile assez dense passe par-dessus :
   sans lui les bulles claires deviennent illisibles sur les zones claires. */
body.avec-photo .aurora {
  background: #000 url('/api/bg') center / cover no-repeat;
}
body.avec-photo .blob { display: none; }
body.avec-photo .aurora::after {
  background: var(--voile-photo);
  backdrop-filter: blur(3px) saturate(115%);
  -webkit-backdrop-filter: blur(3px) saturate(115%);
}

body[data-theme="rose"]  { --voile-photo: rgb(253 243 238 / 0.78); }
body[data-theme="dusk"]  { --voile-photo: rgb(20 14 31 / 0.76); }
body[data-theme="ocean"] { --voile-photo: rgb(7 26 36 / 0.76); }

/* ── stickers ────────────────────────────────────────────────────────────── */

.bubble.sticker {
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.bubble.sticker img {
  display: block;
  width: 148px;
  max-width: 100%;
  border-radius: 18px;
  filter: drop-shadow(0 8px 16px rgb(0 0 0 / 0.22));
}
.bubble.sticker .meta { justify-content: flex-end; padding-top: 3px; }

.emoji-grid.stickers {
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-height: 262px;
}
.emoji-grid.stickers button {
  aspect-ratio: 1;
  padding: 0;
  border-radius: 16px;
  overflow: hidden;
}
.emoji-grid.stickers button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 16px;
}
.emoji-grid.stickers button:hover { background: none; transform: scale(1.05); }
.sticker-vide {
  grid-column: 1 / -1;
  margin: 26px 8px;
  text-align: center;
  font-size: 13.5px;
  color: var(--ink-faint);
}

/* réaction + actions */
.reaction {
  position: absolute;
  bottom: -11px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 13px;
  line-height: 1.3;
  background: var(--bg-2);
  border: 1px solid var(--line);
  box-shadow: 0 4px 12px -6px rgb(0 0 0 / 0.5);
  animation: pop 0.35s var(--ease) both;
}
.row.mine .reaction { left: 10px; }
.row.theirs .reaction { right: 10px; }

.actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.2s;
  color: var(--ink-faint);
}
.row:hover .actions, .row.open .actions { opacity: 1; }
.row.mine .actions { order: -1; margin-right: 4px; }
.row.theirs .actions { margin-left: 4px; }
.actions .icon { width: 30px; height: 30px; padding: 7px; }

@media (hover: none) {
  .actions { display: none; }
}

/* saisie en cours */
.typing {
  display: flex;
  gap: 4px;
  width: fit-content;
  margin: 4px 0 10px;
  padding: 12px 16px;
  border-radius: var(--bubble-radius);
  border-bottom-left-radius: 7px;
  background: var(--theirs);
  border: 1px solid var(--line);
  animation: pop 0.3s var(--ease) both;
}
.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-soft);
  animation: bounce 1.25s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.16s; }
.typing span:nth-child(3) { animation-delay: 0.32s; }

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

/* bouton descendre */
.jump {
  position: absolute;
  right: 18px;
  bottom: 96px;
  width: 40px;
  height: 40px;
  padding: 8px;
  border-radius: 50%;
  color: var(--ink);
  background: var(--glass-strong);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  animation: pop 0.3s var(--ease) both;
  z-index: 5;
}
.jump:hover { transform: translateY(-2px); }

/* barre de réponse */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 12px;
  padding: 9px 12px;
  border-radius: 14px 14px 0 0;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  border-bottom: 0;
  animation: rise 0.25s var(--ease) both;
}
.reply-preview {
  flex: 1;
  min-width: 0;
  border-left: 3px solid var(--accent);
  padding-left: 9px;
  font-size: 13px;
}
.reply-preview strong { display: block; font-weight: 500; color: var(--accent); font-size: 12px; }
.reply-preview span { display: block; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── le personnage qui monte du bas quand l'autre entre dans la conversation ── */

.presence {
  /* ancré sur la zone de saisie : il reste juste au-dessus quel que soit
     le nombre de lignes tapées */
  position: absolute;
  left: 12px;
  bottom: calc(100% - 6px);
  display: flex;
  align-items: flex-end;
  pointer-events: none;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.32s var(--ease), transform 0.44s var(--ease);
}
.presence.monte { opacity: 1; transform: none; }

.presence .who {
  position: relative;
  z-index: 2;
  display: block;
  font-size: 40px;
  font-style: normal;
  line-height: 1;
  /* il dépasse juste au-dessus du bord, comme s'il passait la tête */
  margin-bottom: -6px;
  filter: drop-shadow(0 6px 10px rgb(0 0 0 / 0.22));
  transform-origin: bottom center;
}
.presence.monte .who { animation: coucou 0.9s var(--ease) 0.1s; }

/* le prénom sort de derrière le personnage, puis se rétracte */
.presence .label {
  margin: 0 0 12px -10px;
  padding: 5px 13px 5px 18px;
  border-radius: 0 999px 999px 0;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--ink);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-left: 0;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateX(-14px) scale(0.9);
  transform-origin: left center;
  transition: opacity 0.3s var(--ease), transform 0.4s var(--ease);
}
.presence.ouvert .label { opacity: 1; transform: none; }

@keyframes coucou {
  0%   { transform: translateY(16px) scale(0.7) rotate(0deg); }
  40%  { transform: translateY(-6px) scale(1.12) rotate(-9deg); }
  60%  { transform: translateY(0) scale(1) rotate(7deg); }
  80%  { transform: rotate(-4deg); }
  100% { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .presence, .presence .label { transition: none; }
  .presence.monte .who { animation: none; }
}

/* zone de saisie */
.composer {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.icon.round {
  width: 44px;
  height: 44px;
  flex: none;
  padding: 11px;
  border-radius: 50%;
  background: var(--glass);
  border: 1px solid var(--line);
}

.input-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: flex-end;
  border-radius: 22px;
  background: var(--glass);
  border: 1px solid var(--line);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-wrap:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

.input-wrap textarea {
  flex: 1;
  max-height: 132px;
  padding: 12px 4px 12px 17px;
  border: 0;
  background: none;
  outline: none;
  resize: none;
  font-weight: 300;
  font-size: 15.5px;
  line-height: 1.45;
  overflow-y: auto;
  scrollbar-width: none; /* sinon Chrome réserve une gouttière visible dans la barre de saisie */
}
.input-wrap textarea::-webkit-scrollbar { width: 0; height: 0; }
.input-wrap textarea::placeholder { color: var(--ink-faint); }
.emoji { width: 40px; height: 42px; padding: 11px; }

.send {
  position: relative;
  width: 46px;
  height: 46px;
  flex: none;
  padding: 12px;
  border-radius: 50%;
  color: var(--mine-ink);
  background: linear-gradient(135deg, var(--mine-1), var(--mine-2));
  box-shadow: 0 10px 24px -12px var(--mine-1);
  transition: transform 0.25s var(--ease), filter 0.2s;
}
.send:hover { transform: translateY(-2px) scale(1.04); filter: brightness(1.07); }
.send:active { transform: scale(0.93); }
/* inset seul ne suffit pas : la règle globale « svg { width: 100% } » l'emporterait
   et l'icône déborderait du cercle. Taille fixe + margin auto = vrai centrage. */
.send svg {
  position: absolute;
  inset: 0;
  width: 21px;
  height: 21px;
  margin: auto;
  transition: opacity 0.25s var(--ease), transform 0.3s var(--ease);
}
.send .plane { opacity: 0; transform: scale(0.6) rotate(-25deg); }
.send .heart { fill: currentColor; stroke: none; }
.send.ready .plane { opacity: 1; transform: none; }
.send.ready .heart { opacity: 0; transform: scale(0.6); }

/* emoji */
.emoji-pop {
  position: absolute;
  right: 62px;
  bottom: 74px;
  display: flex;
  flex-direction: column;
  width: min(342px, calc(100vw - 24px));
  border-radius: 18px;
  overflow: hidden;
  background: var(--bg-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise 0.22s var(--ease) both;
  z-index: 20;
}

/* onglets : toujours visibles, la grille défile en dessous */
.emoji-tabs {
  display: flex;
  gap: 2px;
  padding: 7px 7px 6px;
  border-bottom: 1px solid var(--line);
}
.emoji-tabs button {
  flex: 1;
  padding: 6px 0 7px;
  font-size: 17px;
  line-height: 1;
  border-radius: 9px;
  opacity: 0.45;
  transition: opacity 0.15s, background 0.15s;
}
.emoji-tabs button:hover { opacity: 0.8; }
.emoji-tabs button[aria-selected="true"] {
  opacity: 1;
  background: var(--glass-strong);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 1px;
  max-height: 232px;
  padding: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.emoji-grid::-webkit-scrollbar { width: 6px; }
.emoji-grid::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.emoji-grid button {
  aspect-ratio: 1;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  border-radius: 9px;
  transition: background 0.15s, transform 0.15s var(--ease);
}
.emoji-grid button:hover { background: var(--glass-strong); transform: scale(1.2); }
.emoji-grid button:active { transform: scale(0.95); }

/* cœurs qui montent */
.hearts { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.hearts i {
  position: absolute;
  bottom: 60px;
  font-size: 26px;
  font-style: normal;
  animation: fly 3.4s var(--ease) forwards;
}
@keyframes fly {
  0% { opacity: 0; transform: translateY(0) scale(0.4); }
  12% { opacity: 1; transform: translateY(-30px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-72vh) scale(0.85) rotate(var(--r, 18deg)); }
}

/* toast */
.toast {
  position: absolute;
  left: 50%;
  top: 76px;
  transform: translateX(-50%);
  padding: 9px 17px;
  border-radius: 999px;
  font-size: 13.5px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise 0.3s var(--ease) both;
  z-index: 40;
}

/* ── la question, puis l'écran « hors ligne » ─────────────────────────────── */

.ask {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(0 0 0 / 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: rise 0.3s var(--ease) both;
}

.ask-card {
  width: min(330px, 100%);
  padding: 30px 26px 24px;
  border-radius: 26px;
  text-align: center;
  background: var(--bg-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise 0.4s var(--ease) both;
}
.ask-emoji { display: block; font-size: 46px; font-style: normal; margin-bottom: 14px; }
.ask-card p {
  margin: 0 0 22px;
  font-size: 17px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--ink);
}

.ask-actions { display: flex; gap: 10px; }
.ask-actions button {
  flex: 1;
  padding: 13px;
  border-radius: 14px;
  font-weight: 500;
  transition: transform 0.18s var(--ease), filter 0.2s;
}
.ask-actions button:active { transform: scale(0.97); }
.ask-no {
  color: var(--ink);
  background: var(--glass-strong);
  border: 1px solid var(--line);
}
.ask-yes {
  color: var(--mine-ink);
  background: linear-gradient(135deg, var(--mine-1), var(--mine-2));
  box-shadow: 0 10px 22px -12px var(--mine-1);
}
/* action irréversible : on la teinte en rouge pour qu'elle ne soit pas cliquée par réflexe */
.ask-yes.danger {
  color: #fff;
  background: linear-gradient(135deg, #e5484d, #c0392b);
  box-shadow: 0 10px 22px -12px #c0392b;
}
.ask-actions button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.broken {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 4px;
  padding: 28px;
  text-align: center;
  background: #0d0a0f;
  color: #efe6ea;
  animation: rise 0.6s var(--ease) both;
}
.broken-heart {
  font-size: 72px;
  font-style: normal;
  margin-bottom: 14px;
  cursor: default;
  animation: battement 2.6s ease-in-out infinite;
}
.broken h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 27px;
  letter-spacing: -0.01em;
}
.broken p { margin: 6px 0 0; font-size: 15px; font-weight: 300; opacity: 0.62; }

.restore {
  margin-top: 32px;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  color: #efe6ea;
  background: rgb(255 255 255 / 0.09);
  border: 1px solid rgb(255 255 255 / 0.16);
  animation: rise 0.35s var(--ease) both;
}
.restore:hover { background: rgb(255 255 255 / 0.15); }

@keyframes battement {
  0%, 100% { transform: scale(1); }
  14% { transform: scale(1.13); }
  28% { transform: scale(1); }
  42% { transform: scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  .broken-heart { animation: none; }
}

/* visionneuse photo */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(0 0 0 / 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: rise 0.25s var(--ease) both;
}
.viewer img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 14px;
  box-shadow: 0 30px 80px -30px #000;
}
.viewer-close {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  right: 18px;
  color: #fff;
  background: rgb(255 255 255 / 0.12);
}

/* ============================================================ mobile ===== */

@media (max-width: 560px) {
  /* sur un petit écran le sélecteur prend toute la largeur disponible */
  .emoji-pop { right: 12px; left: 12px; width: auto; }
  .emoji-grid { max-height: 208px; }
  .bubble { max-width: 84%; font-size: 15px; }
  .thread { padding: 14px 12px 6px; }
  .card { padding: 32px 24px 26px; }
  .jump { bottom: 88px; right: 14px; }
}
