/**
 * App Chrome Contract — LOCKED. Loads last. Single authority for nav + viewport modes.
 * Controlled by js/app-chrome.js → html[data-app-chrome="…"]
 * Do not duplicate these rules in route CSS without updating validate:css-stability.
 */

/* ── Modes with bottom tab bar (mobile) ── */
@media (max-width: 767px) {
  html[data-app-chrome='default'] .app-main,
  html[data-app-chrome='default'] .app-shell__content,
  html[data-app-chrome='fandom'] .app-main,
  html[data-app-chrome='fandom'] .app-shell__content,
  html[data-app-chrome='circles'] .app-main,
  html[data-app-chrome='circles'] .app-shell__content,
  html[data-app-chrome='auth'] .app-main,
  html[data-app-chrome='auth'] .app-shell__content,
  html[data-app-chrome='admin'] .app-main,
  html[data-app-chrome='admin'] .app-shell__content,
  html[data-app-chrome]:not([data-app-chrome='circle-chat']).has-mobile-bottom-nav .app-main,
  html[data-app-chrome]:not([data-app-chrome='circle-chat']).has-mobile-bottom-nav .app-shell__content {
    padding-bottom: var(--mobile-bottom-nav-total, calc(72px + env(safe-area-inset-bottom, 0px))) !important;
  }

  /* ── Circle chat: full viewport messenger, no bottom nav gap ── */
  html[data-app-chrome='circle-chat'],
  html[data-app-chrome='circle-chat'] body {
    overflow: hidden !important;
    height: 100dvh;
    max-height: 100dvh;
    overscroll-behavior: none;
  }

  html[data-app-chrome='circle-chat'] #root,
  html[data-app-chrome='circle-chat'] .app-shell {
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden !important;
    max-height: 100dvh;
  }

  html[data-app-chrome='circle-chat'] .app-main,
  html[data-app-chrome='circle-chat'] .app-shell__content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100dvh;
    overflow: hidden !important;
    padding-bottom: 0 !important;
  }

  html[data-app-chrome='circle-chat'] .mobile-bottom-nav,
  html[data-app-chrome='circle-chat'] .mobile-bottom-nav[hidden] {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    height: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  html[data-app-chrome='circle-chat'] .circles-desktop-shell {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden;
  }

  html[data-app-chrome='circle-chat'] body.circles-shell-page .circles-app {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    max-height: 100%;
  }

  html[data-app-chrome='circle-chat'] body.circles-shell-page .circles-main,
  html[data-app-chrome='circle-chat'] body.circles-shell-page .sf-page--circle-detail,
  html[data-app-chrome='circle-chat'] body.circles-shell-page .circle-chat-page,
  html[data-app-chrome='circle-chat'] body.circles-shell-page .sf-circle-stream-mount,
  html[data-app-chrome='circle-chat'] body.circles-shell-page .sf-circle-chat-root,
  html[data-app-chrome='circle-chat'] body.circles-shell-page .sf-circle-chat,
  html[data-app-chrome='circle-chat'] body.circles-shell-page .circle-chat-shell {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  html[data-app-chrome='circle-chat'] body.circles-shell-page .sf-circle-chat-scroll {
    flex: 1 1 auto;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }

  html[data-app-chrome='circle-chat'] body.circles-shell-page .circle-chat-composer {
    flex: 0 0 auto;
    margin-top: auto;
    width: 100%;
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 6px);
    background: rgba(10, 22, 40, 0.98);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
}
