/* =========================================================
   Bulle – couche mobile (chargée en dernier)
   Barre d'onglets native : icône + libellé, un seul style,
   onglet actif signalé par une pastille d'accent.
   Retour arrière : retirer la balise <link> de mobile.css.
   ========================================================= */
@media (max-width: 760px) {
  .app .rail {
    justify-content: space-around; gap: 0;
    padding: 4px 6px calc(4px + var(--sab));
  }
  .app .rail .bubble {
    flex: 1 1 0; max-width: 88px; width: auto; height: 54px; min-height: 54px;
    padding: 0; margin: 0; border: 0; border-radius: 14px;
    background: transparent; box-shadow: none;
    color: var(--texte-3);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    position: relative; isolation: isolate;
    -webkit-tap-highlight-color: transparent;
    transition: color .18s var(--ease, ease), transform .12s var(--ease, ease);
  }
  .app .rail .bubble:hover { background: transparent; box-shadow: none; transform: none; }
  .app .rail .bubble:active { transform: scale(.94); }
  .app .rail .bubble svg { width: 22px; height: 22px; }
  .app .rail .bubble::after {
    font: 800 10.5px/1 var(--font-ui, 'Nunito'), system-ui, sans-serif;
    letter-spacing: .01em; white-space: nowrap;
  }
  .app #btn-home::after { content: 'Amis'; }
  .app #btn-social::after { content: 'Social'; }
  .app #btn-notifs::after { content: 'Alertes'; }
  .app #btn-mobile-menu::after { content: 'Discussions'; }
  .app #btn-premium::after { content: 'Bulle+'; }

  /* Onglet actif : couleur d'accent + pastille derrière l'icône */
  .app .rail .bubble.active,
  .app .rail .bubble[aria-expanded="true"] { color: var(--violet); background: transparent; box-shadow: none; }
  .app .rail .bubble.active::before,
  .app .rail .bubble[aria-expanded="true"]::before {
    content: ''; position: absolute; z-index: -1; top: 4px; left: 50%;
    width: 52px; height: 28px; margin-left: -26px; border-radius: 999px;
    background: color-mix(in srgb, var(--violet) 15%, transparent);
    animation: bulle-tab-pill .22s var(--ease, ease);
  }
  @keyframes bulle-tab-pill { from { transform: scaleX(.5); opacity: 0; } to { transform: none; opacity: 1; } }

  /* Social : on neutralise le halo et le libellé du rail desktop */
  .app .rail .bubble.social .bubble-halo,
  .app .rail .bubble.social .bubble-text { display: none; }
  .app .rail .bubble.social .bubble-ic { display: inline-flex; transform: none; }
  .app .rail .bubble.social.active { color: var(--violet); }

  /* Bulle+ : touche dorée, lisible sur fond clair comme sombre */
  .app .rail .bubble.plus { color: color-mix(in srgb, var(--or, #FFD93D) 55%, var(--texte)); }

  /* Pastilles de notification, accrochées à l'icône */
  .app .rail .bubble .badge-dot { top: 6px; right: auto; left: calc(50% + 6px); }

  /* En-tête : onglets défilants sur une ligne au lieu de passer à la ligne */
  .main-head .tabs, .main-head .friend-tabs, .main-head nav {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain; min-width: 0;
  }
  .main-head .tabs::-webkit-scrollbar, .main-head .friend-tabs::-webkit-scrollbar, .main-head nav::-webkit-scrollbar { display: none; }
  .main-head .tabs > *, .main-head .friend-tabs > *, .main-head nav > * { flex: 0 0 auto; white-space: nowrap; }
}

@media (max-width: 380px) {
  .app .rail .bubble::after { font-size: 9.5px; }
  .app #btn-mobile-menu::after { content: 'Fils'; }
}

@media (prefers-reduced-motion: reduce) {
  .app .rail .bubble, .app .rail .bubble::before { transition: none; animation: none; }
}

/* Bannière « Réseau social » : hauteur naturelle et bouton lisible (toutes tailles) */
.app .social-hero .social-hero-btn {
  /* liquid-glass.css rend tous les .btn neutres translucides (sélecteur à 7 classes) */
  background-color: #fff !important; background-image: none !important; color: var(--violet-fonce, var(--violet));
  border-color: transparent !important; -webkit-backdrop-filter: none; backdrop-filter: none;
}
@media (max-width: 620px) {
  .app .social-hero-txt { flex: 0 0 auto; min-width: 0; padding-right: 34px; }
  .app .social-hero { gap: 14px; }
}
/* Onglets d'en-tête défilants : fondu sur le bord droit pour signaler la suite */
@media (max-width: 760px) {
  .main-head nav {
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
            mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
    padding-right: 24px;
  }
}

/* =========================================================
   Gestes tactiles : feuille d'actions et glisser pour répondre
   ========================================================= */
@media (hover: none) {
  #messages .msg-actions { display: none; }
  #messages .msg { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
    transition: transform .2s var(--ease, ease), background-color .15s var(--ease, ease); }
  #messages .msg.msg-swiping { transition: none; }
  #messages .msg.msg-pressed { background: color-mix(in srgb, var(--violet) 10%, transparent); }
  #messages .msg::before {
    content: ''; position: absolute; left: -46px; top: 50%; width: 30px; height: 30px; margin-top: -15px;
    border-radius: 50%; opacity: 0; transform: scale(.6);
    background: color-mix(in srgb, var(--violet) 16%, var(--panneau)) center / 16px no-repeat
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237C4DFF' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 14 4 9l5-5'/%3E%3Cpath d='M4 9h10.5a5.5 5.5 0 0 1 0 11H11'/%3E%3C/svg%3E");
    transition: opacity .15s, transform .15s;
  }
  #messages .msg.msg-swiping::before { opacity: .55; transform: scale(.85); }
  #messages .msg.msg-swipe-armed::before { opacity: 1; transform: scale(1); }
}
.msheet-back {
  position: fixed; inset: 0; z-index: 90; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(15, 10, 30, 0); transition: background-color .2s var(--ease, ease);
}
.msheet-back.open { background: rgba(15, 10, 30, .42); }
.msheet {
  width: min(520px, 100%); padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--panneau); color: var(--texte);
  border-radius: 24px 24px 0 0; box-shadow: 0 -18px 50px -20px rgba(0, 0, 0, .45);
  transform: translateY(100%); transition: transform .24s cubic-bezier(.2, .9, .25, 1);
}
.msheet-back.open .msheet { transform: none; }
.msheet-grip { width: 38px; height: 5px; border-radius: 3px; margin: 2px auto 10px; background: var(--ligne-2, var(--ligne)); }
.msheet-preview {
  margin: 0 4px 10px; padding: 10px 12px; border-radius: 14px; font-size: 14px; line-height: 1.4;
  background: var(--panneau-2, color-mix(in srgb, var(--texte) 5%, transparent)); color: var(--texte-2);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.msheet-list { display: flex; flex-direction: column; border-radius: 16px; overflow: hidden; background: var(--panneau-2, transparent); }
.msheet-item {
  display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 0 16px; width: 100%;
  border: 0; background: transparent; color: var(--texte); font: 700 16px/1.2 var(--font-ui, 'Nunito'), system-ui, sans-serif; text-align: left;
}
.msheet-item + .msheet-item { border-top: 1px solid var(--ligne); }
.msheet-item:active, .msheet-item:focus-visible { background: color-mix(in srgb, var(--violet) 10%, transparent); outline: none; }
.msheet-item.danger { color: var(--rouge); }
.msheet-ic { width: 22px; display: grid; place-items: center; color: var(--texte-3); }
.msheet-item.danger .msheet-ic { color: var(--rouge); }
.msheet-cancel {
  width: 100%; min-height: 52px; margin-top: 10px; border: 0; border-radius: 16px;
  background: var(--panneau-2, color-mix(in srgb, var(--texte) 6%, transparent)); color: var(--texte);
  font: 800 16px/1 var(--font-ui, 'Nunito'), system-ui, sans-serif;
}

/* =========================================================
   Mobile : bulles en messages privés, saisie, panneaux opaques
   ========================================================= */
@media (max-width: 760px) {
  /* Messages privés façon messagerie : les miens à droite, en couleur */
  .messages.dm .msg { padding: 2px 4px; gap: 8px; align-items: flex-end; background: transparent; }
  .messages.dm .msg:not(.cont) { margin-top: 8px; }
  .messages.dm .msg .avatar-btn .avatar, .messages.dm .msg > .avatar-btn { width: 30px; height: 30px; min-width: 30px; font-size: 13px; }
  .messages.dm .msg.mine { flex-direction: row-reverse; }
  .messages.dm .msg.mine > .avatar-btn { display: none; }
  .messages.dm .msg.cont > .avatar-btn { visibility: hidden; height: 0; }
  .messages.dm .msg-body { flex: 0 1 auto; max-width: 80%; display: flex; flex-direction: column; align-items: flex-start; }
  .messages.dm .msg.mine .msg-body { align-items: flex-end; }
  .messages.dm .msg-meta .clickable-name { display: none; }
  .messages.dm .msg-meta { order: 3; padding: 2px 6px 0; }
  .messages.dm .msg-meta time { font-size: 11px; }
  .messages.dm .msg-text {
    padding: 9px 13px; border-radius: 20px 20px 20px 6px; line-height: 1.38;
    background: var(--panneau); color: var(--texte-msg, var(--texte));
    border: 1px solid var(--ligne); box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
  }
  .messages.dm .msg.cont .msg-text { border-top-left-radius: 6px; }
  .messages.dm .msg.mine .msg-text {
    border-radius: 20px 20px 6px 20px; border-color: transparent; color: #fff;
    background: linear-gradient(135deg, var(--violet), color-mix(in srgb, var(--violet) 70%, var(--accent-2, #E0559B)));
  }
  .messages.dm .msg.mine.cont .msg-text { border-top-right-radius: 6px; }
  .messages.dm .msg.mine .msg-text a { color: #fff; text-decoration: underline; }
  .messages.dm .msg-quote { margin: 0 0 3px; }
  .messages.dm .msg-edited { padding: 0 6px; }

  /* Saisie : invite sur une ligne, boutons resserrés */
  .composer-input:placeholder-shown { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .composer form { gap: 2px; }
  .composer .icon-btn { min-width: 40px; }

  /* Tiroir et fenêtres : fond opaque (le verre dépoli laissait lire le contenu dessous) */
  .app .side { background-color: var(--panneau); -webkit-backdrop-filter: none; backdrop-filter: none; }

  /* Fenêtres → feuilles qui montent du bas, poignée, zone de pouce */
  .modal-back { align-items: end; place-items: end center; padding: calc(12px + var(--sat, 0px)) 0 0; }
  .modal-back .modal {
    max-width: 100%; width: 100%; border-radius: 26px 26px 0 0;
    background-color: color-mix(in srgb, var(--panneau) 98%, transparent);
    padding-bottom: calc(20px + var(--sab, 0px));
    max-height: calc(100dvh - 48px - var(--sat, 0px));
    animation: bulle-sheet-up .26s cubic-bezier(.2, .9, .25, 1);
    position: relative;
  }
  .modal-back .modal::before {
    content: ''; position: absolute; top: 8px; left: 50%; width: 38px; height: 5px; margin-left: -19px;
    border-radius: 3px; background: var(--ligne-2, var(--ligne));
  }
  @keyframes bulle-sheet-up { from { transform: translateY(40%); opacity: .4; } to { transform: none; opacity: 1; } }
}
@media (prefers-reduced-motion: reduce) {
  .msheet, .msheet-back, #messages .msg { transition: none; }
  .modal-back .modal { animation: none; }
}

/* Fenêtre étroite avec souris : actions au survol seulement (ne masquent plus les bulles) */
@media (max-width: 760px) and (hover: hover) {
  #messages .msg-actions { opacity: 0; pointer-events: none; }
  #messages .msg:hover .msg-actions, #messages .msg:focus-within .msg-actions { opacity: 1; pointer-events: auto; }
  .messages.dm .msg-actions { top: -14px; }
  .messages.dm .msg.mine .msg-actions { right: auto; left: 8px; }
}
/* Tactile : le bouton « ⋯ » des conversations est toujours visible → la pastille se décale */
@media (hover: none) {
  .item-row .item:has(+ .item-gear) { padding-right: 42px; }
  .item-row .item-gear { color: var(--texte-3); }
}
/* Fenêtres (toutes tailles) : verre plus dense, le contenu dessous ne se lit plus à travers */
.modal-back .modal { background-color: color-mix(in srgb, var(--panneau) 95%, transparent); }

@media (max-width: 760px) {
  /* Profil : bannière bord à bord dans la feuille, statistiques et actions lisibles */
  .modal-back .modal.profile-modal { padding: 0 0 var(--sab, 0px); }
  .modal-back .modal.profile-modal::before { z-index: 3; background: rgba(255, 255, 255, .75); }
  .profile-card .pc-hero { height: 128px; }
  .profile-card .pc-body { padding: 0 16px 16px; }
  .profile-card .pc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(62px, 1fr)); gap: 6px; }
  .profile-card .pc-stat { padding: 8px 4px; }
  .profile-card .pc-stat span { font-size: .64rem; letter-spacing: .02em; text-transform: none; }
  .profile-card .pc-actions .modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; justify-content: stretch; }
  .profile-card .pc-actions .modal-actions .btn { width: 100%; justify-content: center; min-height: 44px; }

  /* Réglages plein écran : fond opaque (lisible, et le flou coûte cher en batterie) */
  .settings { background-color: var(--fond); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (max-width: 760px) {
  .modal-back .modal { background-color: var(--panneau); -webkit-backdrop-filter: none; backdrop-filter: none; }
  /* Statistiques façon profil social : chiffres en avant, sans cadres */
  .profile-card .pc-stats { display: flex; gap: 0; justify-content: space-between; padding: 6px 0;
    border-top: 1px solid var(--ligne); border-bottom: 1px solid var(--ligne); }
  .profile-card .pc-stat { flex: 1 1 0; background: none; border: 0; border-radius: 10px; padding: 6px 2px; }
  .profile-card .pc-stat strong { font-size: 19px; }
  .profile-card .pc-stat span { font-size: .66rem; text-transform: none; letter-spacing: 0; white-space: nowrap; overflow: visible; }
  .profile-card .pc-actions .modal-actions .btn:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* =========================================================
   Appels et salons vocaux sur téléphone
   ========================================================= */
@media (max-width: 760px) {
  .voice-stage { padding: 12px; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .voice-stage.has-video { grid-template-columns: minmax(0, 1fr); }
  .voice-tile { padding: 18px 10px; gap: 8px; border-radius: 20px; }
  .voice-tile .avatar { width: 64px; height: 64px; font-size: 26px; }
  .voice-tile strong { font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* Commandes sur une seule ligne, raccrocher compris, à portée de pouce */
  .voice-actions { flex-wrap: nowrap; gap: 8px; padding: 6px 10px 14px; justify-content: center; overflow-x: auto; scrollbar-width: none; }
  .voice-actions::-webkit-scrollbar { display: none; }
  .app .voice-actions .call-ctrl { width: 48px; height: 48px; min-width: 48px; flex: 0 0 auto; }
  .app .voice-actions .call-ctrl svg { width: 20px; height: 20px; }
  .call-panel { max-height: 58vh; overflow-y: auto; }
  .call-panel .voice-stage { padding: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .call-panel .voice-stage.has-video { grid-template-columns: minmax(0, 1fr); }
  .call-panel .voice-actions { padding: 0 10px 12px; }
}
@media (max-width: 380px) {
  .app .voice-actions .call-ctrl { width: 44px; height: 44px; min-width: 44px; }
  .voice-actions { gap: 6px; }
}
