/* STOCKDIVAR_CHAT_APK_V8332_R1 — scoped viewport fallback for messages.html. */

/* A definite height must survive engines that discard declarations using dvh.
   The page has one layout child plus a closed dialog; it needs no outer grid. */
body.api-messages-route #mainContent.api-messages-page {
  display: block;
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
}

body.api-messages-route .api-chat-shell {
  height: 580px;
  height: clamp(580px, calc(var(--chat-apk-viewport-height, 100vh) - 150px), 820px);
  box-sizing: border-box;
}

/* CSS-only first paint, including while authentication/API requests are pending. */
@media (max-width: 720px) {
  body.api-messages-route { min-height: 100vh; }

  body.api-messages-route .container.layout-shell {
    box-sizing: border-box;
    height: calc(100vh - 158px);
    height: var(--chat-apk-content-height, calc(100vh - 158px));
  }

  body.api-messages-route.api-chat-thread-open .container.layout-shell {
    height: 100vh;
    height: var(--chat-apk-content-height, 100vh);
  }

  body.api-messages-route #mainContent.api-messages-page,
  body.api-messages-route .api-chat-shell { height: 100%; }
}

/* This class also covers native WebViews with a wider layout viewport. */
body.api-messages-route.api-chat-apk-compact {
  min-height: 100vh;
  min-height: var(--chat-apk-viewport-height, 100vh);
  overflow: hidden;
  background: var(--chat-page);
}

body.api-messages-route.api-chat-apk-compact .container.layout-shell {
  display: block !important;
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  min-height: 0;
  height: calc(100vh - 158px);
  height: var(--chat-apk-content-height, calc(100vh - 158px));
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body.api-messages-route.api-chat-apk-compact #mainContent.api-messages-page {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body.api-messages-route.api-chat-apk-compact .api-chat-shell {
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-height: 0;
  border-inline: 0;
  border-radius: 0;
  box-shadow: none;
}

body.api-messages-route.api-chat-apk-compact .api-chat-list {
  display: grid;
  width: 100%;
  height: 100%;
  max-height: none;
  border: 0;
}

body.api-messages-route.api-chat-apk-compact .api-chat-main { display: none; }
body.api-messages-route.api-chat-apk-compact .api-chat-shell.is-thread-open .api-chat-list { display: none; }
body.api-messages-route.api-chat-apk-compact .api-chat-shell.is-thread-open .api-chat-main { display: grid; }
body.api-messages-route.api-chat-apk-compact .api-chat-back { display: grid; }

body.api-messages-route.api-chat-apk-compact .sd-mobile-search-v772,
body.api-messages-route.api-chat-apk-compact .dashboard-sidebar,
body.api-messages-route.api-chat-apk-compact #panelHeaderMount,
body.api-messages-route.api-chat-apk-compact #panelFooterMount,
body.api-messages-route.api-chat-apk-compact.api-chat-thread-open .sd-mobile-header-v772,
body.api-messages-route.api-chat-apk-compact.api-chat-thread-open .sd-bottom-nav-v772 { display: none !important; }

body.api-messages-route.api-chat-apk-compact.api-chat-thread-open {
  padding-bottom: 0 !important;
}

body.api-messages-route.api-chat-apk-compact .api-chat-compose-area {
  padding-bottom: env(safe-area-inset-bottom);
}

/* The shared shell hides the theme switch and forces white chrome in native
   mode. Only the chat page opts out; auth visibility rules are not overridden. */
html body.api-messages-route.api-chat-apk-compact .sd-mobile-theme-v776 {
  display: grid !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

html body.api-messages-route.api-chat-apk-compact .sd-mobile-header-v772,
html body.api-messages-route.api-chat-apk-compact .sd-bottom-nav-v772 {
  background: var(--chat-surface) !important;
  color: var(--chat-text) !important;
  border-color: var(--chat-border) !important;
}

html body.api-messages-route.api-chat-apk-compact .sd-mobile-back-v772,
html body.api-messages-route.api-chat-apk-compact .sd-mobile-account-v772,
html body.api-messages-route.api-chat-apk-compact .sd-mobile-theme-v776 {
  background: var(--chat-surface-alt) !important;
  color: var(--chat-text) !important;
  border-color: var(--chat-border) !important;
}

body.api-messages-route.api-chat-apk-compact .sd-mobile-brand-v772 { color: var(--chat-text); }
body.api-messages-route.api-chat-apk-compact .sd-mobile-brand-v772 small,
body.api-messages-route.api-chat-apk-compact .sd-bottom-nav-v772 > a { color: var(--chat-muted); }
body.api-messages-route.api-chat-apk-compact .sd-bottom-nav-v772 > a[aria-current="page"] {
  color: var(--api-red);
  background: var(--chat-mine);
}
