/* Social: one mobile safe-area owner and direction-aware collapsing navigation. */
@media (max-width:760px) {
  html:root.social-crystal {
    --social-safe-top:max(env(safe-area-inset-top,0px),var(--sabsus-safe-top,0px));
    --social-safe-bottom:max(env(safe-area-inset-bottom,0px),var(--sabsus-safe-bottom,0px));
    --social-mobile-header-height:58px;
    --social-mobile-header-gap:8px;
  }
  /* Native suite CSS already pads body on iOS. The signed-in shell owns the
     insets itself; adding both body and shell padding wastes the status area. */
  html:root.social-crystal[data-sabsus-runtime] body:has(#app>.app) {
    padding-top:0!important;
    padding-bottom:0!important;
  }
  html:root.social-crystal body #app>.app {
    padding-top:calc(var(--social-safe-top) + 6px);
    padding-bottom:calc(var(--social-safe-bottom) + 82px);
    gap:var(--social-mobile-header-gap);
  }
  html:root.social-crystal body #app>.app.is-chats {
    padding-top:calc(max(0px,calc(var(--social-safe-top) - var(--cw-viewport-top,0px))) + 6px);
    padding-bottom:calc(var(--social-safe-bottom) + 82px);
  }
  /* An open conversation has its own header and back action. Remove the
     module header from layout completely, rather than reserving an empty slot. */
  html:root.social-crystal body #app>.app.is-chats:has(.chat-workspace.chat-open) {
    padding-bottom:max(8px,var(--social-safe-bottom));
    gap:0;
  }
  html:root.social-crystal body #app>.app.is-chats:has(.chat-workspace.chat-open)>.topbar {
    display:none!important;
  }
  html:root.social-crystal body #app>.app.is-chats:has(.chat-workspace.chat-open)>.layout {
    flex:1 1 auto;
    margin-top:0;
    min-height:0;
  }
  html:root.social-crystal body #app>.app>.topbar {
    box-sizing:border-box;
    height:var(--social-mobile-header-height);
    min-height:0;
    flex:0 0 auto;
    margin-block:0;
    padding-block:7px;
    border-width:1px;
    overflow:visible;
    /* Keep the real widget visible independently of the glass renderer.
       No translated, opacity-zero or visibility-delayed layer on WebKit. */
    transform:none!important;
    opacity:1!important;
    visibility:visible!important;
    background:var(--card-surface)!important;
    box-shadow:var(--card-edge)!important;
    -webkit-backdrop-filter:blur(18px) saturate(1.12);
    backdrop-filter:blur(18px) saturate(1.12);
    transition:height .20s ease,padding-block .20s ease,border-width .20s ease;
  }
  html:root.social-crystal body #app>.app>.topbar>.sg-pane {display:none!important}
  html:root.social-crystal body #app>.app {transition:row-gap .20s ease}
  html:root.social-crystal body #app>.app.social-header-animating>.topbar {overflow:hidden}
  html:root.social-crystal:not(.nav-open) body #app>.app.social-header-hidden:not(:has(.chat-workspace.chat-open)) {
    row-gap:0;
  }
  html:root.social-crystal:not(.nav-open) body #app>.app.social-header-hidden:not(:has(.chat-workspace.chat-open))>.topbar {
    height:0;
    padding-block:0;
    border-width:0;
    overflow:hidden;
    pointer-events:none;
    box-shadow:none!important;
  }
  html:root.social-crystal body #app>.app.social-header-snap,
  html:root.social-crystal body #app>.app.social-header-snap>.topbar {transition:none!important}
  html:root.social-crystal body #app>.app~.mobile-bottom {
    bottom:calc(8px + var(--social-safe-bottom));
  }
  /* The Social module keeps its own dock even inside the native shell. */
  html:root.social-crystal body:has(#app>.app):not(:has(#app>.app .chat-workspace.chat-open)) div.sb-chat {
    --sb-bottom:calc(82px + var(--social-safe-bottom));
  }
  html:root.social-crystal body:has(#app>.app) div.sb-chat .sb-panel {
    max-height:calc(100dvh - var(--sb-bottom) - var(--social-safe-top) - 10px);
  }
  html:root.social-crystal body .toast {
    bottom:calc(88px + var(--social-safe-bottom));
  }
  html:root.social-crystal.nav-open body #app>.app>.layout>.sidebar {
    top:calc(var(--social-safe-top) + 6px);
    bottom:calc(var(--social-safe-bottom) + 8px);
    max-height:none;
  }
}
@media (max-width:760px) and (prefers-reduced-motion:reduce) {
  html:root.social-crystal body #app>.app,
  html:root.social-crystal body #app>.app>.topbar {transition:none!important}
}
