:root {
  --crm-visible-height: 100dvh;
  --crm-visible-width: 100vw;
  --crm-visible-top: 0px;
  --crm-visible-left: 0px;
  --crm-visible-bottom: 0px;
  --crm-visible-right: 0px;
  --crm-nav-reserve: 0px;
}
/* Fixed modal children share the viewport; transforms would trap the bottom bar. */
dialog[open] {
  position: fixed;
  top: calc(var(--crm-visible-top) + 10px);
  bottom: calc(var(--crm-visible-bottom) + var(--crm-nav-reserve) + 10px);
  left: calc(var(--crm-visible-left) + 10px);
  right: calc(var(--crm-visible-right) + 10px);
  margin: auto;
  height: fit-content;
  box-sizing: border-box;
  max-width: calc(var(--crm-visible-width) - 20px);
  max-height: max(0px, calc(var(--crm-visible-height) - var(--crm-nav-reserve) - 20px));
  overflow: auto;
  overscroll-behavior: contain;
  transform: none;
  contain: none;
}
.crm-navigation-under-modal { visibility: hidden; }
.crm-modal-nav { box-shadow: 0 -2px 10px #0001; }
@media (max-width: 1000px) {
  :root.crm-mobile-navigation { --crm-nav-reserve: calc(48px + env(safe-area-inset-bottom, 0px)); }
  html { scroll-padding-bottom: calc(var(--crm-nav-reserve) + 12px); }
  #shell main { padding-bottom: calc(var(--crm-nav-reserve) + 8px); }
  .mobile-bottom-nav {
    position: fixed;
    bottom: var(--crm-visible-bottom);
    left: var(--crm-visible-left);
    right: var(--crm-visible-right);
    width: auto;
    height: var(--crm-nav-reserve);
    min-height: 48px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-sizing: border-box;
    flex-shrink: 0;
  }
  dialog[open] .crm-modal-nav { display: flex; z-index: 1; }
  dialog[open] { scroll-padding: 12px; }
  #toast { bottom: calc(var(--crm-visible-bottom) + var(--crm-nav-reserve) + 10px); }
  #shell .sidebar {
    bottom:calc(var(--crm-visible-bottom) + var(--crm-nav-reserve));
    max-height:calc(var(--crm-visible-height) - 54px - var(--crm-nav-reserve));
    min-height:0;
    box-sizing:border-box;
  }
  #shell .sidebar nav { flex:1 1 auto; min-height:0; overflow-y:auto; }
  #shell .sidebar .brand,
  #shell .sidebar-create,
  #shell .sidebar-bottom { flex-shrink:0; }
  #shell .sidebar-bottom { padding-bottom:4px; }
}
