.task-list {
    margin: 0 auto;
    /* Ensure centered if width < 100% */
}

.task-list li {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.task-list li span {
    flex: 1;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    min-width: 0;
    /* Critical for flexbox text wrapping */
    padding-right: 10px;
    line-height: 1.4;
}

/* Ensure drag handle and buttons maintain size */
.task-list li .actions {
    flex-shrink: 0;
    display: flex;
    gap: 5px;
}

/* Fix User Icon Centering */
#adminLink {
    /* display: flex !important; removed to allow JS to hide it */
    justify-content: center !important;
    align-items: center !important;
    padding: 0 !important;
    width: 40px !important;
    height: 40px !important;
}

#adminLink i,
#logoutBtn i {
    margin: 0 !important;
    padding: 0 !important;
    display: inline-block;
    /* Ensure icon behaves for centering */
}

@media (max-width: 480px) {
    .task-list li {
        flex-direction: row;
        /* Keep row even on mobile? Or column? User asked to cut the word to next line */
        /* Row is standard for checkboxes and actions. The text just needs to wrap. */
    }

    /* Hide text in Add button on mobile */
    .btn-text {
        display: none;
    }

    /* Center header and buttons on mobile */
    .input-container h1 {
        text-align: center;
        width: 100%;
    }

    .button-row {
        justify-content: center !important;
        /* Force center alignment */
        gap: 15px;
        /* Increase gap slightly since text is gone */
    }

    /* Center task lists perfectly with approx 0.5cm (20px) spacing */
    .responsive-grid,
    #taskListsContainer {
        display: block !important;
        width: 100% !important;
        padding: 0 20px !important;
        /* Side padding only */
        box-sizing: border-box !important;
    }

    .task-list {
        width: 100% !important;
        margin: 15px 0 !important;
        box-sizing: border-box !important;
    }

    .main-content {
        padding: 0 !important;
        /* Remove double padding */
        width: 100% !important;
    }

    .input-container {
        padding: 0 20px !important;
        /* Match the task list spacing */
        box-sizing: border-box !important;
        width: 100% !important;
    }

    /* Fix User Icon Centering */
    #adminLink {
        /* display: flex !important; removed */
        justify-content: center !important;
        align-items: center !important;
        padding: 0 !important;
        width: 40px !important;
        height: 40px !important;
    }

    #adminLink i,
    #logoutBtn i {
        margin: 0 !important;
        padding: 0 !important;
        display: inline-block;
        /* Ensure icon behaves for centering */
    }

    /* Ensure all round/square buttons are flex centered */
    .button-row>* {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
}

/* PC/Laptop: Smart Grid Layout (3 or 4 columns based on space) */
@media (min-width: 768px) {

    .responsive-grid,
    #taskListsContainer {
        display: grid !important;
        gap: 20px !important;
        align-items: start !important;
        padding: 20px !important;
        /* 0.5cm edge spacing */
        width: 100% !important;
        box-sizing: border-box !important;
        /* Default to 3 cols if attr missing, but specific rules below override */
        grid-template-columns: repeat(3, 1fr);
    }

    /* Dynamic columns based on count - using !important to override any previous hard settings */
    #taskListsContainer[data-grid-columns="1"] {
        grid-template-columns: 1fr !important;
    }

    #taskListsContainer[data-grid-columns="2"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    #taskListsContainer[data-grid-columns="3"] {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .task-list {
        width: 100% !important;
        margin: 0 !important;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        /* Slight shadow for separation */
        box-sizing: border-box !important;
    }

    .main-content {
        max-width: 1400px !important;
        /* Allow wide screens to show 3 columns comfortably */
        width: 95% !important;
        margin: 0 auto !important;
    }
}