/* Messenger v1.15: phone-first adaptive chat + contact drawer + fullscreen graph. */
.mobile-sidebar-btn,
.mobile-sidebar-scrim,
#contactGraphCloseBtn {
  display: none;
}

@media (max-width: 760px) {
  .app-shell {
    display: block !important;
    position: relative;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh;
    overflow: hidden;
  }

  .app-shell.hidden {
    display: none !important;
  }

  .chat {
    position: absolute;
    inset: 0;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100%;
    min-width: 0;
    z-index: 1;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: calc(-1 * min(88vw, 340px) - 16px);
    z-index: 850;
    width: min(88vw, 340px) !important;
    max-width: 340px;
    min-width: min(270px, 88vw);
    overflow: hidden;
    border-right: 1px solid var(--line);
    background: #0f172a;
    box-shadow: 18px 0 48px rgba(0, 0, 0, .42);
    transition: left .18s ease;
  }

  .app-shell.mobile-sidebar-open .sidebar {
    left: 0;
  }

  .mobile-sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 840;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(2, 6, 23, .58);
    backdrop-filter: blur(2px);
  }

  .app-shell.mobile-sidebar-open .mobile-sidebar-scrim {
    display: block;
  }

  .mobile-sidebar-btn {
    display: inline-grid;
    place-items: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    margin-right: 2px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #111827;
    color: #e5edf8;
    font-size: 20px;
    line-height: 1;
  }

  .mobile-sidebar-btn:active {
    background: #1e293b;
  }

  /* The drawer is wide enough to be useful, so restore the labels hidden by the old icon rail. */
  .sidebar .brand {
    justify-content: flex-start;
    padding: 14px;
  }

  .sidebar .brand > div:last-child,
  .sidebar .search-wrap {
    display: block;
  }

  .sidebar .profile-copy,
  .sidebar .contact-copy {
    display: flex;
  }

  .sidebar .status-dot {
    display: block;
  }

  .sidebar .profile-card {
    justify-content: flex-start;
    margin: 10px;
    padding: 10px;
    flex-wrap: nowrap;
  }

  .sidebar .profile-card .icon-btn {
    min-width: 34px;
    width: 34px;
    height: 34px;
  }

  .sidebar .contact {
    justify-content: flex-start;
    padding: 9px 10px;
  }

  .sidebar .contacts-empty {
    font-size: 13px;
  }

  .sidebar .contacts-empty::after {
    content: none;
  }

  .sidebar .organizer-bar {
    grid-template-columns: minmax(0, 1fr) auto auto;
    padding: 0 10px 9px;
    gap: 6px;
  }

  .sidebar .folder-filter {
    grid-column: auto;
    width: 100%;
    height: 36px;
    justify-self: stretch;
    padding: 0 8px;
    font-size: 12px;
  }

  .sidebar .organizer-btn {
    min-width: 36px;
    min-height: 36px;
    height: 36px;
    padding: 0 8px;
    font-size: 14px;
  }

  .sidebar .organizer-btn span {
    display: inline;
  }

  .sidebar .group-section {
    max-height: 190px;
    padding: 7px 8px;
  }

  .sidebar .group-section-title {
    display: block;
  }

  .sidebar .group-chat-item {
    justify-content: flex-start;
    padding: 7px 8px;
  }

  .sidebar .group-copy {
    display: flex;
  }

  .chat-header {
    gap: 7px;
    padding: 9px 8px;
    min-height: 62px;
  }

  .chat-person {
    gap: 8px;
  }

  .chat-person .avatar {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .chat-person strong {
    font-size: 15px;
  }

  .call-actions {
    gap: 4px;
    margin-left: 2px;
  }

  .call-btn {
    min-width: 34px;
    width: 34px;
    height: 34px;
    font-size: 16px;
  }

  .messages {
    width: 100%;
    padding: 16px 10px;
  }

  .message {
    max-width: 86%;
  }

  .composer {
    width: 100%;
    padding: 9px 8px calc(9px + env(safe-area-inset-bottom));
    gap: 7px;
  }

  .composer textarea {
    min-width: 0;
    min-height: 42px;
  }

  .composer .send-btn {
    min-height: 42px;
    padding: 0 12px;
    font-size: 14px;
  }

  /* On a phone the contact graph is a real fullscreen workspace, not a narrow sidebar card. */
  body.v115-graph-fullscreen .sidebar {
    overflow: visible !important;
  }

  body.v115-graph-fullscreen .mobile-sidebar-scrim {
    display: none !important;
  }

  body.v115-graph-fullscreen .contact-graph-panel.fullscreen {
    position: fixed !important;
    inset: 0 !important;
    z-index: 1400 !important;
    width: 100vw !important;
    max-width: none !important;
    height: 100dvh !important;
    min-height: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: #08111f;
  }

  body.v115-graph-fullscreen .contact-graph-toolbar {
    min-height: calc(54px + env(safe-area-inset-top));
    padding: calc(7px + env(safe-area-inset-top)) 8px 7px 12px;
  }

  body.v115-graph-fullscreen .contact-graph-toolbar small {
    max-width: 48vw;
  }

  body.v115-graph-fullscreen .contact-graph-stage {
    height: calc(100dvh - 54px - env(safe-area-inset-top)) !important;
    min-height: 0 !important;
  }

  body.v115-graph-fullscreen #contactGraphCloseBtn {
    display: inline-grid;
    color: #fecaca;
    border-color: rgba(248, 113, 113, .42);
    font-size: 20px;
  }

  body.v115-graph-fullscreen .contact-graph-hint {
    bottom: calc(8px + env(safe-area-inset-bottom));
    font-size: 10px;
  }
}
