.messages-view {
  width: min(1120px, 100%);
  min-height: calc(100vh - 82px);
  margin: 0 auto;
  padding: 18px 18px 110px;
}

.messages-view.profile-hidden {
  display: none !important;
}

.messages-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 14px;
}

.messages-topbar strong {
  font-size: 22px;
}

.messages-refresh {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid #343434;
  border-radius: 11px;
  background: #111;
  color: #eee;
  font: inherit;
  font-size: 18px;
  cursor: pointer;
}

.messages-refresh:hover {
  border-color: #4b4b4b;
  background: #171717;
}

.messages-layout {
  display: grid;
  grid-template-columns: minmax(270px, 350px) minmax(0, 1fr);
  min-height: 620px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 20px;
  background: #0e0e0e;
}

.messages-list-panel {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  border-right: 1px solid rgba(255,255,255,.085);
  background: #101010;
}

.messages-thread,
.messages-thread-empty {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
}

.messages-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 9px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.messages-tab {
  position: relative;
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: #a8a8a8;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.messages-tab.is-active {
  border-color: rgba(255,76,158,.38);
  background: rgba(255,76,158,.075);
  color: #fff;
}

.messages-tab-badge,
.nav-message-badge {
  display: inline-grid;
  min-width: 19px;
  height: 19px;
  place-items: center;
  padding: 0 5px;
  border-radius: 999px;
  background: #ff4c9e;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

.messages-tab-badge[hidden],
.nav-message-badge[hidden] {
  display: none !important;
}

#nav-messages {
  position: relative;
}

#nav-messages .nav-message-badge {
  position: absolute;
  top: 2px;
  right: max(8px, calc(50% - 23px));
  box-shadow: 0 0 0 2px #0a0a0a;
}

.messages-list {
  display: grid;
  align-content: start;
}

.messages-list-empty {
  padding: 34px 18px;
  color: #8e8e8e;
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
}

.messages-conversation-card {
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  gap: 11px;
  align-items: center;
  width: 100%;
  padding: 13px 14px;
  border: 0;
  border-bottom: 1px solid rgba(255,255,255,.065);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.messages-conversation-card:hover {
  background: rgba(255,255,255,.035);
}

.messages-conversation-card.is-selected {
  background: rgba(255,76,158,.065);
}

.messages-conversation-card.has-unread {
  background-image:
    linear-gradient(
      90deg,
      rgba(255,76,158,.12),
      transparent 48%
    );
}

.message-peer-avatar {
  position: relative;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  overflow: hidden;
  flex: 0 0 44px;
  border: 1px solid #343434;
  border-radius: 50%;
  background: #1b1b1b;
  color: #d8d8d8;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.message-peer-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-conversation-main {
  min-width: 0;
}

.message-conversation-name-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.message-conversation-name {
  overflow: hidden;
  color: #f1f1f1;
  font-size: 13px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-context-chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 999px;
  color: #aaa;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.message-context-chip.is-adult {
  border-color: rgba(255,76,158,.35);
  color: #ff79b8;
}

.message-conversation-preview {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  color: #929292;
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-conversation-status {
  display: block;
  margin-top: 5px;
  color: #777;
  font-size: 10px;
  line-height: 1.25;
}

.message-conversation-side {
  display: grid;
  justify-items: end;
  gap: 7px;
  color: #7e7e7e;
  font-size: 10px;
}

.message-unread-count {
  display: grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  padding: 0 5px;
  border-radius: 999px;
  background: #ff4c9e;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
}

.messages-thread {
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto;
  min-width: 0;
  min-height: 620px;
  background: #0b0b0b;
}

.messages-thread[hidden] {
  display: none !important;
}

.messages-thread-empty {
  display: grid;
  min-height: 620px;
  place-items: center;
  padding: 30px;
  color: #777;
  font-size: 13px;
  text-align: center;
}

.messages-thread-header {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
  min-height: 67px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.messages-thread-back {
  display: none;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 1px solid #333;
  border-radius: 10px;
  background: #121212;
  color: #eee;
  font: inherit;
  cursor: pointer;
}

.messages-thread-peer {
  min-width: 0;
  flex: 1;
}

.messages-thread-peer strong,
.messages-thread-peer span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messages-thread-peer strong {
  font-size: 14px;
}

.messages-thread-peer span {
  margin-top: 2px;
  color: #858585;
  font-size: 11px;
}

.messages-thread-block {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid rgba(255,76,158,.28);
  border-radius: 10px;
  background: transparent;
  color: #ff6aae;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.messages-thread-body {
  display: flex;
  min-height: 0;
  max-height: 590px;
  flex-direction: column;
  gap: 9px;
  overflow-y: auto;
  padding: 18px;
}

.message-request-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 auto 6px;
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px;
  background: #121212;
  color: #929292;
  font-size: 10px;
}

.message-bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 7px;
}

.message-bubble-row.is-own {
  justify-content: flex-end;
}

.message-bubble {
  max-width: min(76%, 620px);
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 15px 15px 15px 5px;
  background: #161616;
  color: #eee;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-bubble-row.is-own .message-bubble {
  border-color: rgba(255,76,158,.24);
  border-radius: 15px 15px 5px 15px;
  background: rgba(255,76,158,.105);
}

.message-bubble-meta {
  margin-top: 5px;
  color: #777;
  font-size: 9px;
  text-align: right;
}

.messages-request-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  padding: 2px 0 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: transparent;
}

.messages-request-actions[hidden] {
  display: none !important;
}

.messages-request-action {
  min-height: 39px;
  padding: 8px 13px;
  border: 1px solid #383838;
  border-radius: 11px;
  background: #171717;
  color: #eee;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.messages-request-action.is-primary {
  border-color: rgba(255,76,158,.48);
  background: rgba(255,76,158,.12);
}

.messages-request-action.is-danger {
  color: #ff6aae;
}

.messages-composer {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 9px;
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,.08);
  background: #101010;
}

.messages-composer[hidden] {
  display: none !important;
}

.messages-composer textarea {
  min-height: 42px;
  max-height: 130px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid #363636;
  border-radius: 12px;
  outline: none;
  background: #151515;
  color: #fff;
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
}

.messages-composer textarea:focus {
  border-color: rgba(255,76,158,.55);
}

.messages-send {
  min-width: 88px;
  padding: 0 15px;
  border: 1px solid rgba(255,76,158,.45);
  border-radius: 12px;
  background: rgba(255,76,158,.12);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.messages-send-icon {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.messages-send:disabled {
  opacity: .55;
  cursor: default;
}

.message-request-modal {
  width: min(540px, calc(100vw - 28px));
}

.message-request-modal-intro {
  margin: 0 0 16px;
  color: #aaa;
  font-size: 13px;
  line-height: 1.5;
}

.message-request-contexts {
  display: grid;
  gap: 9px;
  margin: 0 0 14px;
}

.message-request-context-option {
  display: grid;
  grid-template-columns: auto minmax(0,1fr);
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  background: #141414;
  cursor: pointer;
}

.message-request-context-option:has(input:checked) {
  border-color: rgba(255,76,158,.5);
  background: rgba(255,76,158,.06);
}

.message-request-context-option input {
  margin-top: 3px;
  accent-color: #ff4c9e;
}

.message-request-context-copy {
  display: grid;
  gap: 3px;
}

.message-request-context-copy strong {
  font-size: 13px;
}

.message-request-context-copy small {
  color: #8e8e8e;
  font-size: 11px;
  line-height: 1.4;
}

.message-request-modal label[for="message-request-text"] {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 800;
}

#message-request-text {
  width: 100%;
  min-height: 112px;
  resize: vertical;
  padding: 11px 12px;
  border: 1px solid #363636;
  border-radius: 12px;
  outline: none;
  background: #151515;
  color: #fff;
  font: inherit;
  font-size: 13px;
  line-height: 1.5;
}

#message-request-text:focus {
  border-color: rgba(255,76,158,.55);
}

.message-request-modal-meta {
  display: flex;
  min-height: 22px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 5px;
}

#message-request-count {
  color: #707070;
  font-size: 10px;
}

#message-request-status {
  color: #ff7ab9;
  font-size: 11px;
  text-align: right;
}

#message-request-status:empty {
  display: none;
}

.public-profile-message-button {
  display: inline-flex;
  width: auto;
  min-width: 0;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 13px;
  border: 1px solid rgba(255,76,158,.35);
  border-radius: 11px;
  background: rgba(255,76,158,.06);
  color: #f6f6f6;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

.public-profile-message-button::before {
  content: "✉";
  color: #ff62aa;
  font-size: 13px;
}

.public-profile-message-button:hover {
  border-color: rgba(255,76,158,.58);
  background: rgba(255,76,158,.1);
}

.public-profile-message-button[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .messages-view {
    min-height: calc(100vh - 72px);
    padding: 8px 0 90px;
  }

  .messages-topbar {
    padding: 0 13px;
  }

  /*
    Mobile = une seule surface à la fois.

    On conserve une grille à UNE cellule au lieu de repasser
    le conteneur en display:block. Liste et conversation occupent
    donc exactement la même position : aucune ne peut être
    auto-placée sous l'autre.
  */
  .messages-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    min-height: calc(100vh - 145px);
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .messages-list-panel,
  .messages-thread,
  .messages-thread-empty {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    min-width: 0;
    min-height: calc(100vh - 145px);
  }

  .messages-list-panel {
    display: block;
    border-right: 0;
  }

  /*
    Sur smartphone l'état vide desktop n'a pas d'utilité :
    sans conversation ouverte, on garde simplement la liste.
  */
  .messages-thread-empty {
    display: none !important;
  }

  /*
    Conversation ouverte :
    - la liste disparaît ;
    - le thread reste dans la même cellule, tout en haut.
  */
  .messages-layout.has-thread .messages-list-panel {
    display: none !important;
  }

  .messages-layout.has-thread .messages-thread {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    align-self: start;
  }

  .messages-thread-back {
    display: grid;
  }

  .messages-thread-body {
    max-height: none;
    min-height: calc(100vh - 330px);
  }

  .message-bubble {
    max-width: 86%;
  }

  .messages-composer {
    grid-template-columns: minmax(0,1fr) auto;
  }
}

@media (max-width: 420px) {
  .public-profile-message-button {
    display: grid;
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    place-items: center;
    gap: 0;
    font-size: 0;
    line-height: 1;
  }

  .public-profile-message-button::before {
    display: grid;
    width: 100%;
    height: 100%;
    place-items: center;
    margin: 0;
    font-size: 15px;
    line-height: 1;
  }

  .messages-thread-block {
    padding: 7px 8px;
    font-size: 10px;
  }

  .messages-send {
    min-width: 68px;
    padding: 0 10px;
  }
}


.message-request-submit {
  min-height: 42px;
  padding: 9px 15px;
  border: 1px solid rgba(255,76,158,.48);
  border-radius: 11px;
  background: rgba(255,76,158,.13);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

.message-request-submit:disabled {
  opacity: .55;
  cursor: default;
}

/* GRFTSH MOBILE CHAT VIEWPORT FIX V1 */
@media (max-width: 900px) {
  /*
    Sur smartphone, la messagerie doit fonctionner comme une vraie
    vue de chat : le header et le composer restent visibles, seule
    la zone des messages défile.
  */
  .messages-view {
    height: 100dvh;
    min-height: 0;
    box-sizing: border-box;
    overflow: hidden;
  }

  .messages-topbar {
    flex: 0 0 auto;
  }

  .messages-layout {
    height: calc(100dvh - 145px);
    min-height: 0;
    max-height: calc(100dvh - 145px);
    overflow: hidden;
  }

  .messages-list-panel,
  .messages-thread,
  .messages-thread-empty {
    min-height: 0;
    height: 100%;
    max-height: 100%;
  }

  .messages-layout.has-thread .messages-thread {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
  }

  .messages-thread-header {
    min-height: 0;
    flex: 0 0 auto;
  }

  .messages-thread-body {
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .messages-composer {
    position: relative;
    z-index: 3;
    min-height: 0;
    flex: 0 0 auto;
    padding-bottom:
      calc(12px + env(safe-area-inset-bottom, 0px));
    background: #101010;
  }
}

/* GRFTSH CHAT AVAILABLE HEIGHT V2 */

/*
  Le bas de la messagerie est calculé en JS à partir de la vraie
  position de .bottom-nav. Le composer reste donc AU-DESSUS de
  la navigation, desktop comme mobile.
*/
.messages-view {
  min-height: 0;
  padding-bottom: 0;
}

.messages-layout {
  height:
    var(--messages-layout-height, 620px);
  min-height: 0;
  max-height:
    var(--messages-layout-height, 620px);
  overflow: hidden;
}

.messages-list-panel,
.messages-thread,
.messages-thread-empty {
  min-height: 0;
  height: 100%;
  max-height: 100%;
}

.messages-thread {
  grid-template-rows:
    auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.messages-thread-body {
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.messages-composer {
  position: relative;
  z-index: 4;
  min-height: 0;
  flex: 0 0 auto;
}


@media (max-width: 900px) {
  /*
    Important : la vue Messages commence SOUS le header GRFTSH.
    Elle ne doit donc pas elle-même réclamer 100dvh.
  */
  .messages-view {
    height: auto;
    min-height: 0;
    overflow: visible;
    padding-bottom: 0;
  }

  .messages-layout {
    height:
      var(--messages-layout-height, 520px);
    min-height: 0;
    max-height:
      var(--messages-layout-height, 520px);
  }

  .messages-list-panel,
  .messages-thread,
  .messages-thread-empty {
    min-height: 0;
    height: 100%;
    max-height: 100%;
  }

  .messages-layout.has-thread
  .messages-thread {
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
  }

  .messages-thread-body {
    min-height: 0;
    max-height: none;
    overflow-y: auto;
  }

  .messages-composer {
    padding-bottom:
      calc(
        12px +
        env(safe-area-inset-bottom, 0px)
      );
  }
}

/* GRFTSH MOBILE SEND ICON V1 */
@media (max-width: 900px) {
  .messages-composer {
    grid-template-columns:
      minmax(0, 1fr) 46px;
    gap: 8px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
  }

  /*
    Safari iOS zoome automatiquement les champs dont la taille
    de police est inférieure à 16px.
  */
  .messages-composer textarea {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    font-size: 16px;
    resize: none;
  }

  .messages-send {
    width: 46px;
    min-width: 46px;
    height: 46px;
    min-height: 46px;
    padding: 0;
    border-radius: 14px;
    overflow: hidden;
  }

  .messages-send-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .messages-send-icon {
    width: 22px;
    height: 22px;
  }
}

/* GRFTSH PROFILE ACTION ICONS VECTOR FIX V2 */

.public-profile-message-button::before {
  content: "" !important;
  display: block !important;
  width: 18px !important;
  height: 18px !important;
  flex: 0 0 18px !important;
  margin: 0 !important;
  background: #ff62aa !important;

  -webkit-mask:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='5.5' width='18' height='13' rx='2' fill='none' stroke='black' stroke-width='2'/%3E%3Cpath d='m4 7 8 6 8-6' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / contain no-repeat !important;

  mask:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='5.5' width='18' height='13' rx='2' fill='none' stroke='black' stroke-width='2'/%3E%3Cpath d='m4 7 8 6 8-6' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / contain no-repeat !important;
}

@media (max-width: 420px) {
  .public-profile-message-button {
    display: grid !important;
    place-items: center !important;
  }

  .public-profile-message-button::before {
    width: 19px !important;
    height: 19px !important;
    flex: 0 0 19px !important;
  }
}

/* GRFTSH MESSAGING NAV UX FIX V1 */

.messages-thread-header
.message-peer-avatar,
.messages-thread-peer {
  cursor: pointer;
}

.messages-thread-peer {
  border-radius: 8px;
}

.messages-thread-peer:focus-visible,
.messages-thread-header
.message-peer-avatar:focus-visible {
  outline: 2px solid rgba(255, 76, 158, .7);
  outline-offset: 3px;
}

/* GRFTSH DEFAULT USER AVATAR V1 */

/*
  Ne jamais réafficher une action volontairement masquée par le JS.
  Important sur smartphone où les règles display:grid utilisent !important.
*/
.public-profile-message-button[hidden],
.public-profile-compact-actions
#public-profile-follow-button[hidden],
.public-profile-compact-actions
[hidden] {
  display: none !important;
}

/* GRFTSH PRIVATE MESSAGE IMAGES FRONTEND V1 */

.messages-composer {
  grid-template-columns:
    44px minmax(0, 1fr) auto;
  align-items: end;
}

.messages-photo {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  background: #171717;
  color: #d9d9d9;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.messages-photo:hover,
.messages-photo:focus-visible {
  border-color: rgba(255,76,158,.42);
  color: #ff6aae;
}

.messages-photo:disabled {
  opacity: .45;
  cursor: default;
}

.messages-photo svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.message-image-shell {
  display: grid;
  gap: 7px;
  min-width: 170px;
}

.message-media-retention {
  color: #8d8d8d;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.message-private-image {
  display: block;
  width: min(320px, 100%);
  max-height: 420px;
  object-fit: cover;
  border-radius: 11px;
  background: #0b0b0b;
  cursor: pointer;
}

.message-private-image.is-open {
  width: min(520px, 100%);
  max-height: 68vh;
  object-fit: contain;
}

.message-image-open {
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid rgba(255,76,158,.42);
  border-radius: 11px;
  background: rgba(255,76,158,.1);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.message-image-open:disabled {
  opacity: .5;
  cursor: default;
}

.message-media-status {
  padding: 12px;
  border: 1px dashed rgba(255,255,255,.13);
  border-radius: 11px;
  color: #777;
  font-size: 12px;
  text-align: center;
}

.message-image-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0,0,0,.76);
  backdrop-filter: blur(7px);
}

.message-image-modal {
  width: min(520px, calc(100vw - 28px));
  max-height: min(760px, calc(100dvh - 28px));
  overflow-y: auto;
  padding: 18px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 18px;
  background: #101010;
  box-shadow: 0 22px 70px rgba(0,0,0,.5);
}

.message-image-modal h3 {
  margin: 0 0 14px;
  font-size: 17px;
}

.message-image-modal-preview {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 13px;
  background: #080808;
}

.message-image-modal p {
  margin: 13px 0;
  color: #aaa;
  font-size: 12px;
  line-height: 1.5;
}

.message-image-retention-choices {
  display: grid;
  gap: 9px;
}

.message-image-retention-choice {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 12px;
  background: #171717;
  color: #fff;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.message-image-retention-choice.is-primary {
  border-color: rgba(255,76,158,.42);
  background: rgba(255,76,158,.08);
}

.message-image-retention-choice strong {
  font-size: 13px;
}

.message-image-retention-choice small {
  color: #8c8c8c;
  font-size: 11px;
  line-height: 1.4;
}

.message-image-modal-cancel {
  width: 100%;
  margin-top: 10px;
  min-height: 40px;
  border: 0;
  background: transparent;
  color: #888;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

@media (max-width: 900px) {
  .messages-composer {
    grid-template-columns:
      44px minmax(0, 1fr) 46px;
    gap: 8px;
  }

  .messages-photo {
    width: 44px;
    min-width: 44px;
    height: 46px;
    min-height: 46px;
    border-radius: 14px;
  }

  .message-bubble:has(.message-image-shell) {
    max-width: 92%;
  }

  .message-private-image {
    width: min(280px, 100%);
    max-height: 46vh;
  }

  .message-private-image.is-open {
    width: 100%;
    max-height: 62vh;
  }

  .message-image-modal {
    padding: 15px;
    border-radius: 16px;
  }
}

/* GRFTSH MESSAGING LIVE REFRESH MEDIA POLISH V1 */

.message-private-image[hidden] {
  display: none !important;
}

.message-private-image {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

.message-image-shell {
  overflow: hidden;
}

.message-image-open {
  width: 100%;
}

/* Aucun mode de rétention n'est pré-sélectionné visuellement. */
.message-image-retention-choice,
.message-image-retention-choice.is-primary {
  border-color: rgba(255,255,255,.11);
  background: #171717;
}

.message-image-retention-choice:hover,
.message-image-retention-choice:focus-visible {
  border-color: rgba(255,76,158,.48);
  background: rgba(255,76,158,.08);
}

@media (max-width: 900px) {
  .message-image-shell {
    min-width: 0;
    width: min(100%, 310px);
  }

  .message-bubble:has(.message-image-shell) {
    width: min(92%, 340px);
    max-width: 92%;
  }

  .message-image-open {
    min-height: 48px;
  }
}



/* GRFTSH MESSAGE EDIT DELETE V1 */

.message-bubble-row {
  position: relative;
}

.message-actions-button {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  margin-bottom: 3px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #777;
  font: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.message-actions-button:hover,
.message-actions-button:focus-visible {
  background: rgba(255,255,255,.06);
  color: #ddd;
}

.message-action-menu {
  position: absolute;
  right: 0;
  bottom: 34px;
  z-index: 20;
  display: grid;
  min-width: 150px;
  padding: 6px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  background: #151515;
  box-shadow: 0 12px 34px rgba(0,0,0,.42);
}

.message-action-menu button {
  min-height: 38px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #eee;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  text-align: left;
  cursor: pointer;
}

.message-action-menu button:hover,
.message-action-menu button:focus-visible {
  background: rgba(255,255,255,.06);
}

.message-action-menu button.is-danger {
  color: #ff6aae;
}

.message-action-overlay {
  position: fixed;
  inset: 0;
  z-index: 10100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(6px);
}

.message-edit-modal {
  width: min(520px, calc(100vw - 28px));
  padding: 18px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 17px;
  background: #111;
  box-shadow: 0 22px 70px rgba(0,0,0,.52);
}

.message-edit-modal h3 {
  margin: 0 0 13px;
  font-size: 17px;
}

.message-edit-modal textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 130px;
  max-height: 42vh;
  resize: vertical;
  padding: 11px 12px;
  border: 1px solid #383838;
  border-radius: 12px;
  outline: none;
  background: #171717;
  color: #fff;
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
}

.message-edit-modal textarea:focus {
  border-color: rgba(255,76,158,.5);
}

.message-edit-counter {
  margin-top: 6px;
  color: #737373;
  font-size: 10px;
  text-align: right;
}

.message-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 13px;
}

.message-edit-actions button {
  min-height: 39px;
  padding: 8px 13px;
  border: 1px solid #383838;
  border-radius: 10px;
  background: #171717;
  color: #eee;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.message-edit-actions button.is-primary {
  border-color: rgba(255,76,158,.48);
  background: rgba(255,76,158,.12);
}

.message-edit-actions button:disabled {
  opacity: .5;
  cursor: default;
}

@media (max-width: 900px) {
  .message-actions-button {
    width: 34px;
    height: 34px;
  }

  .message-action-menu {
    min-width: 160px;
  }

  .message-edit-modal {
    padding: 15px;
  }
}

/* GRFTSH MESSAGE EDIT MOBILE VIEWPORT V1 */

/*
  iOS zoome automatiquement les champs dont la taille de police
  est inferieure a 16px. On force donc 16px sur mobile.
  Le modal reste aussi contenu dans le viewport, clavier compris.
*/
@media (max-width: 900px) {
  .message-action-overlay {
    align-items: end;
    padding:
      12px
      12px
      calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .message-edit-modal {
    box-sizing: border-box;
    display: flex;
    width: 100%;
    max-height:
      calc(100dvh - 24px - env(safe-area-inset-bottom, 0px));
    flex-direction: column;
    overflow: hidden;
  }

  .message-edit-modal textarea {
    min-height: 110px;
    max-height: min(38dvh, 260px);
    flex: 1 1 auto;
    resize: none;
    font-size: 16px;
  }

  .message-edit-counter {
    flex: 0 0 auto;
  }

  .message-edit-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    flex: 0 0 auto;
    padding-top: 10px;
    background: #111;
  }

  .message-edit-actions button {
    min-height: 44px;
  }
}

/* GRFTSH MESSAGE EDIT MOBILE VIEWPORT V1 */


/* ============================================================
   MESSAGE REQUEST GUIDANCE V1
   ============================================================ */

.message-request-guidance {
  display: grid;
  gap: 7px;
  margin: 0 0 14px;
  padding: 11px 12px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 12px;
  background: rgba(255,255,255,.035);
}

.message-request-guidance[hidden] {
  display: none !important;
}

.message-request-guidance > strong {
  color: #e8e8e8;
  font-size: 11px;
  font-weight: 800;
}

#message-request-guidance-content {
  display: grid;
  gap: 6px;
}

#message-request-guidance-content p {
  margin: 0;
  color: #9d9d9d;
  font-size: 11px;
  line-height: 1.45;
}

/* ============================================================
   GRFTSH MESSAGING READONLY UI V1
   ============================================================ */

.messages-readonly-notice {
  display: grid;
  gap: 5px;

  padding: 13px 16px;

  border-top:
    1px solid rgba(255, 255, 255, 0.08);

  background:
    rgba(255, 255, 255, 0.035);
}


.messages-readonly-notice[hidden] {
  display: none;
}


.messages-readonly-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}


.messages-readonly-text {
  font-size: 12px;
  line-height: 1.5;

  color:
    rgba(255, 255, 255, 0.7);
}



/* GRFTSH VIEW ONCE 10S COUNTDOWN V1 */

.message-view-once-countdown {
  justify-self: end;

  min-width: 42px;
  padding: 4px 9px;

  border:
    1px solid rgba(255, 76, 158, .32);

  border-radius: 999px;

  background:
    rgba(255, 76, 158, .09);

  color: #ff79b8;

  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;

  font-variant-numeric:
    tabular-nums;
}


@media (max-width: 900px) {
  .message-view-once-countdown {
    min-width: 46px;
    padding: 5px 10px;

    font-size: 12px;
  }
}

/* ==========================================================
   GRFTSH IOS CHAT SCROLL STABILITY V1
   ========================================================== */

@media (max-width: 900px) {

  .messages-layout,
  .messages-thread {
    overscroll-behavior: none;
  }

  .messages-thread-body {
    overscroll-behavior-y: contain;
    overscroll-behavior-x: none;

    touch-action:
      pan-y pinch-zoom;

    -webkit-overflow-scrolling:
      touch;

    overflow-anchor:
      none;
  }

  .message-bubble,
  .message-bubble-row {
    transform:
      translateZ(0);
  }

}


/* GRFTSH_VOICE_COMPOSER_UI_V1 */
.messages-composer:has(> .messages-voice:not([hidden])) {
  grid-template-columns:
    44px 44px minmax(0, 1fr) auto;
}

.messages-voice {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  background: #171717;
  color: #d9d9d9;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.messages-voice[hidden] {
  display: none !important;
}

.messages-voice:hover,
.messages-voice:focus-visible {
  border-color: rgba(255,76,158,.42);
  color: #ff6aae;
}

.messages-voice:disabled {
  opacity: .45;
  cursor: default;
}

.messages-voice svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 900px) {
  .messages-composer:has(> .messages-voice:not([hidden])) {
    grid-template-columns:
      44px 44px minmax(0, 1fr) 46px;
    gap: 8px;
  }

  .messages-voice {
    height: 46px;
    min-height: 46px;
    border-radius: 14px;
  }
}


/* GRFTSH_VOICE_RECORDER_PANEL_V1 */
.messages-voice-panel {
  grid-column: 1 / -1;
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255,76,158,.22);
  border-radius: 12px;
  background: #171717;
}

.messages-voice-panel[hidden],
.messages-voice-panel [hidden] {
  display: none !important;
}

.messages-voice-timer {
  color: #ff6aae;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.messages-voice-panel audio {
  flex: 1 1 180px;
  min-width: 0;
  max-width: 100%;
}

.messages-voice-panel button {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 10px;
  background: #242424;
  color: #fff;
  cursor: pointer;
}

.messages-voice-panel button:disabled {
  opacity: .5;
  cursor: default;
}

@media (max-width: 900px) {
  .messages-voice-panel {
    gap: 8px;
  }

  .messages-voice-panel audio {
    flex-basis: 100%;
  }
}


/* GRFTSH_VOICE_MESSAGE_PLAYER_V1 */
.message-voice-shell {
  display: grid;
  gap: 9px;
  min-width: 0;
  width: min(280px, 100%);
}

.message-voice-title {
  color: #f1f1f1;
  font-size: 13px;
  font-weight: 600;
}

.message-voice-duration {
  color: #aaa;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.message-voice-audio {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 42px;
}

.message-voice-unavailable {
  color: #aaa;
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 900px) {
  .message-bubble:has(.message-voice-shell) {
    max-width: 92%;
  }

  .message-voice-shell {
    width: min(260px, 100%);
  }
}


/* GRFTSH_VOICE_COMPOSER_GRID_FIX_V1 */

/* Première ligne : outils et saisie */
.messages-composer > #messages-photo,
.messages-composer > #messages-voice:not([hidden]),
.messages-composer > #messages-composer-text {
  grid-row: 1;
}

.messages-composer > #messages-send {
  grid-row: 1;
  grid-column: -2 / -1;
  align-self: end;
}

/* Deuxième ligne : panneau audio uniquement */
.messages-composer > .messages-voice-panel {
  grid-column: 1 / -1;
  grid-row: 2;
  min-width: 0;
}

.messages-composer > .messages-voice-panel[hidden] {
  display: none !important;
}


/* GRFTSH_VOICE_HOLD_TO_SEND_V1 */

.messages-voice {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.messages-composer.voice-holding
  > #messages-composer-text,
.messages-composer.voice-holding
  > #messages-send {
  display: none !important;
}

.messages-composer.voice-holding
  > .messages-voice-panel {
  grid-row: 1;
  grid-column: 3 / -1;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  min-height: 44px;
  padding: 7px 10px;
}

.messages-composer.voice-holding
  > .messages-voice-panel::before {
  content: '';
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ed4760;
  animation: grftsh-voice-pulse 1s infinite;
}

.messages-voice-hint {
  font-size: 12px;
  color: #aaa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.messages-composer.voice-holding
  .messages-voice-panel audio,
.messages-composer.voice-holding
  .messages-voice-panel button {
  display: none !important;
}

.messages-composer.voice-holding
  .messages-voice-timer {
  flex-shrink: 0;
}

.messages-composer.voice-holding
  > .messages-voice {
  border-color: #ed4760;
  color: #ff6aae;
}

@keyframes grftsh-voice-pulse {
  50% { opacity: .3; }
}

@media (max-width: 600px) {
  .messages-composer.voice-holding
    > .messages-voice-panel {
    padding: 6px;
    gap: 6px;
  }

  .messages-voice-hint {
    font-size: 11px;
  }
}


/* GRFTSH_VOICE_TOUCH_HOVER_FIX_V1 */

/* Pas de survol persistant sur écran tactile. */
@media (hover: none) {
  .messages-voice:not(:focus-visible) {
    border-color: rgba(255,255,255,.12);
    color: #d9d9d9;
  }

  .messages-composer.voice-holding
    > .messages-voice {
    border-color: #ed4760;
    color: #ff6aae;
  }
}

/* Survol uniquement sur un vrai pointeur. */
@media (hover: hover) and (pointer: fine) {
  .messages-voice:hover {
    border-color: rgba(255,76,158,.42);
    color: #ff6aae;
  }
}


/* GRFTSH_VOICE_FLOATING_TIMER_V1 */

/* Le composer sert d'ancrage à la pastille. */
.messages-composer {
  position: relative;
}

/* Pendant le vocal, la saisie reste à sa place,
   mais la pastille apparaît au-dessus. */
.messages-composer.voice-holding
  > #messages-composer-text {
  display: block !important;
  visibility: hidden;
  pointer-events: none;
}

.messages-composer.voice-holding
  > #messages-send {
  visibility: hidden;
  pointer-events: none;
}

/* Pastille indépendante de la grille. */
.messages-composer.voice-holding
  > .messages-voice-panel {
  position: absolute;
  z-index: 20;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);

  width: max-content;
  max-width: calc(100% - 16px);
  min-height: 40px;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;

  padding: 8px 15px;
  border: 1px solid rgba(255,106,174,.35);
  border-radius: 999px;
  background: #242424;

  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  white-space: nowrap;
  pointer-events: none;
}

.messages-composer.voice-holding
  > .messages-voice-panel::before {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
}

.messages-composer.voice-holding
  .messages-voice-timer {
  font-size: 15px;
  font-weight: 700;
}

.messages-composer.voice-holding
  .messages-voice-hint {
  font-size: 12px;
  color: #d0d0d0;
}

/* La pastille ne doit jamais apparaître au repos. */
.messages-composer:not(.voice-holding)
  > .messages-voice-panel {
  display: none !important;
}

@media (max-width: 600px) {
  .messages-composer.voice-holding
    > .messages-voice-panel {
    gap: 9px;
    padding: 8px 12px;
    max-width: calc(100% - 8px);
  }
}


/* GRFTSH_VOICE_MOBILE_FLOAT_FIX_V1 */

@media (max-width: 600px) {

  /* Autoriser la pastille à dépasser du composer. */
  .messages-composer {
    overflow: visible !important;
  }

  /* Positionner la pastille au-dessus du composer. */
  .messages-composer.voice-holding
    > .messages-voice-panel {
    position: absolute !important;

    bottom: calc(100% + 8px) !important;
    left: 50% !important;

    transform: translateX(-50%) !important;

    grid-column: auto !important;
    grid-row: auto !important;

    width: max-content !important;
    max-width: calc(100% - 16px) !important;
    min-width: 0 !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    gap: 9px !important;
    padding: 8px 12px !important;

    overflow: visible !important;
    box-shadow: 0 8px 24px rgba(0,0,0,.3) !important;
  }

  /* Chronomètre clairement visible. */
  .messages-composer.voice-holding
    .messages-voice-timer {
    display: inline !important;
    visibility: visible !important;
    flex-shrink: 0;
  }

  .messages-composer.voice-holding
    .messages-voice-hint {
    flex: 0 1 auto;
    min-width: 0;
    font-size: 11px;
  }

  /* La pastille reste purement informative. */
  .messages-composer.voice-holding
    > .messages-voice-panel {
    pointer-events: none !important;
  }
}
