:root {
  --bg: #f4f1ea;
  --panel: #ffffff;
  --text: #1d2a2f;
  --muted: #6b7b80;
  --line: #e4ded3;
  --accent: #2a9d8f;
  --accent-text: #ffffff;
  --mine: #d8f3ec;
  --theirs: #ffffff;
  --danger: #d62839;
  --ok: #2bb673;
  --radius: 18px;
  /* Écran d'appel : clair en mode jour, sombre en mode sombre */
  --call-bg: radial-gradient(circle at 50% 35%, #ffffff 0%, #eef1f3 70%);
  --call-fg: #111b21;
  --call-panel: #ffffff;
  --call-panel-shadow: 0 -2px 20px rgba(0,0,0,.08);
  --call-btn: #e9edef;
  --call-btn-on: #111b21;
  --call-btn-on-fg: #ffffff;
  --call-pulse: rgba(17,27,33,.18);
}
/* Mode sombre : automatique (réglage du téléphone), ou choisi dans les Réglages (data-theme) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11181b;
    --panel: #1a2428;
    --text: #e8eef0;
    --muted: #8fa1a6;
    --line: #2a373c;
    --mine: #1f4a44;
    --theirs: #223035;
    --call-bg: radial-gradient(circle at 50% 35%, #16252c 0%, #0b141a 70%);
    --call-fg: #ffffff;
    --call-panel: rgba(28, 38, 43, .92);
    --call-panel-shadow: 0 -2px 20px rgba(0,0,0,.35);
    --call-btn: rgba(255,255,255,.1);
    --call-btn-on: #ffffff;
    --call-btn-on-fg: #0b141a;
    --call-pulse: rgba(255,255,255,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #11181b;
    --panel: #1a2428;
    --text: #e8eef0;
    --muted: #8fa1a6;
    --line: #2a373c;
    --mine: #1f4a44;
    --theirs: #223035;
    --call-bg: radial-gradient(circle at 50% 35%, #16252c 0%, #0b141a 70%);
    --call-fg: #ffffff;
    --call-panel: rgba(28, 38, 43, .92);
    --call-panel-shadow: 0 -2px 20px rgba(0,0,0,.35);
    --call-btn: rgba(255,255,255,.1);
    --call-btn-on: #ffffff;
    --call-btn-on-fg: #0b141a;
    --call-pulse: rgba(255,255,255,.25);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  /* Comme une vraie appli : pas de sélection de texte ni de menu sur appui long */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
/* …sauf là où on écrit, et sur les photos/vidéos (pour pouvoir les enregistrer) */
input, textarea, select { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
.bubble img, .bubble video { -webkit-touch-callout: default; }
button, .icon-btn, .round { touch-action: manipulation; }
#mic-btn { touch-action: none; }
.hidden { display: none !important; }
/* Fonction « amis » cachée pour l'instant (réactivable côté serveur) */
.no-friends .friends-only { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--danger); min-height: 1em; margin: 4px 0; font-size: .9rem; }
.error.pending { color: var(--muted, #777); }
.captcha-box { display: flex; justify-content: center; margin: 6px 0; }
.captcha-box:empty { display: none; }

input, textarea, select {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  width: 100%;
}
textarea { resize: none; max-height: 120px; }

.btn {
  font: inherit;
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  background: var(--line);
  color: var(--text);
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 12px; font-size: .85rem; }
.btn.full { width: calc(100% - 24px); margin: 12px; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 42px; height: 42px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 1.3rem;
  cursor: pointer;
  color: inherit;
}
.icon-btn:hover { background: var(--line); }
.icon-btn.send { background: var(--accent); color: var(--accent-text); }

.avatar {
  display: inline-grid;
  place-items: center;
  width: 42px; height: 42px;
  flex: none;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  position: relative;
}
.avatar.big { width: 96px; height: 96px; font-size: 2.4rem; }
.avatar.online::after {
  content: "";
  position: absolute; right: 0; bottom: 0;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--ok);
  border: 2px solid var(--panel);
}

/* ---------- Connexion ---------- */
.auth-screen { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card {
  width: min(400px, 100%);
  background: var(--panel);
  border-radius: 24px;
  padding: 28px 24px;
  display: grid;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.08);
}
.card h1 { margin: 0; text-align: center; }
.card label { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); }
.logo { font-size: 3rem; text-align: center; }
.invite-note { background: var(--mine); border-radius: 12px; padding: 10px 12px; margin: 0 0 10px; font-size: .95rem; line-height: 1.35; }
.logo-img { width: 76px; height: 76px; border-radius: 20px; display: inline-block; vertical-align: middle; }

/* ---------- Mise en page ---------- */
#app { display: flex; height: 100vh; height: 100dvh; }
#sidebar {
  width: 340px;
  flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.me { display: flex; align-items: center; gap: 10px; flex: 1; }
.banner {
  margin: 10px 12px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff4d6;
  color: #5c4800;
  font-size: .9rem;
  display: flex; gap: 8px; align-items: center; justify-content: space-between;
}
.banner.install { background: #dff3ef; color: #134e46; }
.banner .small-x { width: 28px; height: 28px; font-size: .9rem; color: inherit; }
.share-icon { display: inline-block; vertical-align: -3px; width: 18px; height: 18px; }
#conv-list { list-style: none; margin: 0; padding: 6px 0; overflow-y: auto; flex: 1; }
#conv-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
}
#conv-list li:hover, #conv-list li.active { background: var(--bg); }
.conv-text { flex: 1; min-width: 0; }
.conv-text strong { display: block; }
.conv-text small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  background: var(--accent); color: var(--accent-text);
  border-radius: 999px; min-width: 22px; padding: 2px 7px;
  font-size: .8rem; text-align: center; font-weight: 700;
}

#chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#chat .placeholder { display: none; }
#chat.empty > * { display: none; }
#chat.empty .placeholder { display: grid; place-items: center; flex: 1; color: var(--muted); font-size: 1.1rem; }
.chat-header { padding-top: calc(10px + env(safe-area-inset-top)); }
.chat-title { flex: 1; min-width: 0; display: grid; }
.chat-title small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Téléphone étroit ou texte agrandi (réglage Android) : la manette passe dans le menu ⋮, les boutons se resserrent */
.chat-header.tight { gap: 4px; padding-left: 6px; padding-right: 6px; }
.chat-header.tight .icon-btn { width: 36px; }
.chat-header.compact #games-btn { display: none; }
#back-btn { display: none; }

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 4px;
  display: flex; flex-direction: column; gap: 4px;
}
.day { align-self: center; font-size: .78rem; color: var(--muted); margin: 10px 0 4px; }
.msg { max-width: min(78%, 480px); display: flex; flex-direction: column; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.theirs { align-self: flex-start; }
.msg .author { font-size: .78rem; font-weight: 600; margin: 6px 10px 2px; }
.bubble {
  background: var(--theirs);
  padding: 8px 12px;
  border-radius: var(--radius);
  word-wrap: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 1px rgba(0,0,0,.05);
}
.msg.mine .bubble { background: var(--mine); }
.bubble.media { padding: 4px; }
.bubble img, .bubble video {
  display: block;
  max-width: 100%;
  max-height: 340px;
  border-radius: 14px;
  background: #000;
}
.bubble img { cursor: zoom-in; }
.bubble audio { display: block; width: 240px; max-width: 100%; }
.bubble .caption { padding: 6px 8px 2px; }
.bubble a.link { color: inherit; text-decoration: underline; word-break: break-all; -webkit-touch-callout: default; }
.bubble.voice { padding: 8px 10px; min-width: 220px; }
.voice-player { display: flex; align-items: center; gap: 10px; }
.voice-btn {
  width: 38px; height: 38px; flex: none;
  border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-text);
  font-size: 1rem; cursor: pointer;
}
.voice-track { flex: 1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; cursor: pointer; min-width: 90px; }
.voice-fill { height: 100%; width: 0; background: var(--accent); }
.voice-time { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.voice-status { font-size: .78rem; color: var(--danger); margin-top: 6px; white-space: normal; }
.meta { font-size: .7rem; color: var(--muted); margin: 2px 8px 0; }
/* Heure et ✓✓ dans la bulle, à droite de la dernière ligne (elles passent à la ligne s'il manque de place) */
.bubble { position: relative; }
.bubble > .meta { float: right; margin: 8px -2px -4px 12px; line-height: 1; white-space: nowrap; user-select: none; }
.bubble > .meta.over { position: absolute; right: 10px; bottom: 8px; margin: 0; float: none; color: #fff; background: rgba(0,0,0,.4); padding: 3px 7px; border-radius: 10px; }
.bubble > .meta.over .ticks:not(.read) { color: #fff; }
.bubble.media > .meta:not(.over) { margin-right: 6px; margin-bottom: 2px; }
.msg.system { align-self: center; max-width: 90%; }
.msg.system .bubble { background: transparent; box-shadow: none; color: var(--muted); font-size: .88rem; text-align: center; }
.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 6px; width: 160px; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
#typing { font-size: .8rem; color: var(--muted); padding: 0 16px; min-height: 1.2em; }

.composer {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.rec-info { flex: 1; display: flex; align-items: center; gap: 8px; padding: 10px; font-variant-numeric: tabular-nums; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* ---------- Appels ---------- */
.overlay {
  position: fixed; inset: 0;
  z-index: 50;
  background: rgba(10, 16, 18, .96);
  color: #fff;
}
#incoming { display: grid; place-items: center; }
.incoming-card { text-align: center; }
.incoming-card h2 { margin: 16px 0 4px; }
.incoming-card .avatar.big { animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 var(--call-pulse); } 50% { box-shadow: 0 0 0 22px rgba(255,255,255,0); } }
.call-actions { display: flex; gap: 60px; justify-content: center; margin-top: 40px; }
.round {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 0;
  font-size: 1.6rem;
  background: rgba(255,255,255,.15);
  color: #fff;
  cursor: pointer;
}
.round.red { background: var(--danger); }
.round.green { background: var(--ok); }
.round.off { background: #fff; color: #000; }

/* Écran d'appel (façon WhatsApp) : nom en haut, grande photo, panneau de boutons légendés en bas */
#call, #incoming { background: var(--call-bg); color: var(--call-fg); }
#call { display: flex; flex-direction: column; }
.call-top { position: relative; display: flex; justify-content: center; padding: calc(14px + env(safe-area-inset-top)) 70px 4px; min-height: 64px; }
.call-head { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
#call-name { font-size: 1.45rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
#call-status { font-size: .95rem; opacity: .75; margin-top: 2px; }
.call-round-top { position: absolute; left: 14px; top: calc(10px + env(safe-area-inset-top)); width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--call-btn); color: var(--call-fg); display: grid; place-items: center; cursor: pointer; }
.call-round-top svg { width: 26px; height: 26px; }
#call svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#call svg .fill { fill: currentColor; stroke: none; }
#call svg .slash { display: none; }
.call-panel { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 8px; margin: 8px 16px calc(14px + env(safe-area-inset-bottom)); padding: 22px 10px 18px; border-radius: 30px; background: var(--call-panel); box-shadow: var(--call-panel-shadow); }
.call-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: .95rem; text-align: center; }
.call-btn.hidden { display: none; }
.call-btn .round { width: 72px; height: 72px; display: grid; place-items: center; background: var(--call-btn); color: var(--call-fg); }
.call-btn .round svg { width: 30px; height: 30px; }
.call-btn .round.on { background: var(--call-btn-on); color: var(--call-btn-on-fg); }
.call-btn .round.off .slash { display: inline; }
.call-btn .round.off { background: var(--call-btn-on); color: var(--call-btn-on-fg); }
.call-btn.call-end { grid-column: 3; }
.call-btn .round.red { background: #e5173f; color: #fff; }
.call-btn .round.red svg { width: 34px; height: 34px; }
#call-reconnect { align-self: center; margin: 4px 10px; padding: 6px 14px; border-radius: 999px; background: rgba(233, 196, 106, .9); color: #1d1d1d; font-size: .9rem; font-weight: 600; }
#videos {
  flex: 1;
  display: grid;
  gap: 8px;
  padding: 8px;
  grid-template-columns: 1fr;
  grid-auto-rows: 1fr;
  min-height: 0;
}
#videos.n2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 700px) { #videos.n2 { grid-template-columns: 1fr; } }
.tile {
  position: relative;
  background: #1c272b;
  border-radius: 16px;
  overflow: hidden;
  display: grid; place-items: center;
  min-height: 0;
}
.tile video { width: 100%; height: 100%; object-fit: cover; }
.tile .avatar { position: absolute; width: 110px; height: 110px; font-size: 2.6rem; }
/* Appel vocal à deux : la photo de l'autre, en grand au milieu (le nom est en haut) */
.tile:not(.has-video) { background: transparent; }
#videos:not(.n2) .tile:not(.has-video) .avatar { width: min(52vw, 240px); height: min(52vw, 240px); font-size: 5rem; }
#videos:not(.n2) .tile:not(.has-video) .label { display: none; }
#call .tile .avatar.online::after { display: none; }
#call-waiting .avatar { width: min(52vw, 240px); height: min(52vw, 240px); font-size: 5rem; animation: callpulse 1.6s infinite; }
@keyframes callpulse { 0%,100% { box-shadow: 0 0 0 0 var(--call-pulse); } 50% { box-shadow: 0 0 0 26px rgba(255,255,255,0); } }
.tile.has-video .avatar { display: none; }
/* Appel vocal : le lecteur (qui joue le son) reste invisible */
.tile:not(.has-video) video { opacity: 0; }
.tile .label { position: absolute; left: 10px; bottom: 8px; font-size: .85rem; color: #fff; background: rgba(0,0,0,.45); padding: 2px 8px; border-radius: 8px; }
#local-video {
  position: absolute;
  right: 14px; top: calc(86px + env(safe-area-inset-top));
  width: 110px; height: 150px;
  object-fit: cover;
  border-radius: 14px;
  background: #000;
  transform: scaleX(-1);
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
}
#local-video.rear { transform: none; }
/* Application Android : petite fenêtre flottante pendant un appel vidéo (Picture-in-picture) :
   seulement l'image de l'autre (et la sienne en petit), même si l'appel était réduit */
body.pip #call { display: flex !important; position: fixed; inset: 0; z-index: 9999; }
body.pip .call-top, body.pip .call-panel, body.pip #call-reconnect, body.pip .tile .label { display: none; }
body.pip #videos { padding: 0; gap: 2px; }
body.pip .tile { border-radius: 0; }
body.pip #videos:not(.n2) .tile:not(.has-video) .avatar { width: 45vmin; height: 45vmin; font-size: 18vmin; }
body.pip #local-video { top: auto; bottom: 6px; right: 6px; width: 28vw; height: 38vw; border-radius: 6px; }

#viewer { display: grid; place-items: center; cursor: zoom-out; }
#viewer { grid-template-rows: 1fr auto; }
#viewer img { max-width: 100%; max-height: 100%; align-self: center; justify-self: center; }
#viewer img.profile { width: min(80vw, 420px); height: min(80vw, 420px); max-height: 70vh; object-fit: cover; border-radius: 50%; }
#viewer video { max-width: 100%; max-height: 100%; align-self: center; justify-self: center; background: #000; }
#viewer-close { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 12px; z-index: 2; color: #fff; font-size: 1.5rem; background: rgba(0,0,0,.35); border-radius: 50%; width: 44px; height: 44px; }
/* Vidéo dans une conversation : vignette, gros ▶ et durée (comme WhatsApp) */
.video-thumb { position: relative; display: block; cursor: pointer; background: #000; border-radius: 14px; overflow: hidden; min-width: 160px; min-height: 120px; }
.video-thumb { max-width: 100%; }
.video-thumb video, .video-thumb .video-shot { display: block; width: 100%; height: 100%; max-height: none; object-fit: cover; pointer-events: none; border-radius: 0; }
.video-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 56px; height: 56px; border-radius: 50%; background: rgba(0,0,0,.55); display: grid; place-items: center; }
.video-play svg { width: 30px; height: 30px; fill: #fff; margin-left: 3px; }
.video-dur { position: absolute; left: 8px; bottom: 6px; color: #fff; font-size: .8rem; font-weight: 600; text-shadow: 0 1px 2px rgba(0,0,0,.8); }
.video-dur:empty { display: none; }
#viewer-caption { color: #fff; font-size: 1.3rem; font-weight: 700; text-align: center; padding: 12px 12px calc(24px + env(safe-area-inset-bottom)); }
#viewer-caption:empty { display: none; }
/* Galerie des photos d'une conversation (balayer, double appui pour zoomer) */
#viewer-head { display: none; }
#viewer.gallery { cursor: default; touch-action: none; overflow: hidden; }
/* Bande de 3 photos (précédente, actuelle, suivante) qui suit le doigt */
.gstrip { display: none; }
#viewer.gallery > img { display: none; }
#viewer.gallery .gstrip {
  display: flex; position: absolute; top: 0; left: 0; height: 100%; width: 300vw; will-change: transform;
}
.gslide { width: 100vw; height: 100%; flex: 0 0 100vw; display: grid; place-items: center; overflow: hidden; }
.gslide img { max-width: 100%; max-height: calc(100dvh - 120px); will-change: transform; user-select: none; -webkit-user-drag: none; }
.gslide img:not([src]) { display: none; }
#viewer.gallery #viewer-head {
  display: block; position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 14px; right: 70px; z-index: 2;
  color: #fff; font-weight: 600; font-size: .95rem; line-height: 44px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0,0,0,.8);
}
#viewer.gallery #viewer-caption { font-size: 1rem; font-weight: 500; position: relative; z-index: 2; }
#viewer.gallery #viewer-head, #viewer.gallery #viewer-close, #viewer.gallery #viewer-caption { transition: opacity .2s; }
#viewer.gallery.chrome-off #viewer-head, #viewer.gallery.chrome-off #viewer-close, #viewer.gallery.chrome-off #viewer-caption { opacity: 0; pointer-events: none; }
.me { cursor: pointer; border-radius: 12px; }
#chat-avatar, #members-list .avatar { cursor: pointer; }
.msg.deleted .bubble { font-style: italic; color: var(--muted); }

/* ---------- Fenêtres ---------- */
dialog {
  border: 0;
  border-radius: 20px;
  padding: 0;
  width: min(440px, calc(100% - 24px));
  background: var(--panel);
  color: var(--text);
}
dialog::backdrop { background: rgba(0,0,0,.45); }
.dialog-body { padding: 20px; display: grid; gap: 12px; max-height: 85vh; max-height: 85dvh; overflow-y: auto; }
.dialog-body h2, .dialog-body h3 { margin: 0; }
.dialog-body section { display: grid; gap: 8px; }
#add-member-form { display: grid; gap: 8px; }
#invite-create { display: grid; gap: 8px; }
#invite-result { display: grid; gap: 8px; }
#invites-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
#invites-list li { display: flex; align-items: center; gap: 8px; font-size: .88rem; }
#invites-list li span { flex: 1; }
#members-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
#members-list li { display: flex; align-items: center; gap: 10px; }
#members-list li span.grow { flex: 1; }
#group-members label { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
#group-members input { width: auto; }
.row { display: flex; gap: 8px; justify-content: flex-end; }

.fatal { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: grid; place-items: center; padding: 16px; text-align: center; }
.fatal .card { gap: 10px; }
.fatal #fatal-detail { word-break: break-word; font-size: .75rem; }
html.dialog-polyfill dialog:not([open]) { display: none; }
html.dialog-polyfill dialog[open] {
  display: block; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 60; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45);
}

#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: #222; color: #fff;
  padding: 10px 16px; border-radius: 12px;
  z-index: 100; max-width: 90%;
}
/* Au premier plan (popover), par-dessus les fenêtres ouvertes : on garde la même place */
#toast[popover] { inset: auto; left: 50%; bottom: 90px; margin: 0; border: 0; overflow: visible; }
#toast.hidden { display: none; }
.thanks-body { text-align: center; }
.thanks-heart { font-size: 3.5rem; line-height: 1; margin: 6px 0 4px; animation: thanksbeat 1.2s ease-in-out 2; }
@keyframes thanksbeat { 0%,100% { transform: scale(1); } 40% { transform: scale(1.25); } }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  #sidebar { width: 100%; border-right: 0; }
  #chat { display: none; }
  #app.in-chat #sidebar { display: none; }
  #app.in-chat #chat { display: flex; }
  #back-btn { display: inline-grid; }
}

/* ---------- Photo de profil ---------- */
.avatar.photo { background-size: cover !important; background-position: center !important; }
.avatar-row { display: flex; align-items: center; gap: 16px; }
.avatar-row .col { display: grid; gap: 8px; }

/* ---------- Fond d'écran ---------- */
#wallpaper-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.wp-choice {
  height: 84px; border-radius: 14px; border: 3px solid transparent; cursor: pointer;
  display: flex; align-items: flex-end; justify-content: center; padding: 4px;
  background-size: cover !important; box-shadow: inset 0 0 0 1px var(--line);
}
.wp-choice span { font-size: .72rem; background: rgba(255,255,255,.85); color: #222; border-radius: 6px; padding: 1px 6px; }
.wp-choice.active { border-color: var(--accent); }
.has-wallpaper .day,
.has-wallpaper .msg.system .bubble,
.has-wallpaper .author {
  /* Pastilles (dates, appels, auteurs) aux couleurs de l'appli, lisibles sur n'importe quel fond */
  background: color-mix(in srgb, var(--panel) 90%, transparent); color: var(--text); border-radius: 10px;
  padding: 3px 10px; align-self: flex-start; box-shadow: 0 1px 2px rgba(0,0,0,.18);
}
.has-wallpaper .day, .has-wallpaper .msg.system .bubble { align-self: center; }
.has-wallpaper .msg.system .bubble { color: var(--muted); }
.has-wallpaper .bubble { box-shadow: 0 1px 2px rgba(0,0,0,.22); }
.has-wallpaper .msg.theirs .bubble { background: var(--theirs); }

#messages { container-type: inline-size; } /* largeur de référence des photos / vidéos (cqw) */
#messages.settling { visibility: hidden; }
#wallpaper-progress { display: grid; gap: 6px; margin-top: 10px; font-size: .9rem; }
#wallpaper-progress.hidden { display: none; }
#wallpaper-progress .progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
#wallpaper-progress .progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* ---------- Réactions et menu d'un message ---------- */
/* Qui a réagi */
.reaction-list { display: grid; gap: 2px; margin: 4px 0 12px; }
.reaction-row { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border: 0; border-radius: 12px; background: transparent; color: inherit; font: inherit; text-align: left; }
.reaction-row:not(:disabled) { cursor: pointer; }
.reaction-row:not(:disabled):hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.reaction-row:disabled { opacity: 1; }
.reaction-row .avatar { width: 40px; height: 40px; flex: none; }
.reaction-row .who { flex: 1; display: grid; min-width: 0; }
.reaction-row .who small { color: var(--muted); }
.reaction-row .emoji { font-size: 1.5rem; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin: -6px 8px 0; position: relative; z-index: 1; }
.reaction {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 999px; padding: 1px 7px; font-size: .85rem; cursor: pointer;
}
.reaction.mine { border-color: var(--accent); background: var(--mine); }
.msg.selected .bubble { outline: 2px solid var(--accent); }
#msg-menu {
  position: fixed; z-index: 70; background: var(--panel); color: var(--text);
  border-radius: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.25); padding: 6px; display: grid; gap: 4px;
}
.menu-reactions { display: flex; gap: 2px; }
.menu-reactions button { font-size: 1.6rem; background: none; border: 0; border-radius: 12px; padding: 4px 6px; cursor: pointer; }
.menu-reactions button.mine, .menu-reactions button:hover { background: var(--bg); }
.menu-actions { display: grid; border-top: 1px solid var(--line); padding-top: 4px; }
.menu-actions button { background: none; border: 0; color: var(--text); text-align: left; padding: 9px 10px; border-radius: 10px; font: inherit; cursor: pointer; }
.menu-actions button:hover { background: var(--bg); }
#edit-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px; background: var(--mine); font-size: .88rem; border-top: 1px solid var(--line);
}
.watch-btn { display: block; margin-top: 6px; background: #ff0033; color: #fff; }

/* ---------- Appel réduit ---------- */
#call-mini {
  position: fixed; z-index: 65; bottom: calc(84px + env(safe-area-inset-bottom)); right: 12px;
  display: flex; align-items: center; gap: 4px; background: var(--ok); color: #fff;
  border-radius: 999px; padding: 4px; box-shadow: 0 4px 16px rgba(0,0,0,.3); max-width: calc(100% - 24px);
}
#call-mini { touch-action: none; user-select: none; -webkit-user-select: none; transition: left .2s, right .2s, top .2s; }
#call-mini.dragging { transition: none; opacity: .9; }
#call-mini button { border: 0; background: none; color: #fff; font: inherit; cursor: pointer; padding: 6px 10px; border-radius: 999px; }
#call-mini-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .88rem; }
#call-mini-hangup { background: var(--danger) !important; width: 34px; height: 34px; padding: 0 !important; }

/* ---------- Activités ---------- */
#activity-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; background: #fff4d6; color: #5c4800; font-size: .92rem;
}
#activity {
  position: fixed; inset: 0; z-index: 40; background: var(--bg); color: var(--text);
  display: flex; flex-direction: column;
}
#activity header { padding-top: calc(10px + env(safe-area-inset-top)); }
#activity-title { flex: 1; }
#activity-presence {
  padding: 6px 12px; font-size: .9rem; text-align: center; background: #fff4d6; color: #5c4800;
}
#activity-presence.here { background: #e3f6e8; color: #1d5b2c; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #activity-presence { background: #3a3218; color: #f3dfa2; }
  :root:not([data-theme="light"]) #activity-presence.here { background: #193824; color: #bfe8c9; }
}
:root[data-theme="dark"] #activity-presence { background: #3a3218; color: #f3dfa2; }
:root[data-theme="dark"] #activity-presence.here { background: #193824; color: #bfe8c9; }
#activity-body {
  flex: 1; overflow-y: auto; padding: 12px 12px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
#activity-invite {
  position: fixed; z-index: 45; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(420px, calc(100% - 24px)); background: var(--panel); color: var(--text);
  border-radius: 18px; padding: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); display: grid; gap: 10px; font-weight: 600;
}
.activity-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.games-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.game-choice {
  display: grid; justify-items: center; gap: 6px; padding: 14px 6px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: .85rem; cursor: pointer;
}
.game-choice span { font-size: 1.8rem; }
.big-btn { font-size: 1.1rem; padding: 14px 22px; }
.center { text-align: center; }

.game-head { display: grid; gap: 6px; text-align: center; width: 100%; }
.game-score { font-weight: 600; }
.game-status { font-size: 1.15rem; font-weight: 700; text-align: center; padding: 6px 12px; border-radius: 12px; }
.game-status.my-turn { background: var(--mine); }

.ttt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: min(360px, 92vw); }
.ttt-cell {
  aspect-ratio: 1; font-size: clamp(2.2rem, 12vw, 3.6rem); border: 0; border-radius: 18px;
  background: var(--panel); box-shadow: 0 2px 6px rgba(0,0,0,.08); cursor: pointer;
}
.ttt-cell.win { background: #ffe082; }

.c4-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 8px;
  background: #1d4ed8; border-radius: 16px; width: min(460px, 94vw); overflow: hidden;
}
.c4-col { display: grid; gap: 4px; border: 0; background: none; padding: 0; cursor: pointer; border-radius: 10px; }
.c4-col:hover { background: rgba(255,255,255,.12); }
.c4-cell { aspect-ratio: 1; border-radius: 50%; background: var(--bg); box-shadow: inset 0 2px 4px rgba(0,0,0,.3); }
.c4-cell.red { background: #e63946; }
.c4-cell.yellow { background: #ffd60a; }
.c4-cell.win { box-shadow: 0 0 0 3px #fff, inset 0 2px 4px rgba(0,0,0,.3); }
.c4-cell.drop { animation: c4drop .35s ease-in; }
@keyframes c4drop { from { transform: translateY(calc(var(--drop-rows) * -110%)); } to { transform: none; } }

/* Bataille navale */
.bs-sea { display: grid; gap: 6px; justify-items: center; }
.bs-title { font-weight: 600; font-size: .95rem; }
.bs-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; padding: 6px;
  background: #1d6fe0; border-radius: 14px; width: min(340px, 90vw);
}
.bs-sea.mine .bs-grid { width: min(220px, 60vw); background: #4c8fe8; }
.bs-sea.mine.big .bs-grid { width: min(340px, 90vw); }
.bs-cell {
  aspect-ratio: 1; border: 0; border-radius: 6px; padding: 0; background: #9cc8ff;
  display: grid; place-items: center; font-size: clamp(.9rem, 5vw, 1.5rem); line-height: 1; color: inherit;
}
.bs-sea.mine .bs-cell { font-size: clamp(.7rem, 3.4vw, 1.1rem); }
.bs-sea.mine.big .bs-cell { font-size: clamp(.9rem, 5vw, 1.5rem); }
.bs-cell.ship { background: #6b7c93; }
.bs-cell.miss { background: #cfe3ff; }
.bs-cell.hit { background: #ffb4a2; }
.bs-cell.sunk { background: #e63946; }
.bs-sea.can-shoot .bs-cell:not(.hit):not(.miss):not(.sunk) { cursor: crosshair; }
.bs-sea.can-shoot .bs-cell:not(.hit):not(.miss):not(.sunk):active { background: #ffd60a; }
.bs-buttons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.draw-scores { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; font-size: .9rem; }
.draw-scores .drawer { font-weight: 700; }
.word-choices { display: grid; gap: 10px; width: min(360px, 100%); }
.word-own { width: min(360px, 100%); display: grid; gap: 6px; }
.word-own .row { display: flex; gap: 8px; }
.word-own input { flex: 1; min-width: 0; }
.canvas-wrap { width: 100%; max-width: 640px; display: flex; justify-content: center; }
.draw-canvas { background: #fff; border-radius: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.12); touch-action: none; }
.draw-canvas.can-draw { cursor: crosshair; }
.draw-tools { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; }
.draw-tools .color { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--panel); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.draw-tools .color.active { box-shadow: 0 0 0 3px var(--accent); }
.draw-tools .size { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); display: grid; place-items: center; cursor: pointer; }
.draw-tools .size span { display: block; background: var(--text); border-radius: 50%; }
.draw-tools .size.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.draw-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.guess-form { display: flex; gap: 8px; width: min(420px, 100%); }
.hint { font-size: 1.1rem; letter-spacing: .1em; }
.guesses { display: grid; gap: 2px; font-size: .9rem; text-align: center; }
.guesses .ok { font-weight: 700; color: var(--ok); }

.yt-holder { position: relative; width: 100%; max-width: 900px; display: flex; flex-direction: column; background: #000; border-radius: 12px; overflow: hidden; }
.yt-video { position: relative; width: 100%; aspect-ratio: 16 / 9; }
.yt-video iframe, .yt-video > div { position: absolute; inset: 0; width: 100%; height: 100%; }
/* Barre sous la vidéo : réactions + plein écran (jamais par-dessus les boutons de YouTube) */
.yt-bar { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 4px 6px; background: #111; }
.yt-reacts { display: flex; gap: 2px; flex-wrap: wrap; }
.yt-react-btn {
  width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; font-size: 1.35rem;
  line-height: 1; cursor: pointer; padding: 0;
}
.yt-react-btn:active { background: rgba(255,255,255,.18); transform: scale(1.15); }
/* Emojis qui s'envolent par-dessus la vidéo */
.yt-video > .yt-react-layer { z-index: 4; pointer-events: none; overflow: hidden; }
.yt-react-fly {
  position: absolute; bottom: 8%; display: grid; justify-items: center; gap: 2px;
  animation: yt-fly 2.6s ease-out forwards;
}
.yt-react-emoji { font-size: clamp(2rem, 9vw, 3.4rem); line-height: 1; filter: drop-shadow(0 2px 3px rgba(0,0,0,.5)); }
.yt-react-who { font-size: .72rem; color: #fff; background: rgba(0,0,0,.55); padding: 1px 6px; border-radius: 999px; white-space: nowrap; }
@keyframes yt-fly {
  0% { transform: translateY(20px) scale(.6); opacity: 0; }
  12% { transform: translateY(0) scale(1.1); opacity: 1; }
  75% { opacity: 1; }
  100% { transform: translateY(-160%) scale(1); opacity: 0; }
}
.yt-tap {
  position: absolute; inset: auto 12px 12px 12px; z-index: 2; border: 0; border-radius: 12px;
  background: rgba(255,0,51,.92); color: #fff; font: inherit; font-weight: 700; padding: 12px; cursor: pointer;
}
.yt-info { text-align: center; max-width: 600px; }
.yt-change { display: flex; gap: 8px; width: min(600px, 100%); }

/* ---------- Fête de fin de partie ---------- */
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 90; pointer-events: none; }
.celebrate {
  position: fixed; z-index: 91; left: 50%; top: 42%; transform: translate(-50%, -50%);
  background: var(--panel); color: var(--text); border-radius: 26px; padding: 22px 30px;
  box-shadow: 0 16px 50px rgba(0,0,0,.3); text-align: center; min-width: min(300px, 86vw);
  animation: celebrate-in .55s cubic-bezier(.2, 1.6, .4, 1) both;
}
.celebrate.out { animation: celebrate-out .45s ease-in both; }
.celebrate-emoji { font-size: 4.5rem; line-height: 1.1; animation: celebrate-bounce .8s ease-in-out .3s 2; }
.celebrate-title { font-size: 1.5rem; font-weight: 800; margin-top: 6px; }
.celebrate-sub { font-size: 1.15rem; margin-top: 4px; color: var(--muted); }
.celebrate.win .celebrate-title { color: var(--accent); }
@keyframes celebrate-in { from { transform: translate(-50%, -50%) scale(.3); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
@keyframes celebrate-out { to { transform: translate(-50%, -50%) scale(.8); opacity: 0; } }
@keyframes celebrate-bounce { 0%, 100% { transform: translateY(0) rotate(0); } 30% { transform: translateY(-18px) rotate(-12deg); } 60% { transform: translateY(0) rotate(8deg); } }
@media (prefers-reduced-motion: reduce) { .celebrate, .celebrate-emoji { animation: none; } }

/* ---------- « écrit… » ---------- */
.typing-text { color: var(--accent) !important; font-style: italic; }
#chat-sub.typing-text { font-weight: 600; }
.typing-dots { display: inline-flex; align-items: center; gap: 5px; padding: 12px 14px; }
.typing-dots i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: block;
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dots i:nth-of-type(2) { animation-delay: .15s; }
.typing-dots i:nth-of-type(3) { animation-delay: .3s; }
.typing-mic { font-size: .95rem; margin-right: 2px; }
@keyframes typing-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* ---------- Amis, groupes ---------- */
.members-title { font-weight: 700; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; margin-top: 6px; }
#chat-name, #chat-sub { cursor: pointer; }
.group-head { display: flex; align-items: center; gap: 14px; }
.group-head .avatar.big { cursor: pointer; flex: none; }
.group-head h2 { margin: 0; }
.row.wrap { flex-wrap: wrap; justify-content: flex-start; }
#group-info-members { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
#group-info-members li { display: flex; align-items: center; gap: 10px; }
#group-add { display: grid; gap: 6px; }
.add-person { display: flex; align-items: center; gap: 10px; text-align: left; border-radius: 14px; }
.add-person .avatar { width: 32px; height: 32px; font-size: .85rem; }

/* ---------- Recadrage ---------- */
#crop { display: grid; place-items: center; z-index: 95; padding: 16px; }
.crop-box { width: min(420px, 100%); display: grid; gap: 12px; text-align: center; color: #fff; }
.crop-box h2 { margin: 0; }
.crop-box .muted { color: #cfd8dc; }
#crop-frame {
  position: relative; width: min(86vw, 58vh, 380px); aspect-ratio: 1; margin: 0 auto;
  overflow: hidden; touch-action: none; cursor: grab; background: #000; border-radius: 12px;
}
#crop-img { position: absolute; left: 0; top: 0; max-width: none; user-select: none; -webkit-user-drag: none; pointer-events: none; transform-origin: 0 0; }
.crop-mask { position: absolute; inset: 0; pointer-events: none; border-radius: 50%; box-shadow: 0 0 0 999px rgba(0,0,0,.55); outline: 2px solid rgba(255,255,255,.8); outline-offset: -2px; }
#crop-frame.rect .crop-mask { border-radius: 0; }
.crop-zoom { display: flex; align-items: center; gap: 10px; font-size: 1.2rem; }
.crop-zoom input { flex: 1; padding: 0; }

/* ---------- YouTube ensemble : présence et départ commun ---------- */
.yt-presence { font-weight: 600; font-size: .95rem; text-align: center; }
.yt-presence.alone { color: var(--muted); }
.yt-wait {
  background: #fff4d6; color: #5c4800; border-radius: 12px; padding: 8px 12px;
  font-size: .9rem; text-align: center; max-width: 600px;
}
.yt-countdown {
  position: absolute; inset: 0; z-index: 3; display: grid; place-items: center;
  background: rgba(0,0,0,.55); color: #fff; font-size: 5rem; font-weight: 800;
  pointer-events: none; animation: yt-pop 1s ease-out infinite;
}
@keyframes yt-pop { from { transform: scale(1.25); opacity: .6; } 30% { transform: scale(1); opacity: 1; } }

#invites-list li { flex-wrap: wrap; }
.small-select { width: auto; padding: 4px 8px; font-size: .82rem; border-radius: 999px; }

/* Dessine et devine : palette et gomme */
.draw-palette { display: grid; grid-template-columns: repeat(8, 34px); gap: 6px; justify-content: center; width: 100%; }
.draw-tools .eraser {
  border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 999px;
  padding: 6px 12px; font: inherit; font-size: .9rem; cursor: pointer;
}
.draw-tools .eraser.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.draw-tools .color[style*="255, 243, 176"], .draw-tools .color[style*="#fff3b0"] { box-shadow: 0 0 0 1px #ccc; }

/* ---------- Dictée ---------- */
.games-grid .dictee-choice { grid-column: 1 / -1; }
.dictee-list { display: flex; align-items: center; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 6px; }
.dictee-list .grow { flex: 1; min-width: 0; }
.dictee-list .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#dictee-editor, #dictee-start { display: grid; gap: 8px; }
#dictee-editor.hidden, #dictee-start.hidden { display: none; }
.dictee-who { display: flex; align-items: center; gap: 8px; }
.dictee-who select { flex: 1; }
.dictee-head { width: min(480px, 100%); display: grid; gap: 6px; text-align: center; }
.dictee-title { font-weight: 700; }
.dictee-bar { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; }
.dictee-bar > div { height: 100%; background: var(--accent); transition: width .3s; }
.dictee-word { font-size: 1.8rem; font-weight: 800; letter-spacing: .04em; text-align: center; }
.dictee-word.big { font-size: clamp(2rem, 11vw, 3.4rem); padding: 12px 0; }
.dictee-timer { width: min(360px, 90%); height: 8px; border-radius: 4px; background: var(--accent); transform-origin: left; animation: dictee-shrink linear forwards; }
@keyframes dictee-shrink { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.dictee-form { display: flex; gap: 8px; width: min(420px, 100%); }
.dictee-form input { font-size: 1.4rem; text-align: center; }
.center-row { justify-content: center; }
.dictee-bravo { font-size: 2.4rem; font-weight: 800; color: var(--ok); padding: 30px 0; animation: celebrate-in .4s both; }
.dictee-oops { font-weight: 700; font-size: 1.1rem; }
.dictee-correction { font-size: clamp(1.8rem, 10vw, 2.6rem); font-weight: 800; letter-spacing: .06em; }
.dictee-correction .ok { color: var(--ok); }
.dictee-correction .bad { color: var(--danger); text-decoration: underline; }
.dictee-correction .sp { display: inline-block; width: .4em; }
.dictee-results { display: grid; gap: 10px; justify-items: center; text-align: center; }
.dictee-stars { font-size: 3rem; }
.dictee-wrong { display: grid; gap: 4px; }
.dictee-wrong .dictee-correction { font-size: 1.4rem; }
.dictee-wrong-row { display: flex; align-items: baseline; gap: 8px; justify-content: center; }
.dictee-watch { display: grid; gap: 8px; justify-items: center; }
.dictee-live { font-size: 1.2rem; font-weight: 600; min-height: 1.5em; }
.dictee-history { display: grid; gap: 2px; text-align: center; font-size: .95rem; }
.dictee-history .bad { color: var(--danger); }

/* ---------- Pas de zoom : comportement d'appli ---------- */
html { touch-action: manipulation; }
/* iPhone zoome sur les champs dont le texte fait moins de 16px */
input, textarea, select { font-size: max(16px, 1em); }

/* ---------- Carte « Installer + notifications » ---------- */
#app-card, #email-card { display: flex; align-items: center; gap: 10px; margin: 8px 10px; padding: 10px 12px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 16%, var(--panel)); }
#app-card.hidden, #email-card.hidden { display: none; }
#app-card .setup-icon, #email-card .setup-icon { font-size: 1.6rem; }
#app-card .grow, #email-card .grow { flex: 1; display: grid; min-width: 0; }
#app-card small, #email-card small { opacity: .75; }
#setup-card {
  margin: 10px; padding: 12px; border-radius: 14px;
  background: linear-gradient(135deg, #fff4d6, #ffe3ec); color: #4a2a00;
  border: 2px solid #ffb74d; display: grid; gap: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
  animation: setup-pop .5s ease-out;
}
#setup-card.hidden { display: none; }
#setup-card .setup-step { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.7); border-radius: 10px; padding: 8px; }
#setup-card .setup-step.hidden { display: none; }
#setup-card .setup-icon { font-size: 1.6rem; }
#setup-card .grow { flex: 1; display: grid; }
#setup-card small { opacity: .75; }
#setup-card #setup-later { justify-self: end; color: inherit; }
@keyframes setup-pop { from { transform: scale(.95); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Accusés de réception ---------- */
.ticks { margin-left: 4px; letter-spacing: -3px; font-weight: 700; }
.ticks.sent, .ticks.delivered { color: var(--muted); }
.ticks.read { color: #34b7f1; }
#msginfo-list h4 { margin: 14px 0 6px; font-size: .9rem; opacity: .8; }
.msginfo-msg { align-self: center; margin: 4px auto 6px; max-width: 85%; width: fit-content; padding: 8px 14px; border-radius: 18px; background: var(--theirs, #eee); border: 1px solid var(--line); overflow-wrap: anywhere; }
.msginfo-msg.mine { background: var(--mine); }
#msginfo-list { display: flex; flex-direction: column; }
.msginfo-card { border-radius: 14px; background: var(--card, rgba(127,127,127,.08)); padding: 4px 12px; }
.msginfo-state { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.msginfo-state + .msginfo-state { border-top: 1px solid var(--line); }
.msginfo-ico { width: 26px; text-align: center; font-weight: 700; letter-spacing: -3px; color: var(--muted); }
.msginfo-state.read .msginfo-ico, .msginfo-sub.read { color: #34b7f1; }
.msginfo-state.pending { opacity: .6; }
.msginfo-sub { display: block; }
.backup-date { flex-direction: column; align-items: stretch; }
.backup-files { padding: 4px 0 8px 8px; }
.backup-files .btn.small { padding: 4px 10px; }
.app-version.old { color: var(--danger); opacity: 1; }
.msginfo-state .grow { flex: 1; }
.msginfo-card + .msginfo-card { margin-top: 8px; }
.msginfo-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.msginfo-row .avatar { width: 32px; height: 32px; font-size: .9rem; }
.msginfo-row .grow { flex: 1; }

/* Dessine et devine : réponses en cours d'écriture */
.guess-typing { display: grid; gap: 2px; font-size: .9rem; text-align: center; color: var(--muted); font-style: italic; }
.guess-typing.hidden { display: none; }

/* ---------- YouTube ensemble : plein écran ---------- */
.yt-fs {
  flex: 0 0 auto; width: 40px; height: 40px;
  border: 0; border-radius: 10px; background: rgba(255,255,255,.12); color: #fff;
  font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.yt-video > .yt-overlay {
  position: absolute; inset: auto 50% 12px auto; transform: translateX(50%); width: auto; height: auto;
  z-index: 3; background: rgba(0,0,0,.7); color: #fff; padding: 6px 12px; border-radius: 999px;
  font-size: .9rem; white-space: nowrap; pointer-events: none;
}
.yt-video > .yt-overlay.hidden { display: none; }
/* Fin de vidéo : suggestions par-dessus l'écran de fin de YouTube */
.yt-video > .yt-end {
  z-index: 5; background: rgba(0,0,0,.88); color: #fff; display: flex; flex-direction: column;
  justify-content: center; gap: 8px; padding: 10px 0; overflow: hidden;
}
.yt-video > .yt-end.hidden { display: none; }
.yt-end-title { font-weight: 700; text-align: center; padding: 0 12px; font-size: clamp(.9rem, 3.6vw, 1.2rem); }
.yt-end-hint { text-align: center; font-size: .8rem; opacity: .75; padding: 0 12px; }
.yt-end-row { display: flex; gap: 10px; overflow-x: auto; padding: 2px 12px; scroll-snap-type: x mandatory; }
.yt-end-card {
  flex: 0 0 auto; width: clamp(110px, 32vw, 200px); display: grid; gap: 3px; align-content: start;
  border: 0; border-radius: 10px; padding: 0; background: #1f1f1f; color: #fff; text-align: left;
  cursor: pointer; overflow: hidden; scroll-snap-align: start;
}
.yt-end-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: #333; }
.yt-end-name { font-size: .78rem; line-height: 1.2; padding: 0 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.yt-end-channel { font-size: .7rem; opacity: .7; padding: 0 6px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.yt-end-card.again {
  width: clamp(80px, 22vw, 120px); place-content: center; text-align: center; white-space: pre-line;
  font-size: 1rem; background: #2a9d8f;
}
/* Vrai plein écran (Android, ordinateur) */
.yt-holder:fullscreen { max-width: none; width: 100vw; height: 100vh; aspect-ratio: auto; border-radius: 0; }
.yt-holder:-webkit-full-screen { max-width: none; width: 100vw; height: 100vh; aspect-ratio: auto; border-radius: 0; }
/* En plein écran : vidéo au centre, barre en colonne à droite (dans les bandes noires) */
.yt-holder:fullscreen, .yt-holder:-webkit-full-screen, .yt-holder.yt-full { flex-direction: row; align-items: center; }
.yt-holder:fullscreen .yt-video, .yt-holder.yt-full .yt-video { flex: 1; height: 100%; aspect-ratio: auto; }
.yt-holder:-webkit-full-screen .yt-video { flex: 1; height: 100%; aspect-ratio: auto; }
.yt-holder:fullscreen .yt-bar, .yt-holder.yt-full .yt-bar { flex-direction: column; height: 100%; justify-content: center; padding: 6px 4px; background: #000; }
.yt-holder:-webkit-full-screen .yt-bar { flex-direction: column; height: 100%; justify-content: center; padding: 6px 4px; background: #000; }
.yt-holder:fullscreen .yt-reacts, .yt-holder.yt-full .yt-reacts { flex-direction: column; }
.yt-holder:-webkit-full-screen .yt-reacts { flex-direction: column; }
/* iPhone : la vidéo prend tout l'écran de l'appli */
.yt-holder.yt-full {
  position: fixed; inset: 0; z-index: 200; max-width: none; width: 100vw; height: 100dvh;
  aspect-ratio: auto; border-radius: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- Dictée : clavier de l'appli (style Gboard, sans suggestions) ---------- */
:root { --kb-bg: #e8eaed; --kb-key: #ffffff; --kb-special: #c9ccd1; --kb-text: #202124; --kb-hint: #80868b; --kb-accent: #1a73e8; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --kb-bg: #202124; --kb-key: #3c4043; --kb-special: #5f6368; --kb-text: #e8eaed; --kb-hint: #9aa0a6; --kb-accent: #8ab4f8; }
}
:root[data-theme="dark"] { --kb-bg: #202124; --kb-key: #3c4043; --kb-special: #5f6368; --kb-text: #e8eaed; --kb-hint: #9aa0a6; --kb-accent: #8ab4f8; }
.dictee-input { display: flex; flex-direction: column; gap: 10px; align-items: center; width: 100%; }
.dictee-input.with-kb { flex: 1; }
.dictee-kb {
  position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); margin: auto -12px calc(-16px - env(safe-area-inset-bottom));
  width: calc(100% + 24px); max-width: 720px; box-sizing: border-box;
  display: grid; gap: 10px; padding: 10px 4px calc(14px + env(safe-area-inset-bottom));
  background: var(--kb-bg); user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.dictee-kb-row { display: flex; gap: 5px; justify-content: center; }
.dictee-key {
  position: relative; flex: 1 1 0; max-width: 64px; min-width: 0; height: 50px; border: 0; border-radius: 7px;
  background: var(--kb-key); color: var(--kb-text); font-family: Roboto, system-ui, sans-serif;
  font-size: 1.45rem; font-weight: 400; padding: 0; cursor: pointer;
  box-shadow: 0 1px 1px rgba(0,0,0,.18); -webkit-tap-highlight-color: transparent;
}
.dictee-key .hint { position: absolute; top: 2px; right: 5px; font-size: .7rem; color: var(--kb-hint); }
.dictee-key:active, .dictee-key.down { filter: brightness(.88); }
.dictee-key.shift, .dictee-key.erase, .dictee-key.layer, .dictee-key.enter { background: var(--kb-special); flex: 1.5 1 0; max-width: 96px; font-size: 1.35rem; }
.dictee-key.layer { font-size: 1rem; }
.dictee-key.shift.on { color: var(--kb-accent); }
.dictee-key.space { flex: 5 1 0; max-width: 340px; font-size: 1rem; }
.dictee-kb-popup {
  position: absolute; z-index: 5; display: flex; gap: 4px; padding: 4px; border-radius: 10px;
  background: var(--kb-key); box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.dictee-kb-popup .dictee-key { width: 44px; flex: none; background: var(--kb-bg); }
.link-btn { border: 0; background: none; font: inherit; text-decoration: underline; cursor: pointer; padding: 4px; }
.chat-title small.wrap { white-space: normal; overflow: hidden; line-height: 1.2; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }

/* Fenêtre de confirmation de l'appli */
#ask-dialog { width: min(420px, calc(100% - 32px)); }
#ask-dialog .ask-text { margin: 0; white-space: pre-line; line-height: 1.4; }
#ask-dialog .ask-field { display: grid; gap: 4px; font-size: .9rem; }
.btn.danger-fill { background: var(--danger); color: #fff; }

/* Menu du trombone : appareil photo, caméra, galerie */
.composer { position: relative; }
#attach-menu {
  position: absolute; left: 8px; bottom: calc(100% + 6px); z-index: 20;
  display: grid; min-width: 220px; padding: 6px; border-radius: 14px;
  background: var(--panel); color: var(--text); box-shadow: 0 8px 28px rgba(0,0,0,.25);
}
#attach-menu.hidden { display: none; }
#attach-menu button {
  display: flex; align-items: center; gap: 12px; border: 0; background: none; color: inherit;
  font: inherit; font-size: 1.05rem; padding: 12px; border-radius: 10px; text-align: left; cursor: pointer;
}
#attach-menu button:active { background: var(--bg); }
#attach-menu span { font-size: 1.4rem; }

/* Les fenêtres ne dépassent jamais la largeur de l'écran (sinon elles glissent sur le côté) */
.dialog-body { grid-template-columns: minmax(0, 1fr); overflow-x: hidden; }
dialog { max-width: calc(100vw - 24px); overflow-x: hidden; }

/* Choix de l'apparence dans les Réglages */
.theme-choice { display: flex; gap: 6px; }
.theme-choice button { flex: 1; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 12px; padding: 10px 6px; font: inherit; font-size: .92rem; cursor: pointer; }
.theme-choice button.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); font-weight: 700; }
#settings-dialog a { color: var(--accent); }

/* Stockage utilisé */
#storage-info { display: grid; gap: 6px; }
.storage-line { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; color: var(--text); font-size: .92rem; }
.storage-bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.storage-bar > div { height: 100%; background: var(--accent); border-radius: 999px; }
.storage-bar.warn > div { background: var(--danger); }

/* ---------- Réglages rangés : menu de rubriques ---------- */
.settings-head { display: flex; align-items: center; gap: 6px; }
.settings-head h2 { flex: 1; }
.settings-head .icon-btn.hidden { display: none; }
.settings-menu { display: grid; gap: 2px; }
.settings-menu.hidden, .settings-panel.hidden { display: none; }
.settings-menu button {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  border: 0; background: none; color: var(--text); font: inherit; padding: 12px 6px; border-radius: 12px; cursor: pointer;
}
.settings-menu button.hidden { display: none; }
.settings-menu button:active, .settings-menu button:hover { background: var(--bg); }
.settings-menu .ico { font-size: 1.5rem; width: 34px; text-align: center; }
.settings-menu .txt { flex: 1; display: grid; gap: 2px; min-width: 0; }
.settings-menu .txt small { color: var(--muted); font-size: .82rem; }
.settings-menu .chev { color: var(--muted); font-size: 1.5rem; }
.settings-panel { display: grid; gap: 12px; }

/* Partage depuis une autre application (façon WhatsApp) : écran plein, recherche, coches, légende */
#share-dialog.share-sheet { position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0; background: var(--panel); color: var(--text); display: flex; flex-direction: column; }
.share-head { display: flex; align-items: center; gap: 8px; margin: 10px 12px 6px; padding: 4px 6px; border-radius: 999px; background: var(--bg); }
.share-back { font-size: 1.4rem; width: 44px; height: 44px; flex: none; }
.share-search { flex: 1; min-width: 0; border: 0; background: transparent; color: inherit; font: inherit; font-size: 1.1rem; padding: 10px 4px; outline: none; }
.share-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.share-target { display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px 18px; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.share-target.chosen { background: color-mix(in srgb, var(--ok) 22%, transparent); }
.share-av { position: relative; flex: none; }
.share-av .avatar { width: 50px; height: 50px; }
.share-tick { position: absolute; right: -3px; bottom: -3px; width: 22px; height: 22px; border-radius: 50%; background: var(--ok); color: #fff; font-size: .8rem; font-weight: 700; display: none; align-items: center; justify-content: center; border: 2px solid var(--panel); }
.share-target.chosen .share-tick { display: flex; }
.share-text { display: flex; flex-direction: column; min-width: 0; }
.share-text strong { font-size: 1.05rem; }
.share-text small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.share-foot { border-top: 1px solid var(--line); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--panel); }
.share-compose { display: flex; align-items: flex-end; gap: 10px; }
.share-thumb { position: relative; width: 56px; height: 56px; flex: none; border-radius: 10px; overflow: hidden; background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 1.6rem; }
.share-thumb img, .share-thumb video { width: 100%; height: 100%; object-fit: cover; }
.share-count { position: absolute; right: 3px; bottom: 3px; padding: 0 6px; border-radius: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: .8rem; font-weight: 700; }
.share-caption { flex: 1; min-width: 0; box-sizing: border-box; resize: none; min-height: 48px; max-height: 120px; padding: 13px 16px; border: 0; border-radius: 24px; background: var(--bg); color: inherit; font: inherit; font-size: 1.05rem; outline: none; }
.share-bar { display: flex; align-items: center; gap: 12px; margin-top: 10px; min-height: 56px; }
.share-who { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-who.muted { color: var(--muted); font-weight: 400; font-size: .95rem; }
.share-send { width: 56px; height: 56px; flex: none; border: 0; border-radius: 50%; background: var(--ok); color: #fff; font-size: 1.5rem; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.share-send:disabled { opacity: .4; cursor: default; box-shadow: none; }

/* Conditions d'utilisation à accepter */
.terms-check { display: flex; gap: 8px; align-items: flex-start; font-size: 0.92rem; }
.terms-check input { width: auto; margin-top: 3px; }
/* Personnes bloquées, signalements */
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.plain-list li .grow { flex: 1; }
.report-card { border: 1px solid var(--line, #ddd); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.report-card.done { opacity: 0.6; }
.report-card .quote { background: var(--bg); border-radius: 8px; padding: 6px 8px; margin: 6px 0; white-space: pre-wrap; word-break: break-word; }
.report-card img, .report-card video { max-width: 100%; max-height: 240px; border-radius: 8px; display: block; margin: 6px 0; }
.report-card .row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.report-reasons { display: grid; gap: 6px; }
.report-reasons button.on { outline: 2px solid var(--accent, #2a9d8f); }
.msg.hidden-blocked .bubble { font-style: italic; opacity: 0.7; }
#blocked-banner { padding: 8px 12px; text-align: center; font-size: 0.9rem; }
#notif-diag { white-space: pre-line; }

/* Installer l'application (phase de test Google Play) */
.play-steps { padding-left: 20px; margin: 4px 0 10px; display: grid; gap: 12px; }
.play-steps li .btn { display: inline-block; margin-top: 6px; text-decoration: none; }

/* Espaces : sa famille et les familles où l'on est ami(e) */
#spaces-bar { display: flex; gap: 6px; padding: 6px 10px; overflow-x: auto; border-bottom: 1px solid var(--line); background: var(--panel); }
#spaces-bar button { flex: none; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--bg); color: inherit; border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 0.9rem; cursor: pointer; }
#spaces-bar button.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
#spaces-bar .badge { position: static; }

/* Partage d'un lien YouTube : regarder ensemble ou envoyer le lien */
.share-modes { display: flex; gap: 8px; padding: 8px 12px 0; }
.share-mode {
  flex: 1; border: 1px solid var(--border, rgba(0,0,0,.15)); background: var(--panel); color: var(--text);
  border-radius: 999px; padding: 9px 10px; font: inherit; font-size: .92rem; cursor: pointer;
}
.share-mode.on { background: var(--accent, #2a9d8f); border-color: transparent; color: #fff; font-weight: 600; }
.share-compose.hidden { display: none; }

/* Journal replié : « 📋 5 appels manqués de Papa · 14:57–14:58 ▸ » */
.journal { display: contents; }
.journal.folded { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.journal.folded:not(.open) > .msg { display: none; }
.journal-head {
  align-self: center; border: 1px dashed var(--line); border-radius: 10px; padding: 5px 12px; margin: 2px 0;
  background: transparent; color: var(--muted); font: inherit; font-size: .88rem; cursor: pointer; max-width: 90%;
}
.has-wallpaper .journal-head {
  background: color-mix(in srgb, var(--panel) 90%, transparent); border-style: solid; box-shadow: 0 1px 2px rgba(0,0,0,.18);
}

/* À propos et dons */
.about-text p { margin: 0 0 10px; line-height: 1.45; }
.don-list { display: grid; gap: 8px; margin: 8px 0; }
.don-btn { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; }
.don-btn .don-price { font-weight: 700; white-space: nowrap; }
#email-card small { overflow-wrap: anywhere; }
/* Fichier effacé du serveur (gardé 30 jours au plus) */
.gone-note { font-size: .85rem; opacity: .8; padding: 8px 4px; max-width: 260px; white-space: normal; }
/* Album de famille */
#album-dialog .dialog-body { max-width: 760px; }
.album-month { margin: 14px 0 6px; font-size: 1rem; }
.album-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 4px; }
.album-tile { position: relative; padding: 0; border: 0; aspect-ratio: 1; overflow: hidden; border-radius: 6px; background: var(--panel); cursor: pointer; }
.album-tile img, .album-tile video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.album-play { position: absolute; inset: auto 6px 6px auto; color: #fff; font-size: .9rem; background: rgba(0,0,0,.5); border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center; }
.album-video { display: grid; place-items: center; width: 100%; height: 100%; font-size: 2rem; }
/* Organisation familiale */
.orga-day { margin: 12px 0 4px; font-size: .95rem; }
.orga-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid color-mix(in srgb, var(--text) 8%, transparent); }
.orga-item .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.orga-item.done .grow { opacity: .55; text-decoration: line-through; }
.orga-add { display: grid; gap: 6px; margin-top: 14px; }
.orga-add input, .orga-line input { width: 100%; }
.orga-line { display: flex; gap: 6px; margin-bottom: 8px; }
.orga-chip { display: inline-block; margin: 0 6px 6px 0; padding: 4px 10px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 16%, var(--panel)); font-weight: 600; }
/* ---------- Modes d'affichage ---------- */
.author-av { display: none; }
.speak-btn { margin-left: 8px; border: 0; background: none; font-size: 1.5rem; cursor: pointer; vertical-align: middle; }
.quick-call { font-size: 1.6rem; flex: none; }
.choose-btn { display: grid; text-align: left; gap: 2px; width: 100%; margin-bottom: 8px; }
.choose-btn small { white-space: normal; }
body.mode-petit .author-av, body.mode-simple .author-av { display: inline-flex; width: 36px; height: 36px; font-size: 1rem; margin-right: 8px; vertical-align: middle; }

/* Enfant qui ne lit pas encore : des photos au lieu des noms, de gros boutons */
body.mode-petit #conv-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); grid-auto-rows: max-content; align-content: start; gap: 10px; padding: 10px; }
body.mode-petit #conv-list li { flex-direction: column; text-align: center; padding: 14px 6px; border-radius: 18px; position: relative; gap: 8px; background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
body.mode-petit #conv-list .avatar { width: 104px; height: 104px; font-size: 2.8rem; }
body.mode-petit #conv-list .conv-text { flex: none; }
body.mode-petit #conv-list .conv-text small { display: none; }
body.mode-petit #conv-list .conv-text strong { font-size: 1.05rem; }
body.mode-petit #conv-list .badge { position: absolute; top: 6px; right: 10px; font-size: 1.1rem; min-width: 32px; height: 32px; line-height: 32px; }
body.mode-petit #conv-list .quick-call { position: absolute; top: 4px; left: 6px; }
body.mode-petit #new-group-btn, body.mode-petit #games-btn, body.mode-petit #orga-btn { display: none !important; }
body.mode-petit #text-input, body.mode-petit #send-btn { display: none !important; }
body.mode-petit #composer { justify-content: center; gap: 28px; padding: 10px; }
body.mode-petit #mic-btn { width: 88px; height: 88px; font-size: 2.8rem; border-radius: 50%; background: var(--accent); }
body.mode-petit #attach-btn { width: 66px; height: 66px; font-size: 2.1rem; }
body.mode-petit #call-audio-btn, body.mode-petit #call-video-btn { font-size: 1.9rem; }
body.mode-petit .voice-player { min-width: 240px; }
body.mode-petit .voice-player .voice-btn { width: 64px; height: 64px; font-size: 1.9rem; }
body.mode-petit .bubble { font-size: 1.15rem; }

/* Grands-parents : tout en plus grand, appeler en un geste, photos en grand */
body.mode-simple { font-size: 118%; }
body.mode-simple #conv-list li { padding: 14px 12px; }
body.mode-simple #conv-list .avatar { width: 64px; height: 64px; font-size: 1.8rem; }
body.mode-simple #conv-list .conv-text strong { font-size: 1.2rem; }
body.mode-simple .quick-call { width: 56px; height: 56px; font-size: 1.8rem; border-radius: 50%; background: color-mix(in srgb, var(--accent) 22%, var(--panel)); }
body.mode-simple #games-btn, body.mode-simple #new-group-btn, body.mode-simple #orga-btn { display: none !important; }
body.mode-simple #mic-btn, body.mode-simple #attach-btn, body.mode-simple #send-btn { width: 56px; height: 56px; font-size: 1.7rem; }
body.mode-simple #call-audio-btn, body.mode-simple #call-video-btn { font-size: 1.8rem; }
body.mode-simple #text-input { font-size: 1.15rem; }
body.mode-simple .bubble.media img, body.mode-simple .bubble.media .video-thumb { width: min(calc(92cqw - 8px), 620px) !important; }
/* Tâches : le titre sur sa ligne, les boutons dessous (petits écrans) */
/* Cagnottes : barre de progression qui se remplit avec les étoiles */
#orga-goals .orga-item { flex-wrap: wrap; }
#orga-goals .goal-title { font-weight: 600; }
.goal-row { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.goal-bar { flex: 1 1 100%; height: 12px; border-radius: 6px; background: color-mix(in srgb, var(--text) 12%, transparent); overflow: hidden; }
.goal-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, #f4a62a, #f7c948); transition: width .4s; }
.goal-txt { flex: 1; }
/* ---------- Mascotte ---------- */
.mascot { display: block; object-fit: contain; }
.placeholder .mascot { width: 160px; height: 160px; margin: 0 auto 10px; }
.placeholder { flex-direction: column; text-align: center; }
#setup-form .logo .mascot { width: 120px; height: 120px; margin: 0 auto; }
.ask-mascot { width: 96px; height: 96px; margin: 0 auto 4px; }
.mascot-party { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; align-content: center; gap: 8px; background: rgba(0,0,0,.35); overflow: hidden; cursor: pointer; }
.mascot-party .mascot { width: 180px; height: 180px; animation: mascot-jump .6s ease-in-out infinite alternate; }
.mascot-party strong { color: #fff; font-size: 2rem; text-shadow: 0 2px 8px rgba(0,0,0,.4); }
.star-fall { position: absolute; top: -40px; font-size: 2rem; animation: star-fall 2.2s linear forwards; }
@keyframes mascot-jump { from { transform: translateY(0) rotate(-4deg); } to { transform: translateY(-18px) rotate(4deg); } }
@keyframes star-fall { to { transform: translateY(110vh) rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .mascot-party .mascot, .star-fall { animation: none; } .star-fall { display: none; } }
.mascot-party[popover] { margin: 0; border: 0; padding: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; }
/* Case « J'accepte les conditions » : à gauche du texte, aussi dans les formulaires d'inscription */
label.terms-check, .card label.terms-check { display: flex; flex-direction: row; align-items: flex-start; gap: 8px; text-align: left; }
label.terms-check input[type=checkbox] { width: auto; flex: none; margin: 3px 0 0; }

/* ---------- Thèmes (Réglages → Apparence → Thème) ----------
   « Classique » : l'apparence de base. Les thèmes enfants ont leurs propres couleurs (jour ou sombre imposé
   par theme.js), un en-tête coloré, des coins plus ronds et un fond de conversation dessiné (public/themes/). */
:root[data-skin="mascotte"] {
  --wp-tile: url("/themes/mascotte.jpg");
  --head-solid: #2a9d8f;
  --bg: #e6f6f2; --panel: #ffffff; --text: #1d2a2f; --muted: #587576; --line: #cbe8e1;
  --accent: #2a9d8f; --accent-text: #fff; --mine: #ffe9a8; --theirs: #ffffff;
  --head: linear-gradient(120deg, #2a9d8f, #45c1b0); --chat-wp: url("/themes/mascotte.jpg"), linear-gradient(#e8f7f3, #e8f7f3);
}
:root[data-skin="espace"] {
  --wp-tile: url("/themes/espace.jpg");
  --head-solid: #9b87f5;
  --bg: #f1effb; --panel: #ffffff; --text: #2b2650; --muted: #77729a; --line: #e2def5;
  --accent: #8a72e0; --accent-text: #fff; --mine: #e3dcff; --theirs: #ffffff;
  --head: linear-gradient(120deg, #9b87f5, #7fb2f0); --chat-wp: url("/themes/espace.jpg"), linear-gradient(#f0eefb, #f0eefb);
}
:root[data-skin="licorne"] {
  --wp-tile: url("/themes/licorne.jpg");
  --head-solid: #f27fc4;
  --bg: #fcf0f8; --panel: #ffffff; --text: #3a2340; --muted: #8a6b8f; --line: #f0d5e9;
  --accent: #c24fae; --accent-text: #fff; --mine: #f7d6f1; --theirs: #ffffff;
  --head: linear-gradient(120deg, #f27fc4, #a98af2); --chat-wp: url("/themes/licorne.jpg"), linear-gradient(#fbeef7, #fbeef7);
}
:root[data-skin="dinos"] {
  --wp-tile: url("/themes/dinos.jpg");
  --head-solid: #3d9a33;
  --bg: #eef8e6; --panel: #ffffff; --text: #1f3318; --muted: #5d7656; --line: #d3eac4;
  --accent: #3d9a33; --accent-text: #fff; --mine: #d5f0c5; --theirs: #ffffff;
  --head: linear-gradient(120deg, #3d9a33, #86c440); --chat-wp: url("/themes/dinos.jpg"), linear-gradient(#eef5e6, #eef5e6);
}
:root[data-skin="ocean"] {
  --wp-tile: url("/themes/ocean.jpg");
  --head-solid: #1a86c7;
  --bg: #e1f0fa; --panel: #ffffff; --text: #10324a; --muted: #557a91; --line: #cbe6f4;
  --accent: #1a86c7; --accent-text: #fff; --mine: #c9ecff; --theirs: #ffffff;
  --head: linear-gradient(120deg, #1a86c7, #33bfd6); --chat-wp: url("/themes/ocean.jpg"), linear-gradient(#e1f0fa, #e1f0fa);
}
:root[data-skin]:not([data-skin="classique"]) { --radius: 22px; }
:root[data-skin]:not([data-skin="classique"]) { color-scheme: light; }
:root[data-skin]:not([data-skin="classique"]) body { font-family: ui-rounded, "Nunito", "Varela Round", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
:root[data-skin]:not([data-skin="classique"]) .bar { background: var(--head); color: #fff; border-bottom: 0; }
:root[data-skin]:not([data-skin="classique"]) .bar .icon-btn { color: #fff; }
:root[data-skin]:not([data-skin="classique"]) .bar .muted { color: rgba(255,255,255,.85); }
:root[data-skin]:not([data-skin="classique"]) #conv-list li.active { background: color-mix(in srgb, var(--accent) 14%, var(--panel)); }
:root[data-skin]:not([data-skin="classique"]) .btn.primary { border-radius: 999px; }
/* Liste des conversations : le motif du thème, très léger */
:root[data-skin]:not([data-skin="classique"]) #conv-list {
  background: linear-gradient(color-mix(in srgb, var(--panel) 45%, transparent), color-mix(in srgb, var(--panel) 45%, transparent)), var(--wp-tile);
  background-size: auto, 540px auto; background-attachment: local;
}
/* Mascotte animée en bas de la liste (thème Mascotte) : elle salue, cligne des yeux ; la toucher la fait saluer */
#sidebar { position: relative; }
#list-mascot { display: none; position: absolute; right: 12px; bottom: 70px; width: 92px; z-index: 1; cursor: pointer; -webkit-tap-highlight-color: transparent; }
:root[data-skin="mascotte"] #list-mascot { display: block; }
:root[data-skin="mascotte"] #conv-list { padding-bottom: 110px; } /* la dernière conversation passe au-dessus de la mascotte */
/* Illustrations Canva (public/themes/*.jpg) : posées une fois, fixes derrière les messages */
#chat.skin-wp #messages { background: var(--chat-wp); background-size: cover, cover; background-position: center top; background-attachment: scroll, scroll; }

/* Choix du thème */
#skin-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.skin-choice { border: 3px solid transparent; border-radius: 16px; padding: 0; overflow: hidden; cursor: pointer; background: var(--panel); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); font: inherit; display: grid; grid-template-rows: 22px 62px auto; text-align: center; }
.skin-choice .skin-head { display: block; }
.skin-choice .skin-body { display: grid; place-items: center; font-size: 1.8rem; background-size: cover !important; background-position: center !important; }
.skin-choice .skin-body img { width: 40px; height: 40px; }
.skin-choice .skin-name { font-size: .8rem; padding: 4px 2px 6px; font-weight: 600; }
.skin-choice.active { border-color: var(--accent); }
.skin-choice.active .skin-name::before { content: "✓ "; }

/* Choix de l'icône de l'application (Android) */
#appicon-choices { display: flex; gap: 10px; }
.appicon-choice { flex: 1; display: grid; justify-items: center; gap: 6px; padding: 10px 6px; border: 3px solid transparent; border-radius: 16px; background: var(--panel); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
.appicon-choice img { width: 64px; height: 64px; border-radius: 16px; }
.appicon-choice.active { border-color: var(--accent); }
.appicon-choice.active span::before { content: "✓ "; }

/* Menu ⋮ d'une conversation : petite liste en haut à droite, comme WhatsApp */
/* Menus ⋮ comme WhatsApp : petit menu collé en haut à droite, sous le bouton */
dialog.menu-dialog { margin: calc(6px + env(safe-area-inset-top)) 6px auto auto; padding: 8px 0; width: max-content; min-width: 210px; max-width: min(300px, calc(100vw - 16px)); border: 0; border-radius: 14px; background: var(--panel); color: var(--text); box-shadow: 0 8px 28px rgba(0,0,0,.25); }
dialog.menu-dialog::backdrop { background: transparent; }
dialog.menu-dialog form { display: grid; }
dialog.menu-dialog button { text-align: left; background: none; border: 0; color: inherit; font: inherit; font-size: 1.02rem; padding: 14px 22px 14px 18px; cursor: pointer; white-space: nowrap; }
dialog.menu-dialog[open] { animation: menu-in .14s ease-out; transform-origin: top right; }
@keyframes menu-in { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
dialog.menu-dialog button:hover, dialog.menu-dialog button:focus-visible { background: var(--bg); }
dialog.menu-dialog button.hidden { display: none; }
#chat-more-btn { font-size: 1.5rem; font-weight: 700; }

/* Rechercher dans une conversation */
#search-input { width: 100%; }
#search-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 55vh; overflow-y: auto; }
.search-item { padding: 10px 12px; border-radius: 12px; background: var(--bg); cursor: pointer; }
.search-head { display: flex; justify-content: space-between; gap: 8px; font-size: .85rem; }
.search-text { margin-top: 3px; word-break: break-word; }
.search-text mark { background: #ffe58a; color: #222; border-radius: 3px; padding: 0 1px; }
/* Message trouvé : il clignote */
.msg.flash .bubble, .flash > .bubble { animation: msg-flash 1.6s ease 2; }
@keyframes msg-flash { 0%, 100% { box-shadow: 0 0 0 0 transparent; } 50% { box-shadow: 0 0 0 4px var(--accent); } }

/* Mascotte animée : corps + bras qui salue (public/mascotte/) + paupières dessinées par-dessus les yeux */
.mascot-anim { position: relative; display: block; aspect-ratio: 1; }
.mascot-anim > img, .mascot-anim > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.mascot-anim .m-arm { transform-origin: 25% 51.95%; } /* l’épaule (128, 266 sur 512) ; le bras est derrière le corps */
.mascot-anim .m-lid { transform: translateY(-80px); }
.mascot-anim .m-lash { opacity: 0; }
/* Salut en arrivant (2 fois), puis de temps en temps ; clignement des yeux toutes les quelques secondes */
.mascot-anim.hello .m-arm { animation: m-wave 1.1s ease-in-out 2; }
.mascot-anim.idle .m-arm { animation: m-wave-rare 9s ease-in-out infinite 3s; }
.mascot-anim .m-lid { animation: m-blink 4.5s ease-in-out infinite 1.2s; }
.mascot-anim .m-lash { animation: m-lash 4.5s ease-in-out infinite 1.2s; }
.mascot-anim.idle { animation: m-breathe 3.2s ease-in-out infinite; transform-origin: 50% 90%; }
.mascot-anim.hop { animation: m-hop 1.4s ease-in-out infinite; transform-origin: 50% 90%; }
.mascot-anim.party { animation: mascot-jump .6s ease-in-out infinite alternate; }
.mascot-anim.party .m-arm { animation: m-wave .5s ease-in-out infinite; }
@keyframes m-wave { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(16deg); } 75% { transform: rotate(-6deg); } }
@keyframes m-wave-rare { 0%, 82%, 100% { transform: rotate(0); } 86% { transform: rotate(16deg); } 90% { transform: rotate(-6deg); } 94% { transform: rotate(14deg); } 98% { transform: rotate(-3deg); } }
@keyframes m-blink { 0%, 92%, 100% { transform: translateY(-80px); } 95%, 97% { transform: translateY(0); } }
@keyframes m-lash { 0%, 94%, 98%, 100% { opacity: 0; } 95%, 97% { opacity: 1; } }
@keyframes m-breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.025, .985); } }
@keyframes m-hop { 0%, 60%, 100% { transform: translateY(0) scale(1, 1); } 70% { transform: translateY(0) scale(1.05, .93); } 80% { transform: translateY(-14%) scale(.97, 1.04); } 90% { transform: translateY(0) scale(1.04, .95); } }
@media (prefers-reduced-motion: reduce) {
  .mascot-anim, .mascot-anim .m-arm, .mascot-anim .m-lid, .mascot-anim .m-lash { animation: none !important; }
}

/* Couleurs des bulles d'une conversation (menu ⋮ → Thème de la discussion), jour et sombre */
#chat[data-bubbles="classique"] { --mine: #d8f3ec; --theirs: #ffffff; }
:root[data-theme="dark"] #chat[data-bubbles="classique"] { --mine: #1f4a44; --theirs: #223035; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) #chat[data-bubbles="classique"] { --mine: #1f4a44; --theirs: #223035; } }
#chat[data-bubbles="vert"] { --mine: #dcf8c6; --theirs: #ffffff; }
:root[data-theme="dark"] #chat[data-bubbles="vert"] { --mine: #005c4b; --theirs: #202c33; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) #chat[data-bubbles="vert"] { --mine: #005c4b; --theirs: #202c33; } }
#chat[data-bubbles="bleu"] { --mine: #d6ebff; --theirs: #ffffff; }
:root[data-theme="dark"] #chat[data-bubbles="bleu"] { --mine: #1d3a5c; --theirs: #202a33; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) #chat[data-bubbles="bleu"] { --mine: #1d3a5c; --theirs: #202a33; } }
#chat[data-bubbles="violet"] { --mine: #e9e0ff; --theirs: #ffffff; }
:root[data-theme="dark"] #chat[data-bubbles="violet"] { --mine: #3a2f63; --theirs: #262433; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) #chat[data-bubbles="violet"] { --mine: #3a2f63; --theirs: #262433; } }
#chat[data-bubbles="rose"] { --mine: #ffe0ef; --theirs: #ffffff; }
:root[data-theme="dark"] #chat[data-bubbles="rose"] { --mine: #5a2944; --theirs: #33242c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) #chat[data-bubbles="rose"] { --mine: #5a2944; --theirs: #33242c; } }
#chat[data-bubbles="jaune"] { --mine: #ffe9a8; --theirs: #ffffff; }
:root[data-theme="dark"] #chat[data-bubbles="jaune"] { --mine: #5a4a14; --theirs: #2e2a1e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) #chat[data-bubbles="jaune"] { --mine: #5a4a14; --theirs: #2e2a1e; } }
#bubble-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-bottom: 14px; }
.bub-choice { display: grid; gap: 4px; padding: 8px 6px 6px; border: 3px solid transparent; border-radius: 14px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; font: inherit; color: var(--text); }
.bub-choice i { display: block; height: 14px; border-radius: 8px; width: 70%; }
.bub-choice i.me { justify-self: end; }
.bub-choice span { font-size: .75rem; text-align: center; }
.bub-choice.active { border-color: var(--accent); }

/* YouTube ensemble : chat éphémère (sous la vidéo ; en plein écran, les derniers messages en haut à gauche) */
/* Mise en page comme le chat en direct de YouTube : vidéo en haut, chat dans tout le reste de l'écran */
#activity-body.yt-body { overflow: hidden; padding: 0 0 env(safe-area-inset-bottom); gap: 0; align-items: stretch; }
#activity-body.yt-body > .yt-holder { flex: none; border-radius: 0; max-width: none; }
.yt-chat { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; padding: 8px 12px 10px; background: var(--panel); }
.yt-chat-head { display: flex; align-items: baseline; gap: 8px; }
.yt-chat-head strong { font-size: 1.05rem; }
.yt-more { font-size: .9rem; }
.yt-more summary { cursor: pointer; color: var(--muted); }
.yt-more[open] { display: grid; gap: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.yt-chat-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; font-size: .95rem; }
.yt-chat-list:empty::before { content: "Personne n’a encore écrit. Dis quelque chose !"; color: var(--muted); font-size: .9rem; }
.yt-chat-line { word-break: break-word; }
.yt-chat-line b { color: var(--accent); }
.yt-chat-form { display: flex; gap: 6px; }
.yt-chat-form input { flex: 1; min-width: 0; }
.yt-chat-fly { position: absolute; left: 10px; top: 10px; bottom: auto; max-width: 70%; display: none; flex-direction: column; align-items: flex-start; gap: 4px; pointer-events: none; z-index: 3; }
.yt-holder.yt-full .yt-chat-fly, .yt-holder:fullscreen .yt-chat-fly { display: flex; }
.yt-chat-fly .yt-chat-line { background: rgba(0,0,0,.55); color: #fff; padding: 4px 10px; border-radius: 12px; font-size: .95rem; animation: yt-chat-fade 7s ease forwards; }
.yt-chat-fly .yt-chat-line b { color: #ffd76a; }
@keyframes yt-chat-fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

/* Agenda en vue mois (comme un calendrier de téléphone) : barres de couleur par rendez-vous */
.cal-dot { width: 12px; height: 12px; border-radius: 4px; flex: none; }
#ev-colors { display: inline-flex; flex-wrap: wrap; gap: 6px; vertical-align: middle; margin-left: 6px; }
.ev-color { width: 26px; height: 26px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; box-shadow: 0 0 0 1px var(--line); }
.ev-color.active { border-color: var(--panel); box-shadow: 0 0 0 2px var(--text); }
#activity-body.yt-body > .yt-presence, #activity-body.yt-body > .yt-wait { flex: none; padding: 6px 12px; text-align: center; }
#activity-body.yt-typing > .yt-presence, #activity-body.yt-typing > .yt-wait, #activity-body.yt-typing .yt-chat-head, #activity-body.yt-typing .yt-more { display: none; }

/* ---------- Organisation en plein écran (agenda façon FamilyWall, tâches) ---------- */
/* Onglets de l'accueil : Discussions / Agenda / Tâches */
#home-tabs { display: flex; flex: none; border-top: 1px solid var(--line); background: var(--panel); padding-bottom: env(safe-area-inset-bottom); position: relative; z-index: 2; }
#home-tabs.hidden { display: none; }
#home-tabs button { flex: 1; display: grid; justify-items: center; gap: 1px; border: 0; background: none; color: var(--muted); font: inherit; font-size: .78rem; font-weight: 600; padding: 6px 4px 7px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
#home-tabs .ht-ico { position: relative; display: grid; place-items: center; width: 56px; height: 30px; border-radius: 15px; font-size: 1.25rem; }
#home-tabs button.on { color: var(--text); }
#home-tabs button.on .ht-ico { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.ht-badge { position: absolute; top: -3px; right: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .7rem; line-height: 18px; font-weight: 700; }
body.mode-petit #home-tabs, body.mode-simple #home-tabs { display: none !important; }
#sidebar[data-tab="agenda"] > :not(header):not(#orga-pane):not(#home-tabs),
#sidebar[data-tab="tasks"] > :not(header):not(#orga-pane):not(#home-tabs) { display: none !important; }
#orga-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#orga-pane.hidden { display: none; }
.orga-body { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; }
/* Fiche, formulaire, calendriers liés : par-dessus tout l'écran sur un téléphone */
@media (max-width: 760px) { .orga-over { position: fixed; z-index: 30; } }
/* Rappel du jour en haut des Discussions */
#today-card { display: flex; align-items: center; gap: 10px; margin: 8px 12px 0; padding: 10px 12px; border: 0; border-radius: 12px; background: color-mix(in srgb, var(--accent) 13%, var(--panel)); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
#today-card.hidden { display: none; }
.today-ico { font-size: 1.2rem; }
.today-txt { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.today-more { color: var(--accent); font-weight: 700; }
/* Aujourd'hui / Ajouter / Tous : en haut de l'agenda */
.cal-tools { display: flex; gap: 6px; padding: 0 10px 6px; }
.cal-tools button { flex: 1; border: 0; border-radius: 999px; padding: 7px 6px; background: var(--bg); color: var(--text); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.cal-tools button.on { background: var(--accent); color: var(--accent-text); }
.orga-top { display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 10px 8px; border-bottom: 1px solid var(--line); background: var(--panel); }
.orga-top .grow { flex: 1; min-width: 0; font-size: 1.1rem; }
.orga-page { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 10px 16px; }
.orga-page[data-orga="agenda"] { padding: 4px 0 0; }
#orga-events { padding: 0 12px 16px; }
.no-parent { display: none !important; }
/* Mois */
#orga-cal { display: flex; flex-direction: column; min-height: 100%; }
#orga-cal.hidden { display: none; }
.cal-head { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.cal-title { flex: 1; text-align: center; font-size: 1.3rem; }
.cal-nav { width: 40px; height: 40px; font-size: 1.6rem; color: var(--accent); }
.cal-wds, .cal-week { display: grid; grid-template-columns: 20px repeat(7, minmax(0, 1fr)); }
.cal-wd { text-align: center; font-size: .8rem; color: var(--muted); padding: 2px 0 4px; }
.cal-week { flex: 1; grid-template-rows: 24px repeat(4, 17px) 1fr; min-height: 100px; border-top: 1px solid var(--line); }
.cal-wn { grid-column: 1; grid-row: 1 / -1; font-size: .62rem; font-weight: 700; color: var(--muted); text-align: center; padding-top: 6px; background: color-mix(in srgb, var(--text) 5%, transparent); }
.cal-day { grid-row: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 3px 0 0; border: 0; border-left: 1px solid var(--line); background: none; color: var(--text); font: inherit; cursor: pointer; text-align: center; }
.cal-day.other { color: var(--muted); }
.cal-day.sel { background: color-mix(in srgb, var(--accent) 12%, transparent); box-shadow: inset 0 0 0 2px var(--accent); }
.cal-num { display: inline-block; font-size: .9rem; min-width: 22px; height: 22px; line-height: 22px; border-radius: 11px; }
.cal-day.today .cal-num { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.cal-bar { position: relative; z-index: 1; pointer-events: none; align-self: center; margin: 0 2px; color: #fff; font-size: .66rem; font-weight: 700; line-height: 15px; height: 15px; padding: 0 4px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: clip; text-align: left; }
.cal-bar.cont-l { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.cal-bar.cont-r { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.cal-more { pointer-events: none; z-index: 1; font-size: .62rem; font-weight: 700; color: var(--muted); text-align: center; }
.cal-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
/* Journée (feuille du bas) */
.cal-sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; max-height: 55%; overflow-y: auto; background: var(--panel); border-radius: 18px 18px 0 0; box-shadow: 0 -6px 24px rgba(0,0,0,.18); padding: 6px 12px calc(14px + env(safe-area-inset-bottom)); }
.cal-sheet-head { display: flex; align-items: center; gap: 4px; position: sticky; top: 0; background: var(--panel); padding: 6px 0; }
.cal-sheet-head strong { flex: 1; font-size: 1.15rem; }
#cal-sheet-add { color: var(--accent); font-size: 1.7rem; }
.ev-line { display: flex; align-items: stretch; gap: 10px; width: 100%; margin: 6px 0; padding: 0; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.ev-time { width: 54px; flex: none; display: grid; align-content: center; font-size: .85rem; }
.ev-time small { color: var(--muted); }
.ev-chip { flex: 1; min-width: 0; display: grid; gap: 2px; padding: 10px 12px; border-radius: 10px; color: #fff; }
.ev-chip strong { font-size: .98rem; }
.ev-chip small { opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#orga-events .orga-day { margin: 14px 0 2px; color: var(--muted); font-size: .9rem; }
/* Fiche et formulaire d'un rendez-vous */
.orga-over { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; background: var(--bg); overflow-y: auto; }
.ev-top { background: var(--accent); color: var(--accent-text); border-bottom: 0; }
.ev-top .icon-btn { color: inherit; }
.ev-top .btn.primary { background: var(--accent-text); color: var(--accent); }
.ev-card { margin: 12px; padding: 16px; border-radius: 14px; background: var(--panel); display: grid; gap: 14px; }
.ev-title { margin: 0; font-size: 1.3rem; overflow-wrap: anywhere; }
.ev-row { display: flex; align-items: center; gap: 12px; }
.ev-when { display: flex; align-items: flex-start; gap: 12px; }
.ev-when .grow { display: grid; gap: 8px; }
.ev-ico { width: 24px; flex: none; text-align: center; font-size: 1.15rem; }
.ev-notes { white-space: pre-wrap; overflow-wrap: anywhere; }
.ev-by { margin: 0; text-align: center; }
.ev-lab { width: 44px; flex: none; color: var(--muted); font-size: .9rem; }
.ev-edit input, .ev-edit textarea { font: inherit; }
.ev-edit #ev-title { font-size: 1.15rem; font-weight: 600; width: 100%; }
.ev-edit .ev-row input[type=date] { flex: 1; min-width: 0; }
.ev-edit .ev-row input[type=time] { width: 96px; }
.ev-edit textarea { flex: 1; min-width: 0; resize: vertical; }
.ev-menu { position: absolute; top: calc(52px + env(safe-area-inset-top)); right: 8px; z-index: 6; display: grid; min-width: 200px; padding: 6px 0; border-radius: 12px; background: var(--panel); box-shadow: 0 8px 28px rgba(0,0,0,.25); }
.ev-menu button { border: 0; background: none; color: var(--text); font: inherit; text-align: left; padding: 12px 18px; cursor: pointer; }
.ev-menu button:hover { background: var(--bg); }
.ev-color.active { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--text); }
/* Tâches */
.orga-h { margin: 16px 0 6px; font-size: 1.05rem; }
/* Parent : une grande carte par enfant (comme la carte « mes étoiles » d'un enfant) */
.orga-kids { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 2px; }
.kid-hint { grid-column: 1 / -1; text-align: center; }
.kid-card { display: flex; align-items: center; gap: 10px; padding: 10px; border: 0; border-radius: 16px; background: linear-gradient(135deg, #fff3c4, #ffe08a); color: #4a3a00; font: inherit; text-align: left; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.kid-card.on { box-shadow: 0 0 0 3px var(--accent); }
.kid-av { width: 44px; height: 44px; flex: none; font-size: 1.1rem; }
.kid-txt { display: grid; min-width: 0; }
.kid-name { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kid-stars { font-size: 1.45rem; font-weight: 800; line-height: 1.15; }
.task-ok { background: color-mix(in srgb, var(--accent) 15%, var(--panel)); color: var(--accent); font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--accent); }
.kid-sub { font-size: .8rem; opacity: .85; }
.task-who { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; color: var(--muted); font-size: .92rem; }
.avatar.mini { width: 24px; height: 24px; font-size: .62rem; flex: none; }
.task-undo { justify-self: center; }
/* Trois grandes tuiles pour ajouter */
.orga-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.orga-tile { display: grid; justify-items: center; gap: 4px; padding: 14px 6px; border: 0; border-radius: 16px; background: var(--panel); color: var(--text); font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.orga-tile span { font-size: 1.8rem; }
.orga-tile:first-child { background: var(--accent); color: var(--accent-text); }
/* Formulaires (tâche, cagnotte, récompense) : par-dessus, comme la fiche d'un rendez-vous */
.orga-add[data-form] { position: absolute; inset: 0; z-index: 6; margin: 0; border-radius: 0; overflow-y: auto; align-content: start; background: var(--bg); padding: calc(10px + env(safe-area-inset-top)) 14px 20px; box-shadow: none; }
.orga-add[data-form].hidden { display: none; }
@media (max-width: 760px) { .orga-add[data-form] { position: fixed; z-index: 30; } }
.form-head { display: flex; align-items: center; gap: 8px; }
.form-head h3 { flex: 1; font-size: 1.2rem; }
.orga-add[data-form] input:not([type=number]) { font-size: 1.05rem; padding: 12px; }
.orga-hero { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: linear-gradient(135deg, #fff3c4, #ffe08a); color: #4a3a00; }
.hero-mascot { width: 76px; flex: none; }
.hero-txt { display: grid; gap: 2px; }
.hero-stars { font-size: 2rem; line-height: 1.1; }
.task-cards { display: grid; gap: 10px; }
.plain-list li.task-card { display: flex; flex-direction: column; align-items: stretch; padding: 12px 14px; }
.task-card { display: grid; gap: 8px; padding: 12px 14px; border-radius: 14px; background: var(--panel); box-shadow: 0 1px 4px rgba(0,0,0,.08); border-left: 5px solid var(--accent); }
.task-card.check { border-left-color: #f4a62a; background: color-mix(in srgb, #f4a62a 10%, var(--panel)); }
.task-card.waiting { border-left-color: #f4a62a; }
.task-top { display: flex; align-items: center; gap: 8px; }
.task-main { flex: 1; min-width: 0; font-size: 1.08rem; font-weight: 600; overflow-wrap: anywhere; }
.task-pts { flex: none; padding: 3px 10px; border-radius: 999px; background: #fff0b8; color: #6b5200; font-weight: 700; }
.task-meta { color: var(--muted); font-size: .9rem; }
.task-btns { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.task-btns .btn { flex: 1 1 auto; }
.task-done-btn { font-size: 1.1rem; padding: 12px; width: 100%; }
.task-wait { flex: 1; color: #8a6400; font-weight: 600; }
.task-empty { padding: 12px; text-align: center; }
.orga-fold { margin-top: 12px; }
.orga-fold summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.orga-add { display: grid; gap: 8px; margin-top: 12px; padding: 12px; border-radius: 14px; background: var(--panel); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.orga-add h3 { margin: 0; }
.orga-form-row { display: flex; flex-wrap: wrap; gap: 10px; }
.orga-form-row label { display: flex; align-items: center; gap: 6px; }
.orga-form-row input[type=number] { width: 70px; }
.task-ideas { display: flex; flex-wrap: wrap; gap: 6px; }
.task-ideas .orga-chip { margin: 0; border: 0; font: inherit; font-size: .85rem; font-weight: 500; cursor: pointer; color: var(--text); }
.cal-links-btn { width: 40px; height: 40px; font-size: 1.15rem; }
#cal-links .ev-card h3 { margin: 0; }
#cal-links input { width: 100%; }
.cal-help summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.feed-item .grow { line-height: 1.3; }
.feed-err { color: var(--danger); }
#ical-box { display: grid; gap: 8px; }
.ical-url { font-size: .8rem; }
/* Mascotte de la liste : au-dessus de la barre d'onglets */
#sidebar:has(#home-tabs:not(.hidden)) #list-mascot { bottom: 128px; }
/* Tâches de chaque jour */
.task-repeat { font-size: .85rem; color: var(--accent); font-weight: 600; }
.task-card.off { opacity: .6; }
