/* ==========================================================================
   Stellion — bibliothèque de composants (refonte visuelle, étape 2)

   Un seul exemplaire de chaque composant. Toutes les valeurs de couleur, de
   taille de texte, d'arrondi et d'ombre viennent de tokens.css.
   Préfixe « st- » : évite les collisions avec l'ancien style.css tant qu'il existe.

   Sommaire
     1. Utilitaires            6. Avatars
     2. Boutons                7. Badges
     3. Puces                  8. Messages d'état (alerte, vide, squelette)
     4. Champs                 9. Fenêtres (modale, feuille, tiroir, menu)
     5. Interrupteur, segments 10. Toasts, info-bulle
                               11. Barre flottante (mobile)
                               12. Publication, sondage, carrousel
                               13. Ligne de liste, bouton flottant
   ========================================================================== */

/* ---------- 1. Utilitaires ---------- */

/* Texte lu par les lecteurs d'écran, invisible à l'écran */
.st-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.st-mono {
  font-family: var(--font-mono);
}

.st-link {
  color: var(--accent-text);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  cursor: pointer;
}

.st-link:hover {
  text-decoration: underline;
}

/* Bouton présenté comme un lien (action dans une phrase) */
.st-link:where(button) {
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  font: inherit;
  font-weight: var(--weight-semibold);
  letter-spacing: 0;
  /* cible tactile : la hauteur passe à 44 px sans décaler le texte */
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
}

/* Logo : la silhouette du lézard (logo.svg) découpée dans une tuile verte.
   Le vert suit --accent : il changera tout seul avec le vert final du logo. */
.st-logo {
  --logo-size: 32px;
  width: var(--logo-size);
  height: var(--logo-size);
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  display: inline-block;
  position: relative;
}

.st-logo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--on-accent);
  /* le dessin n'occupe que le centre du fichier : on l'agrandit pour remplir la tuile */
  -webkit-mask: url("/logo.svg") center / 190% no-repeat;
  mask: url("/logo.svg") center / 190% no-repeat;
}

.st-logo--lg {
  --logo-size: 48px;
  border-radius: var(--radius-md);
}

/* ---------- 2. Boutons ---------- */

/* Remise à zéro commune : annule les réglages globaux de l'ancien style.css
   (button { width: 100%; margin-top; ombre; effet au survol }). À retirer au nettoyage. */
.st-btn,
.st-icon-btn,
.st-chip,
.st-switch,
.st-segmented__option,
.st-menu__item,
.st-row-btn {
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  font: inherit;
  letter-spacing: 0;
  color: inherit;
  cursor: pointer;
  filter: none;
  transform: none;
}

.st-btn:hover,
.st-icon-btn:hover,
.st-chip:hover,
.st-switch:hover,
.st-segmented__option:hover,
.st-menu__item:hover,
.st-row-btn:hover,
button.st-link:hover {
  filter: none;
  transform: none;
  box-shadow: none;
}

.st-btn {
  min-height: var(--tap-min);
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease, opacity var(--duration-fast) ease;
}

.st-btn--primary {
  background: var(--accent);
  color: var(--on-accent);
}

.st-btn--primary:hover {
  background: var(--accent);
  opacity: 0.9;
}

.st-btn--secondary {
  border: 1px solid var(--border-strong);
  color: var(--text);
}

.st-btn--secondary:hover {
  background: var(--surface-2);
}

.st-btn--danger {
  border: 1px solid var(--danger);
  color: var(--danger);
}

.st-btn--danger:hover {
  background: var(--surface-2);
}

/* Action discrète, sans contour (« Annuler ») */
.st-btn--ghost {
  color: var(--text-muted);
}

.st-btn--ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.st-btn--lg {
  min-height: 48px;
  font-size: var(--text-base);
}

.st-btn--block {
  width: 100%;
}

.st-btn:disabled,
.st-btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Bouton qui n'a qu'une icône : toujours 44 × 44 et un aria-label */
.st-icon-btn {
  width: var(--tap-min);
  height: var(--tap-min);
  flex-shrink: 0;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--icon);
  transition: background-color var(--duration-fast) ease, color var(--duration-fast) ease;
}

.st-icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.st-icon-btn--muted {
  color: var(--text-muted);
}

.st-icon-btn--round {
  border-radius: var(--radius-full);
}

.st-icon-btn--accent {
  background: var(--accent);
  color: var(--on-accent);
}

.st-icon-btn--accent:hover {
  background: var(--accent);
  color: var(--on-accent);
  opacity: 0.9;
}

/* ---------- 3. Puces et filtres ---------- */

.st-chip {
  min-height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  color: var(--text);
  white-space: nowrap;
  position: relative;
  transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease;
}

/* La puce mesure 36 px : la zone tactile est étendue à 44 px sans changer le dessin */
.st-chip::after {
  content: "";
  position: absolute;
  inset: -4px 0;
}

.st-chip:hover {
  background: var(--surface-2);
}

.st-chip[aria-pressed="true"],
.st-chip[aria-selected="true"],
.st-chip[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: var(--weight-semibold);
}

/* ---------- 4. Champs ---------- */

.st-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.st-field__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}

.st-field__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text);
}

.st-field__hint {
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
  color: var(--text-muted);
}

.st-input,
.st-textarea {
  width: 100%;
  min-height: var(--tap-min);
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: var(--text-base);
  box-shadow: none;
  outline: none;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.st-input--lg {
  min-height: 48px;
}

.st-textarea {
  padding: 10px 14px;
  line-height: var(--leading-normal);
  resize: vertical;
}

.st-input::placeholder,
.st-textarea::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

.st-input:focus,
.st-textarea:focus {
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.st-input[aria-invalid="true"],
.st-textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.st-input--code {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  letter-spacing: 0.3em;
  text-align: center;
}

/* Champ avec un bouton à l'intérieur (afficher le mot de passe, effacer…) */
.st-input-wrap {
  position: relative;
  display: flex;
}

.st-input-wrap > .st-input {
  padding-right: var(--tap-min);
}

.st-input-wrap > .st-icon-btn {
  position: absolute;
  top: 50%;
  right: 2px;
  margin-top: calc(var(--tap-min) / -2);
}

/* Champ de recherche : loupe à gauche, champ sans contour propre */
.st-search {
  min-height: var(--tap-min);
  padding: 0 14px;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
}

.st-search:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.st-search > input {
  flex: 1;
  min-width: 0;
  width: auto;
  height: var(--tap-min);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--text-base);
  box-shadow: none;
  outline: none;
}

.st-search > input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

/* Case à cocher : vraie case, redessinée */
.st-check {
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-align: left;
  cursor: pointer;
  user-select: none;
}

.st-check > input {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  box-shadow: none;
  display: grid;
  place-content: center;
  cursor: pointer;
  transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease;
}

.st-check > input::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid var(--on-accent);
  border-bottom: 2px solid var(--on-accent);
  transform: translateY(-1px) rotate(-45deg) scale(0);
  transition: transform var(--duration-fast) var(--ease-out);
}

.st-check > input:checked {
  border-color: var(--accent);
  background: var(--accent);
}

.st-check > input:checked::after {
  transform: translateY(-1px) rotate(-45deg) scale(1);
}

.st-check > input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 5. Interrupteur et contrôle segmenté ---------- */

/* <button class="st-switch" role="switch" aria-checked="false">
     <span class="st-switch__text">Libellé<small>Explication</small></span>
     <span class="st-switch__track" aria-hidden="true"></span>
   </button> */
.st-switch {
  width: 100%;
  min-height: 56px;
  padding: var(--space-2) 0;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
}

.st-switch__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
}

.st-switch__text > small {
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  line-height: var(--leading-tight);
  color: var(--text-muted);
}

.st-switch__track {
  width: 48px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--switch-off);
  position: relative;
  transition: background-color var(--duration-fast) ease;
}

.st-switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--switch-knob);
  transition: transform var(--duration-fast) ease;
}

.st-switch[aria-checked="true"] .st-switch__track {
  background: var(--accent);
}

.st-switch[aria-checked="true"] .st-switch__track::after {
  transform: translateX(20px);
}

/* role="tablist" (onglets) ou role="radiogroup" (choix) */
.st-segmented {
  padding: var(--space-1);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: var(--space-1);
}

.st-segmented__option {
  min-height: 36px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}

.st-segmented__option::after {
  content: "";
  position: absolute;
  inset: -4px 0;
}

.st-segmented__option[aria-selected="true"],
.st-segmented__option[aria-checked="true"] {
  background: var(--surface);
  color: var(--text);
  font-weight: var(--weight-semibold);
}

/* ---------- 6. Avatars ---------- */

/* <span class="st-avatar st-avatar--md"><img alt=""> ou initiales
     <span class="st-avatar__status" data-status="online"></span></span>
   Couleur de fond propre à la personne : element.style.setProperty('--avatar-bg', …) */
.st-avatar {
  --avatar-size: var(--avatar-md);
  width: var(--avatar-size);
  height: var(--avatar-size);
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--avatar-bg, var(--surface-2));
  color: var(--avatar-fg, var(--text));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--avatar-size) * 0.36);
  font-weight: var(--weight-semibold);
  line-height: 1;
  text-transform: uppercase;
  position: relative;
  user-select: none;
}

.st-avatar > img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  display: block;
}

/* Initiales sur la couleur personnelle du membre : texte foncé, lisible sur les 8 couleurs */
.st-avatar--tinted {
  color: var(--on-avatar);
}

.st-avatar--sm { --avatar-size: var(--avatar-sm); }
.st-avatar--md { --avatar-size: var(--avatar-md); }
.st-avatar--lg { --avatar-size: var(--avatar-lg); }
.st-avatar--xl { --avatar-size: var(--avatar-xl); }

.st-avatar__status {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 30%;
  height: 30%;
  min-width: 10px;
  min-height: 10px;
  border: 2px solid var(--avatar-ring, var(--bg));
  border-radius: var(--radius-full);
  background: var(--offline);
}

.st-avatar__status[data-status="online"] { background: var(--online); }
.st-avatar__status[data-status="dnd"] { background: var(--danger); }
.st-avatar__status[data-status="idle"] { background: var(--text-muted); }

/* Avatar de groupe : deux ronds superposés dans le même carré */
.st-avatar-group {
  --avatar-size: var(--avatar-lg);
  width: var(--avatar-size);
  height: var(--avatar-size);
  flex-shrink: 0;
  position: relative;
}

.st-avatar-group > .st-avatar {
  --avatar-size: 68%;
  width: 68%;
  height: 68%;
  font-size: var(--text-xs);
  position: absolute;
  top: 0;
  left: 0;
}

/* Sans photos de membres : deux pastilles teintées, lisibles dans les deux thèmes */
.st-avatar-group > .st-avatar:first-child {
  background: var(--accent-soft);
}

.st-avatar-group > .st-avatar:last-child:not(:first-child) {
  background: var(--border-strong);
}

.st-avatar-group > .st-avatar + .st-avatar {
  top: auto;
  left: auto;
  right: 0;
  bottom: 0;
  border: 2px solid var(--avatar-ring, var(--bg));
}

/* ---------- 7. Badges ---------- */

/* Point « non lu » */
.st-dot {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--accent);
}

/* Compteur ou pastille « @ » */
.st-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  line-height: 1;
}

.st-count--danger {
  background: var(--danger);
  color: var(--on-danger);
}

/* Étiquette : « Admin », « Auteur », « Sponsorisé » */
.st-tag {
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-xs);
  background: var(--accent-soft);
  color: var(--accent-text);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  line-height: 1;
  white-space: nowrap;
}

.st-tag--neutral {
  background: var(--surface-2);
  color: var(--text-muted);
}

/* ---------- 8. Messages d'état ---------- */

/* Erreur ou confirmation dans la page : role="alert" (erreur) ou role="status" */
.st-alert {
  padding: 10px var(--space-3);
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-normal);
  text-align: left;
}

.st-alert > svg {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--danger);
}

.st-alert--ok {
  border-color: var(--accent);
}

.st-alert--ok > svg {
  color: var(--accent-text);
}

.st-alert[hidden] {
  display: none;
}

/* État vide : une icône discrète, une phrase, une action utile */
.st-empty {
  padding: var(--space-10) var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-base);
}

.st-empty > svg {
  color: var(--text-muted);
  opacity: 0.7;
}

.st-empty__title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text);
}

/* Squelette de chargement : donner width/height par une classe d'écran */
.st-skeleton {
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  animation: st-pulse 1.4s ease-in-out infinite;
}

@keyframes st-pulse {
  50% { opacity: 0.5; }
}

/* ---------- 9. Fenêtres : une seule mécanique (<dialog> + js/overlay.js) ---------- */

/* <dialog class="st-dialog">            fenêtre centrée
   <dialog class="st-dialog st-dialog--sheet">   feuille qui monte du bas
   <dialog class="st-dialog st-dialog--drawer">  tiroir à gauche (ou --drawer-end à droite)
   Sur mobile, la fenêtre centrée devient une feuille. */
.st-dialog {
  width: min(520px, calc(100vw - var(--space-8)));
  max-width: none;
  max-height: min(720px, calc(100dvh - var(--space-8)));
  margin: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-menu);
  overflow: hidden;
  flex-direction: column;
}

.st-dialog[open] {
  display: flex;
  animation: st-dialog-in var(--duration-fast) var(--ease-out);
}

/* La fenêtre reçoit le focus à l'ouverture (overlay.js) : pas de contour autour d'elle,
   le focus visible reste sur les éléments qu'on atteint ensuite au clavier. */
.st-dialog:focus {
  outline: none;
}

.st-dialog::backdrop {
  background: var(--scrim);
}

.st-dialog--wide {
  width: min(760px, calc(100vw - var(--space-8)));
}

.st-dialog__handle {
  display: none;
  width: 40px;
  height: 5px;
  flex-shrink: 0;
  margin: var(--space-2) auto 0;
  border-radius: var(--radius-full);
  background: var(--border-strong);
}

.st-dialog__head {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-2) var(--space-2) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.st-dialog__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-title);
}

.st-dialog__body {
  flex: 1;
  min-height: 0;
  padding: var(--space-2) var(--space-5) var(--space-5);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.st-dialog__text {
  margin: 0;
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--text-muted);
}

.st-dialog__foot {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-5) var(--space-5);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

.st-dialog--sheet,
.st-dialog--drawer,
.st-dialog--drawer-end {
  margin: 0;
  position: fixed;
}

.st-dialog--sheet {
  inset: auto 0 0 0;
  width: 100%;
  max-height: calc(100dvh - var(--space-10));
  border-width: 1px 0 0;
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  padding-bottom: env(safe-area-inset-bottom);
}

.st-dialog--sheet[open] {
  animation-name: st-sheet-in;
  animation-duration: var(--duration-base);
}

.st-dialog--sheet .st-dialog__handle {
  display: block;
}

.st-dialog--drawer,
.st-dialog--drawer-end {
  inset: 0 auto 0 0;
  width: min(320px, 86vw);
  height: 100dvh;
  max-height: none;
  border-width: 0 1px 0 0;
  border-radius: 0 var(--radius-2xl) var(--radius-2xl) 0;
}

.st-dialog--drawer[open] {
  animation-name: st-drawer-in;
  animation-duration: var(--duration-base);
}

.st-dialog--drawer-end {
  inset: 0 0 0 auto;
  border-width: 0 0 0 1px;
  border-radius: var(--radius-2xl) 0 0 var(--radius-2xl);
}

.st-dialog--drawer-end[open] {
  animation-name: st-drawer-end-in;
  animation-duration: var(--duration-base);
}

@media (max-width: 1023px) {
  .st-dialog:not(.st-dialog--drawer):not(.st-dialog--drawer-end):not(.st-dialog--anchored) {
    margin: 0;
    position: fixed;
    inset: auto 0 0 0;
    width: 100%;
    max-height: calc(100dvh - var(--space-10));
    border-width: 1px 0 0;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .st-dialog:not(.st-dialog--drawer):not(.st-dialog--drawer-end):not(.st-dialog--anchored)[open] {
    animation-name: st-sheet-in;
    animation-duration: var(--duration-base);
  }

  .st-dialog:not(.st-dialog--drawer):not(.st-dialog--drawer-end):not(.st-dialog--anchored) .st-dialog__handle {
    display: block;
  }

  .st-dialog__foot {
    flex-direction: column-reverse;
  }

  .st-dialog__foot > .st-btn {
    width: 100%;
    min-height: 48px;
  }
}

/* Fenêtre ancrée sous un élément (menu du fil, menu « ⋯ » sur ordinateur) : placée par
   js/overlay.js avec --pop-x / --pop-y. Elle reste ancrée sur mobile aussi. */
.st-dialog--anchored {
  position: fixed;
  inset: var(--pop-y, 52px) auto auto var(--pop-x, 12px);
  width: auto;
  min-width: 220px;
  max-width: calc(100vw - var(--space-6));
  max-height: calc(100dvh - var(--pop-y, 52px) - var(--space-3));
  margin: 0;
  border-radius: var(--radius-xl);
  overflow-y: auto;
}

/* Menu d'actions : la fenêtre porte déjà le fond, le contour et l'ombre */
.st-dialog--menu {
  width: min(360px, calc(100vw - var(--space-8)));
}

.st-dialog--menu.st-dialog--anchored {
  width: auto;
}

@keyframes st-dialog-in {
  from { opacity: 0; transform: scale(0.97); }
}

@keyframes st-sheet-in {
  from { transform: translateY(100%); }
}

@keyframes st-drawer-in {
  from { transform: translateX(-100%); }
}

@keyframes st-drawer-end-in {
  from { transform: translateX(100%); }
}

/* Menu déroulant : même contenu en fenêtre flottante (ordinateur) ou en feuille (mobile) */
.st-menu {
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-menu);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.st-menu--bare {
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.st-menu__reactions {
  padding: var(--space-2) var(--space-2) var(--space-1);
  display: flex;
  justify-content: space-between;
  gap: var(--space-1);
}

.st-menu__emoji {
  width: var(--tap-min);
  height: var(--tap-min);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  box-shadow: none;
  color: var(--text);
  font-size: var(--text-2xl);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.st-menu__emoji:hover {
  background: var(--selected);
  filter: none;
  transform: none;
  box-shadow: none;
}

.st-menu__item {
  min-height: var(--tap-min);
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  text-align: left;
  text-decoration: none;
  color: var(--text);
}

.st-menu__item:hover,
.st-menu__item:focus-visible {
  background: var(--surface-2);
}

.st-menu__item > svg {
  flex-shrink: 0;
  color: var(--icon);
}

.st-menu__item--danger,
.st-menu__item--danger > svg {
  color: var(--danger);
}

.st-menu__shortcut {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: var(--text-muted);
}

.st-menu__sep {
  height: 1px;
  margin: var(--space-1) var(--space-2);
  background: var(--hairline);
}

/* ---------- 10. Toasts et info-bulle ---------- */

.st-toasts {
  position: fixed;
  top: calc(var(--space-3) + env(safe-area-inset-top));
  left: 50%;
  z-index: 10000;
  width: min(420px, calc(100vw - var(--space-6)));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.st-toast {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-float);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  pointer-events: auto;
  animation: st-toast-in var(--duration-base) var(--ease-out);
}

.st-toast__title {
  font-weight: var(--weight-semibold);
}

.st-toast__text {
  color: var(--text-muted);
}

@keyframes st-toast-in {
  from { opacity: 0; transform: translateY(-8px); }
}

.st-tooltip {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: var(--leading-tight);
  box-shadow: var(--shadow-float);
  pointer-events: none;
}

/* ---------- 11. Barre flottante (mobile) ---------- */

/* Place réservée en bas des écrans mobiles pour la barre. Les anciens écrans s'en servent
   à la place de leurs « 47px » en dur. Elle vaut 0 quand la barre est absente. */
:root {
  --nav-space: 0px;
}

.st-nav {
  display: none;
}

/* 768 px : seuil de l'ancienne mise en page mobile. Il passera à 1023 px quand les écrans
   ordinateur seront refaits (étape 4). */
@media (max-width: 768px) {
  :root {
    --nav-space: calc(var(--nav-float-h) + var(--nav-float-inset) + var(--space-2) + env(safe-area-inset-bottom, 0px));
  }

  .st-nav {
    position: fixed;
    left: var(--nav-float-inset);
    right: var(--nav-float-inset);
    bottom: calc(var(--nav-float-inset) + env(safe-area-inset-bottom, 0px));
    z-index: 500;
    height: var(--nav-float-h);
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-2xl);
    background: var(--float-bg);
    box-shadow: var(--shadow-float);
    display: flex;
    gap: var(--space-1);
    transition: transform var(--duration-base) var(--ease-out);
  }

  /* Barre rangée sous l'écran : défilement du fil vers le bas (mobile.js) */
  .st-nav--away {
    transform: translateY(calc(100% + var(--nav-float-inset) * 2 + env(safe-area-inset-bottom, 0px)));
  }
}

.st-nav__item {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  height: 52px;
  margin: 0;
  padding: 0 var(--space-2);
  border: 0;
  border-radius: var(--radius-xl);
  background: transparent;
  box-shadow: none;
  color: var(--icon);
  font: inherit;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  letter-spacing: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  cursor: pointer;
  position: relative;
  transition: flex-grow var(--duration-base) var(--ease-out), background-color 220ms ease, color 220ms ease;
}

.st-nav__item:hover {
  filter: none;
  transform: none;
  box-shadow: none;
}

.st-nav__item > svg {
  flex-shrink: 0;
}

/* Seule l'entrée active montre son nom, dans la pastille verte */
.st-nav__label {
  display: block;
  max-width: 0;
  padding-left: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  transition: max-width var(--duration-base) var(--ease-out), opacity var(--duration-fast) ease, padding-left var(--duration-base) ease;
}

.st-nav__item[aria-current="page"] {
  flex-grow: 2.6;
  background: var(--accent);
  color: var(--on-accent);
}

.st-nav__item[aria-current="page"] .st-nav__label {
  max-width: 96px;
  padding-left: var(--space-2);
  opacity: 1;
}

.st-nav__avatar {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--surface) center / cover no-repeat;
  color: var(--text);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: box-shadow 220ms ease;
}

.st-nav__item[aria-current="page"] .st-nav__avatar {
  box-shadow: 0 0 0 2px var(--on-accent);
}

/* Compteur de non-lus, posé sur le coin de l'icône. Affiché par le JS (style.display). */
.st-nav__badge {
  display: none;
  position: absolute;
  top: 6px;
  left: 50%;
  margin-left: 4px;
  min-width: 18px;
  height: 18px;
  box-shadow: 0 0 0 2px var(--float-bg);
}

/* ---------- 12. Publication et sondage ---------- */

/* Liste (par défaut) : publications séparées par un filet, sur fond --surface.
   Cartes : ajouter st-feed--cards sur le conteneur (Paramètres › Affichage). */
.st-feed {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.st-feed--cards {
  padding: 0 var(--space-3);
  border-top: 0;
  background: none;
  gap: 10px;
}

.st-post {
  padding: 14px var(--space-4) var(--space-1);
  border-bottom: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.st-feed--cards > .st-post {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xl);
  background: var(--surface);
}

.st-post__context {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  position: relative;
}

.st-post__head {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Avatar et nom : de vrais boutons, sans habillage */
.st-post__avatar-btn,
.st-post__name,
.st-post__media-btn,
.st-post__nexus {
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  font: inherit;
  letter-spacing: 0;
  color: inherit;
  cursor: pointer;
}

.st-post__avatar-btn:hover,
.st-post__name:hover,
.st-post__media-btn:hover,
.st-post__nexus:hover {
  filter: none;
  transform: none;
  box-shadow: none;
}

.st-post__avatar-btn {
  flex-shrink: 0;
  border-radius: var(--radius-full);
  display: flex;
}

.st-post__who {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.st-post__name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  text-align: left;
}

.st-post__name:hover {
  text-decoration: underline;
}

.st-post__meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Nexus d'origine : petite étiquette cliquable au-dessus de l'auteur */
.st-post__nexus {
  min-height: 24px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  position: relative;
}

.st-post__nexus::after {
  content: "";
  position: absolute;
  inset: -10px 0;
}

.st-post__text {
  margin: 0;
  font-size: var(--text-base);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.st-post__text a,
.st-post__tag {
  color: var(--accent-text);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  cursor: pointer;
}

.st-post__text a:hover,
.st-post__tag:hover {
  text-decoration: underline;
}

/* Médias : image, vidéo ou carrousel */
.st-post__media {
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
  position: relative;
}

.st-feed--cards .st-post__media {
  border-radius: var(--radius-md);
}

.st-post__media-btn {
  width: 100%;
  border-radius: 0;
  display: block;
  cursor: zoom-in;
}

.st-post__media-btn > img,
.st-post__media-btn > video {
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  display: block;
}

/* Bouton rond posé sur un média (son, flèches du carrousel) */
.st-post__media-ctl {
  position: absolute;
  width: var(--tap-min);
  height: var(--tap-min);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--media-scrim);
  color: var(--on-media);
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.st-post__media-ctl:hover {
  filter: none;
  transform: none;
  box-shadow: none;
}

.st-post__media-ctl--sound { right: var(--space-2); bottom: var(--space-2); }
.st-post__media-ctl--prev { left: var(--space-2); top: 50%; margin-top: calc(var(--tap-min) / -2); }
.st-post__media-ctl--next { right: var(--space-2); top: 50%; margin-top: calc(var(--tap-min) / -2); }

.st-post__media-count {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  height: 24px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-xs);
  background: var(--media-scrim);
  color: var(--on-media);
  display: flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
}

/* Musique jointe à la publication */
.st-post__music {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.st-post__music > img,
.st-post__music-art {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
  object-fit: cover;
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.st-post__music-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  font-size: var(--text-sm);
}

.st-post__music-text > strong,
.st-post__music-text > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.st-post__music-text > span {
  color: var(--text-muted);
}

/* Barre d'actions : j'aime, commenter, republier, envoyer */
.st-post__actions {
  margin: 0 -10px;
  display: flex;
  align-items: center;
}

.st-post__action {
  width: auto;
  min-width: var(--tap-min);
  height: var(--tap-min);
  margin: 0;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  box-shadow: none;
  color: var(--icon);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  letter-spacing: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}

.st-post__action:hover {
  background: var(--surface-2);
  filter: none;
  transform: none;
  box-shadow: none;
}

.st-post__action--like[aria-pressed="true"] {
  color: var(--like);
  font-weight: var(--weight-medium);
}

.st-post__action--like[aria-pressed="true"] > svg {
  fill: currentColor;
}

.st-post__action--repost[aria-pressed="true"] {
  color: var(--accent-text);
}

/* « par @ami +2 » : les amis qui ont aimé */
.st-post__liked-by {
  margin-left: auto;
  padding-right: 10px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Sondage : le seul de l'app (publications, salons, forum) */
.st-poll {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.st-poll__question {
  margin: 0;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
}

.st-poll__row {
  display: flex;
  align-items: stretch;
  gap: var(--space-2);
}

.st-poll__option {
  flex: 1;
  min-width: 0;
  width: auto;
  min-height: var(--tap-min);
  margin: 0;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: none;
  box-shadow: none;
  color: var(--text);
  font: inherit;
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  letter-spacing: 0;
  text-align: left;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.st-poll__option:hover {
  background: var(--surface-2);
  filter: none;
  transform: none;
  box-shadow: none;
}

/* Barre de pourcentage : largeur donnée par --pct (data-vars) */
.st-poll__option::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--pct, 0%);
  background: var(--surface-2);
  transition: width var(--duration-base) var(--ease-out);
}

.st-poll__option[aria-pressed="true"] {
  border-color: var(--accent);
}

.st-poll__option[aria-pressed="true"]::before {
  background: var(--accent-soft);
}

.st-poll__option > * {
  position: relative;
}

.st-poll__label {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.st-poll__check {
  flex-shrink: 0;
  color: var(--accent-text);
}

.st-poll__pct {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.st-poll__option[aria-pressed="true"] .st-poll__pct {
  color: var(--text);
  font-weight: var(--weight-medium);
}

.st-poll__voters {
  flex-shrink: 0;
}

.st-poll__foot {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Carrousel de médias d'une publication */
.st-carousel {
  position: relative;
  overflow: hidden;
}

.st-carousel__track {
  display: flex;
  transition: transform var(--duration-base) var(--ease-out);
}

.st-carousel__slide {
  flex: 0 0 100%;
  min-width: 0;
}

.st-carousel__dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--space-2);
  display: flex;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
}

.st-carousel__dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--on-media);
  opacity: 0.45;
}

.st-carousel__dot.active {
  opacity: 1;
}

.st-post__video {
  position: relative;
}

/* ---------- 13. Ligne de liste et bouton flottant ---------- */

/* Ligne cliquable : avatar ou icône, titre, précision en mono */
.st-row-btn {
  width: 100%;
  min-height: 56px;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-align: left;
  color: var(--text);
}

.st-row-btn:hover {
  background: var(--surface-2);
}

.st-row-btn__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.st-row-btn__title,
.st-row-btn__meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.st-row-btn__title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
}

.st-row-btn__meta {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: var(--weight-regular);
  color: var(--text-muted);
}

.st-dialog__body--list {
  gap: 2px;
  padding-left: var(--space-3);
  padding-right: var(--space-3);
}

/* Bouton d'action flottant (créer une publication, un fil de forum…) */
.st-fab {
  width: 56px;
  height: 56px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-xl);
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-float);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.st-fab:hover {
  filter: none;
  transform: none;
  box-shadow: var(--shadow-float);
  opacity: 0.92;
}

/* Élément coché d'un menu à choix unique */
.st-menu__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.st-menu__check {
  display: none;
  color: var(--accent-text);
}

.st-menu__item[aria-checked="true"] {
  background: var(--selected);
}

.st-menu__item[aria-checked="true"] > .st-menu__check {
  display: block;
}

/* Pastille de couleur à choisir (couleur de personnalité) : role="radio" */
.st-swatch {
  width: var(--tap-min);
  height: var(--tap-min);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--swatch);
  box-shadow: none;
  cursor: pointer;
}

.st-swatch:hover {
  filter: none;
  transform: none;
}

.st-swatch[aria-checked="true"] {
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--swatch);
}

/* Lecteur audio des messages vocaux (ui.js, buildAudioPlayer) */
.audio-player-card { display: flex; align-items: center; gap: 10px; background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: 12px; padding: 9px 14px; margin-top: 8px; width: 280px; max-width: 100%; transition: border-color .2s; }
.audio-player-card:hover { border-color: var(--accent); }
.ap-play-btn { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); border: none; color: var(--on-accent); cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin: 0; padding: 0; width: 34px; box-shadow: 0 2px 8px var(--accent-glow); transition: transform .2s cubic-bezier(.34,1.56,.64,1); }
.ap-play-btn:hover { transform: scale(1.1); filter: brightness(1.1); box-shadow: none; }
.ap-body { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ap-progress-bg { height: 4px; background: var(--bg-hover); border-radius: 99px; cursor: pointer; overflow: hidden; }
.ap-progress-fill { height: 100%; background: var(--accent); border-radius: 99px; width: 0%; transition: width .1s linear; }
.ap-time { font-size: 0.65rem; color: var(--text-muted); font-family: var(--font-mono); }

/* ---------- Bandeau de consentement (RGPD) ---------- */

.st-consent {
  position: fixed;
  left: var(--space-3);
  right: var(--space-3);
  bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  z-index: 1300;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-menu);
}

.st-consent[hidden] {
  display: none;
}

.st-consent__inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.st-consent__text {
  flex: 1 1 280px;
  min-width: 0;
}

.st-consent__title {
  margin: 0 0 4px;
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--text);
}

.st-consent__body {
  margin: 0;
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
  color: var(--text-muted);
}

.st-consent__body strong {
  color: var(--text);
}
