/* MatkulDesk: targeted mobile + Midnight stacking repair.
   Loaded last so older theme layers cannot override these rules. */
@media (max-width: 720px) {
  /* Keep the animated star field behind the app without creating a new
     isolated stacking context that traps the sidebar and its backdrop. */
  body[data-theme="midnight"] {
    isolation: auto !important;
    overflow-x: hidden;
  }
  body[data-theme="midnight"]::before,
  body[data-theme="midnight"]::after {
    z-index: -1 !important;
    pointer-events: none !important;
  }
  body[data-theme="midnight"] .layout {
    position: static !important;
    z-index: auto !important;
    isolation: auto !important;
    transform: none !important;
    filter: none !important;
  }

  /* Sidebar and backdrop must be separate, predictable layers. */
  body[data-theme="midnight"] .sidebar {
    position: fixed !important;
    z-index: 120 !important;
    background: #080e1d !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
  body[data-theme="midnight"] .sidebar-backdrop {
    position: fixed !important;
    z-index: 110 !important;
    background: rgba(3, 8, 20, .76) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    filter: none !important;
  }

  /* Keep page content crisp when the navigation drawer is open. */
  body[data-theme="midnight"].sidebar-open .main,
  body[data-theme="midnight"].sidebar-open .topbar,
  body[data-theme="midnight"].sidebar-open .view {
    filter: none !important;
  }

  /* Bottom tabs stay below dialogs and do not create a blur layer over them. */
  body[data-theme="midnight"] .mobile-bottom-nav {
    z-index: 50 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: #17213a !important;
  }
  body[data-theme="midnight"] .modal-layer {
    z-index: 200 !important;
  }

  /* All requested section headings align to the left on phones. */
  .page-head {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    text-align: left !important;
    width: 100%;
  }
  .page-head > div:first-child {
    width: 100%;
    align-self: flex-start !important;
    text-align: left !important;
    margin: 0 !important;
  }
  .page-head .kicker,
  .page-head h1,
  .page-head p {
    text-align: left !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  .page-head .kicker {
    display: block;
    width: 100%;
  }
  .page-head h1 { width: 100%; }
  .page-head p { max-width: 100%; }
  .page-head > .btn,
  .page-head .notes-head-actions {
    width: 100%;
    align-self: stretch;
  }
}
