/* V1227: mobile/tablet-only comments. Absolutely no desktop, live-on-Reels,
 * playback, feed card, or endpoint styling is changed. */
@media(max-width:899px){
 /* The video/photo stage remains visible, but should never consume most of the
    comments viewport. The existing native media node stays in place. */
 html body .social-shell dialog.social-comments.f1158-ui.f1158-has-stage:not([hidden]):not(.f1158-live-original):not(.f1009-live-reel-panel) .f1158-media-stage,
 html body .social-shell .f862-ad-sheet.f1158-ui.f1158-has-stage:not([hidden]) .f1158-media-stage{
  flex:0 0 clamp(118px,25dvh,244px)!important;
  height:clamp(118px,25dvh,244px)!important;max-height:25dvh!important;
  min-height:0!important;padding:12px 12px 4px!important;
  transition:flex-basis .24s ease,height .24s ease,max-height .24s ease!important;
 }
 html body .social-shell dialog.social-comments.f1158-ui.f859-expanded.f1158-has-stage:not([hidden]):not(.f1158-live-original) .f1158-media-stage,
 html body .social-shell .f862-ad-sheet.f1158-ui.f859-expanded.f1158-has-stage:not([hidden]) .f1158-media-stage{
  flex-basis:clamp(70px,10dvh,105px)!important;height:clamp(70px,10dvh,105px)!important;
  max-height:11dvh!important;padding-top:4px!important;
 }
 /* Never size the comment list from the media thumbnail or caption content.
    The actual comments scroll independently, keeping the composer pinned. */
 html body .social-shell dialog.social-comments.f1158-ui:not([hidden]) .f1158-sheet,
 html body .social-shell .f862-ad-sheet.f1158-ui:not([hidden]) .f1158-sheet{
  display:flex!important;flex:1 1 auto!important;flex-direction:column!important;
  min-height:0!important;overflow:hidden!important;
 }
 html body .social-shell dialog.social-comments.f1158-ui .f1158-sheet>.social-comment-list,
 html body .social-shell .f862-ad-sheet.f1158-ui .f1158-sheet>.social-comment-list{
  display:block!important;flex:1 1 0!important;min-height:100px!important;
  overflow-x:hidden!important;overflow-y:auto!important;touch-action:pan-y!important;
  overscroll-behavior-y:contain!important;-webkit-overflow-scrolling:touch!important;
  padding-bottom:18px!important;
 }
 /* Preserve the original Home action row; prevent the caption turning into
    a second scrollable region that traps touch gestures. */
 html body .social-shell dialog.social-comments.f1158-ui .f1158-feed-card .f1227-mobile-caption,
 html body .social-shell .f862-ad-sheet.f1158-ui .f1158-feed-card .f1227-mobile-caption,
 html body .f254-media-lightbox .f1227-mobile-caption{
  position:relative!important;height:auto!important;max-height:none!important;
  overflow:visible!important;white-space:normal!important;
  line-height:1.45!important;font-size:13px!important;
  margin-top:4px!important;margin-bottom:3px!important;
 }
 html body .social-shell .f1158-ui .f1158-feed-card{
  max-height:none!important;min-height:0!important;
 }
 html body .social-shell .f1158-ui .f1158-feed-card>.social-post-text.f1227-mobile-caption{
  max-height:none!important;margin:4px 0 3px!important;overflow:visible!important;
 }
 html body .f1227-mobile-caption .social-expand-toggle{
  display:inline!important;white-space:nowrap!important;
  font-size:13px!important;font-weight:700!important;cursor:pointer!important;
 }
 html body .f1227-mobile-caption .social-expand-toggle[hidden]{display:none!important}
 html body .social-shell dialog.social-comments.f1158-ui .f1158-feed-card .social-post-actions{
  min-height:30px!important;margin:2px 0 0!important;padding:2px 0 0!important;
 }
 html body .social-shell dialog.social-comments.f1158-ui .social-comments-head,
 html body .social-shell .f862-ad-sheet.f1158-ui .social-comments-head{
  flex:0 0 auto!important;min-height:46px!important;touch-action:none!important;
 }
 /* Native comments have a large tappable media preview. A tall attachment
    scrolls inside the comments area rather than being cropped by the sheet. */
 html body .social-shell .f1158-ui .social-comment-media :is(img,video),
 html body .social-shell .f862-ad-sheet.f1158-ui .social-comment-media :is(img,video){
  max-width:100%!important;max-height:min(52dvh,470px)!important;
  width:auto!important;height:auto!important;object-fit:contain!important;
 }
 html body .social-shell .f1158-ui .social-comment-media,
 html body .social-shell .f862-ad-sheet.f1158-ui .social-comment-media{
  max-height:none!important;overflow:visible!important;min-width:0!important;
 }
 /* Buttons are in the same list as original comments, so clicking never
    replaces a thread, changes its sorting, or resets its scroll position. */
 html body .social-shell .f1158-ui .f1227-reply-concealed,
 html body .social-shell .f862-ad-sheet.f1158-ui .f1227-reply-concealed{display:none!important}
 html body .social-shell .f1158-ui .f1227-more-replies,
 html body .social-shell .f862-ad-sheet.f1158-ui .f1227-more-replies{
  display:block!important;box-sizing:border-box!important;max-width:100%!important;
  border:0!important;background:transparent!important;
  color:var(--blue,#1778f2)!important;cursor:pointer!important;
  font-size:12px!important;font-weight:700!important;line-height:1.6!important;
  text-align:left!important;margin:2px 0 7px!important;
  padding:7px 6px 7px calc(8px + var(--f1227-reply-indent,12px))!important;
  min-height:34px!important;
 }
 html body .social-shell .f1158-ui .f1227-more-replies.f1227-reply-concealed,
 html body .social-shell .f862-ad-sheet.f1158-ui .f1227-more-replies.f1227-reply-concealed{display:none!important}
 .f1158-ui .f1158-media-stage,.f1158-ui .f1158-sheet{will-change:auto!important}
 .f1227-caption-overlay[hidden]{display:none!important}
 .f1227-caption-overlay{
  position:absolute!important;inset:0!important;z-index:95!important;
  display:flex!important;flex-direction:column!important;min-height:0!important;
  padding:0!important;margin:0!important;
  background:var(--social-surface,#fff)!important;color:var(--social-text,#182233)!important;
  border-radius:20px 20px 0 0!important;overflow:hidden!important;
 }
 .f1227-caption-header{
  display:flex;align-items:center;justify-content:space-between;flex:0 0 auto;
  min-height:52px;padding:8px 18px;border-bottom:1px solid var(--social-border,#e1e5eb);
  font-weight:750;font-size:16px;
 }
 .f1227-caption-header button{
  width:36px;height:36px;display:grid;place-items:center;flex:none;
  border:0;background:var(--social-muted-bg,#f1f3f5);color:inherit;
  border-radius:50%;font-size:25px;line-height:1;
 }
 .f1227-caption-author{flex:0 0 auto;min-height:0;padding:12px 18px 2px;font-size:13px;font-weight:700}
 .f1227-caption-copy{
  flex:1 1 auto;min-height:0;overflow:auto;touch-action:pan-y;
  padding:10px 18px max(20px,env(safe-area-inset-bottom));
  white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.55;font-size:15px;
 }
}
@media(max-width:899px) and (prefers-reduced-motion:reduce){
 .f1158-ui .f1158-media-stage{transition:none!important}
}
