/* V1.38: a content-independent Social frame on desktop, tablet and phone. */
#modalBackdrop.social-panel-open { overscroll-behavior:contain; }
#modalCard.social-sheet { min-width:0; }
#modalCard.social-sheet #modalTitle { outline:none; }
#modalCard.social-sheet .social-tabs { overflow:visible; }
#modalCard.social-sheet .social-tabs button {
  position:relative; outline-offset:-3px; -webkit-tap-highlight-color:transparent;
}
#modalCard.social-sheet .social-tabs button[aria-current="page"] {
  box-shadow:inset 0 0 0 1px #c5fa474d;
}
#modalCard.social-sheet .social-tabs button:focus-visible {
  outline:2px solid var(--lime); outline-offset:-3px;
}
.social-panel-body { min-width:0; }
.social-panel-loading { display:grid; place-content:center; min-height:180px; text-align:center; padding:24px; color:#a5b1c3; font-size:13px; line-height:1.6; }
.social-panel-loading strong { display:block; color:#e9f1db; font-size:16px; margin-bottom:8px; }
.social-panel-loading .text-button { min-height:44px; margin-top:12px; }
.social-panel-heading { min-width:0; }
/* All six hub tabs share this frame. Only the inner body can scroll.
   Height follows the available viewport, never the selected tab or its data. */
#modalBackdrop.social-panel-open { place-items:center; }
#modalCard.social-frame {
  width:min(760px,100%) !important; max-width:100%;
  height:min(820px,calc(var(--social-visible-height,100dvh) - 48px));
  max-height:min(820px,calc(var(--social-visible-height,100dvh) - 48px));
  min-height:0; padding:0; overflow:hidden; border-radius:25px;
  transform:none; transition:none;
}
#modalCard.social-frame #modalContent {
  display:flex; flex-direction:column; height:100%; min-height:0;
  padding:0; overflow:hidden;
}
#modalCard.social-frame .social-panel-heading {
  flex:none; padding:30px 30px 0;
}
#modalCard.social-frame .social-top { padding-right:44px; }
#modalCard.social-frame .modal-intro { margin-bottom:0; }
#modalCard.social-frame .social-tabs {
  flex:none; display:grid; grid-template-columns:repeat(6,minmax(0,1fr));
  margin:22px 30px 0; padding-bottom:9px;
}
#modalCard.social-frame .social-tabs button { min-width:0; }
#modalCard.social-frame .social-panel-body {
  flex:1 1 0; min-width:0; min-height:0; padding:22px 30px 18px;
  overflow-x:hidden; overflow-y:auto; scrollbar-gutter:stable;
  overscroll-behavior:contain; -webkit-overflow-scrolling:touch;
  scroll-padding-block:16px; overflow-anchor:none;
}
#modalCard.social-frame .social-bottom {
  flex:none; margin:0; padding:10px 30px; min-height:64px;
}
/* A native scrollbar fallback still reserves width on older engines. */
@supports not (scrollbar-gutter:stable) {
  #modalCard.social-frame .social-panel-body { overflow-y:scroll; }
}
/* Chat uses the same outside frame. Its list and timeline scroll independently
   so the message composer stays reachable instead of extending the dialog. */
@media (min-width:601px) {
  #modalCard.social-frame[data-kind="social-chats"] .social-panel-body {
    display:flex; flex-direction:column; overflow:hidden; scrollbar-gutter:auto;
  }
  #modalCard.social-frame .chat-layout {
    flex:1 1 0; min-height:0; grid-template-rows:minmax(0,1fr);
  }
  #modalCard.social-frame .chat-sidebar {
    min-height:0; max-height:none; overflow-y:auto;
    overscroll-behavior:contain; scrollbar-gutter:stable;
  }
  #modalCard.social-frame .chat-pane { height:100%; min-height:0; }
  #modalCard.social-frame .chat-timeline {
    min-height:0; overscroll-behavior:contain; scrollbar-gutter:stable;
  }
  #modalCard.social-frame[data-kind="social-chats"] #socialError { flex:none; }
}
/* Short desktop windows need usable content space as well as a stable frame. */
@media (min-width:721px) and (max-height:600px) {
  #modalCard.social-frame .social-panel-heading { padding:16px 22px 0; }
  #modalCard.social-frame .social-symbol { width:32px; height:32px; border-radius:10px; }
  #modalCard.social-frame h2#modalTitle { font-size:23px; }
  #modalCard.social-frame .modal-intro { display:none; }
  #modalCard.social-frame .social-tabs { margin:10px 22px 0; }
  #modalCard.social-frame .social-panel-body { padding:12px 22px; }
  #modalCard.social-frame .social-bottom { min-height:52px; padding:4px 22px; }
}
@media (min-width:721px) and (max-height:420px) {
  #modalCard.social-frame .social-panel-heading #modalTitle { display:none; }
  #modalCard.social-frame .social-bottom { display:none; }
  #modalCard.social-frame .chat-pane-head { padding:8px 12px; }
  #modalCard.social-frame .chat-pane-head small,
  #modalCard.social-frame .chat-pane-head .section-kicker,
  #modalCard.social-frame .chat-composer small { display:none; }
  #modalCard.social-frame .chat-composer { padding:8px; }
  #modalCard.social-frame .chat-composer textarea { height:48px; min-height:48px; }
}

@media (max-width:720px), (pointer:coarse) and (max-height:520px) {
  #modalBackdrop.social-panel-open {
    display:block; padding:0; overflow:hidden;
    /* No filtered fixed-position ancestor for the viewport-positioned sheet. */
    -webkit-backdrop-filter:none; backdrop-filter:none;
    background:rgba(3,5,8,.87);
  }
  #modalBackdrop.social-panel-open #modalCard.social-sheet {
    --panel-top-gap:max(8px,var(--safe-top,0px));
    --panel-bottom-gap:max(8px,var(--safe-bottom,0px));
    --panel-left-gap:max(8px,var(--safe-left,0px));
    --panel-right-gap:max(8px,var(--safe-right,0px));
    position:absolute; top:calc(var(--social-visible-top,0px) + var(--panel-top-gap));
    left:calc(var(--social-visible-left,0px) + var(--panel-left-gap)); right:auto;
    width:calc(var(--social-visible-width,100vw) - var(--panel-left-gap) - var(--panel-right-gap)) !important;
    height:calc(var(--social-visible-height,100dvh) - var(--panel-top-gap) - var(--panel-bottom-gap));
    max-height:calc(var(--social-visible-height,100dvh) - var(--panel-top-gap) - var(--panel-bottom-gap));
    min-height:0; margin:0; padding:0; overflow:hidden;
    border-radius:22px; transform:none; transition:none;
    box-shadow:0 14px 48px #0007;
  }
  #modalCard.social-sheet #modalContent {
    min-height:0; height:100%; overflow-x:hidden; overflow-y:auto;
    padding:58px 16px 18px; overscroll-behavior:contain; -webkit-overflow-scrolling:touch;
  }
  #modalCard.social-sheet .modal-close {
    position:absolute; top:10px; right:10px; width:44px; min-width:44px; height:44px;
    border-radius:13px; background:#252c37; z-index:6;
  }
  #modalCard.social-frame #modalContent {
    display:flex; flex-direction:column; padding:0; overflow:hidden;
  }
  #modalCard.social-frame .social-panel-heading {
    flex:none; padding:18px 16px 0;
  }
  #modalCard.social-frame .social-top { min-height:38px; padding-right:48px; gap:10px; }
  #modalCard.social-frame .social-symbol { width:36px; height:36px; border-radius:11px; flex:none; }
  #modalCard.social-frame .social-symbol svg { width:22px; height:22px; }
  #modalCard.social-frame .modal-eyebrow { font-size:10px; letter-spacing:.1em; }
  #modalCard.social-frame h2#modalTitle {
    padding:0; margin:12px 0 6px; font-size:clamp(23px,6.5vw,30px); line-height:1.15;
  }
  #modalCard.social-frame .modal-intro { margin:0; font-size:12px; line-height:1.45; }
  #modalCard.social-frame .social-tabs {
    flex:none; display:grid; grid-template-columns:repeat(3,minmax(0,1fr));
    gap:5px; margin:12px 16px 0; padding:0 0 12px; overflow:visible;
  }
  #modalCard.social-frame .social-tabs button {
    min-width:0; min-height:44px; padding:8px 4px; border-radius:12px; font-size:12px;
  }
  #modalCard.social-frame .social-panel-body {
    flex:1; min-height:0; padding:16px; overflow-x:hidden; overflow-y:auto;
    overscroll-behavior:contain; -webkit-overflow-scrolling:touch; scroll-padding-block:12px;
  }
  #modalCard.social-frame .social-bottom {
    flex:none; margin:0; padding:8px 16px; gap:10px; min-height:58px; background:#121721;
  }
  #modalCard.social-frame .social-bottom > span { font-size:9px; max-width:45%; }
  #modalCard.social-frame .social-bottom .text-button { font-size:10px; padding:4px 0; }
  #modalCard.social-frame .social-search { gap:8px; }
  #modalCard.social-frame .social-search input { min-height:48px; padding:10px 11px; font-size:16px; }
  #modalCard.social-frame .social-search button { min-height:48px; padding:8px 11px; font-size:12px; }
  #modalCard.social-frame .search-hint,#modalCard.social-frame .social-caption { font-size:11px; line-height:1.5; }
  #modalCard.social-frame .social-empty { padding:22px 14px; }
  #modalCard.social-frame .social-empty h3 { font-size:17px; }
  #modalCard.social-frame .social-empty p { font-size:12px; }
  #modalCard.social-frame .social-section-title { margin:18px 0 10px; }
  #modalCard.social-frame .social-player { flex-wrap:wrap; gap:10px; padding:12px; }
  #modalCard.social-frame .social-player-info { flex:1 1 120px; }
  #modalCard.social-frame .social-player-actions { max-width:100%; flex:none; margin-left:auto; }
  #modalCard.social-frame .social-tabs button span { font-size:9px; margin-left:2px; }
  #modalCard.social-frame .social-panel-heading:has(+ .social-tabs) { padding-bottom:0; }
  /* When the keyboard is up, prioritize the search or chat, not decorative copy. */
  #modalCard.social-frame[data-social-compact="true"] .social-panel-heading { padding-top:12px; }
  #modalCard.social-frame[data-social-compact="true"] .social-panel-heading #modalTitle,
  #modalCard.social-frame[data-social-compact="true"] .social-panel-heading .modal-intro { display:none; }
  #modalCard.social-frame[data-social-compact="true"] .social-tabs { margin-top:8px; gap:3px; padding-bottom:7px; }
  #modalCard.social-frame[data-social-compact="true"] .social-bottom { display:none; }
  #modalCard.social-frame[data-social-compact="true"] .social-panel-body { padding-block:10px; }
}
@media (pointer:coarse) and (orientation:landscape) and (max-height:520px) {
  #modalCard.social-frame .social-tabs { grid-template-columns:repeat(6,minmax(0,1fr)); margin-top:5px; }
}
@media (max-width:600px) {
  /* Override the old independent fixed chat rectangle. The shared sheet owns
     viewport positioning; only its timeline scrolls in an open conversation. */
  #modalCard.social-sheet[data-kind="social-chats"]:has(.chat-layout.is-thread) #modalContent { display:flex; }
  #modalCard.social-sheet[data-kind="social-chats"]:has(.chat-layout.is-thread) .social-panel-heading,
  #modalCard.social-sheet[data-kind="social-chats"]:has(.chat-layout.is-thread) .social-tabs { display:none; }
  #modalCard.social-sheet[data-kind="social-chats"]:has(.chat-layout.is-thread) .social-panel-body {
    display:flex; flex-direction:column; padding:0; overflow:hidden; flex:1;
  }
  #modalCard.social-sheet[data-kind="social-chats"]:has(.chat-layout.is-thread) .chat-layout { flex:1; min-height:0; height:100%; }
  #modalCard.social-sheet[data-kind="social-chats"]:has(.chat-layout.is-thread) .chat-pane { min-height:0; height:100%; }
  #modalCard.social-sheet[data-kind="social-chats"]:has(.chat-layout.is-thread) #socialError:not(:empty) { flex:none; padding:6px 14px; }
  #modalCard.social-sheet[data-kind="social-chats"]:has(.chat-layout.is-thread) .chat-composer { padding-bottom:10px; }
  #modalCard.social-sheet[data-kind="social-chats"]:has(.chat-layout.is-thread) .chat-pane-head { padding:10px 12px; }
  #modalCard.social-sheet[data-kind="social-chats"]:has(.chat-layout.is-thread) .chat-pane-head h3 { font-size:17px; }
  #modalCard.social-sheet[data-kind="social-chats"]:has(.chat-layout.is-thread) .chat-mobile-toolbar { padding-right:62px; }
  #modalCard.social-sheet[data-social-compact="true"] .chat-pane-head .section-kicker,
  #modalCard.social-sheet[data-social-compact="true"] .chat-pane-head small,
  #modalCard.social-sheet[data-social-compact="true"] .chat-composer small { display:none; }
  #modalCard.social-sheet[data-social-compact="true"] .chat-mobile-toolbar { height:58px; }
  #modalCard.social-sheet[data-social-compact="true"] .chat-pane-head { padding-block:5px; }
  #modalCard.social-sheet[data-social-compact="true"] .chat-composer textarea { height:48px; min-height:48px; }
}
