/* --- Basic Reset & Setup --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent; /* Disable blue tap highlight on mobile */
}

:root {
    /* Material Design Inspired Colors (Light Theme) */
    --primary-color: #0277bd; /* Light Blue darken-3 */
    --primary-light: #58a5f0;
    --primary-dark: #004c8c;
    --secondary-color: #fbc02d; /* Yellow darken-1 */
    --text-on-primary: #ffffff;
    --text-on-secondary: #000000;
    --background-color: #f5f5f5; /* Grey lighten-4 */
    --panel-bg: #ffffff;
    --border-color: #e0e0e0; /* Grey lighten-2 */
    --danger-color: #d32f2f; /* Red darken-2 */
    --text-color: #212121; /* Grey darken-4 */
    --timeline-grid-color: #eeeeee; /* Grey lighten-3 */
    --timeline-time-marker-color: var(--danger-color);
    --input-bg-color: #ffffff;
    --input-border-color: #ccc;
    --modal-bg-color: #fefefe;
    --modal-shadow-color: rgba(0,0,0,0.2);
    --completed-color: #bdbdbd; /* Grey 400 */
    --completed-text-color: #757575; /* Grey 600 */
    --selected-border-color: var(--primary-color);


    /* Resizing Handles */
    --resize-handle-bg: rgba(0, 0, 0, 0.3);
    --resize-handle-bg-hover: rgba(0, 0, 0, 0.6);
    --resize-handle-size: 20px; /* Increased touch target size */

    /* Sizes */
    --header-height: 60px;
    --panel-padding: 1rem;
    --border-radius: 4px;
    /* --timeline-height: 250px; Height now dynamic based on flex */
    --task-height: 50px;
}

/* --- Dark Mode Variables --- */
body.dark-mode {
    --primary-color: #64b5f6; /* Light Blue lighten-1 (adjust for dark) */
    --primary-light: #9be7ff;
    --primary-dark: #2286c3;
    --secondary-color: #fff176; /* Yellow lighten-2 */
    --text-on-primary: #000000; /* Black text on light blue */
    --text-on-secondary: #000000; /* Black text on yellow */
    --background-color: #121212; /* Standard dark bg */
    --panel-bg: #212121; /* Slightly lighter dark */
    --border-color: #424242; /* Darker border */
    --danger-color: #ef5350; /* Lighter red */
    --text-color: #e0e0e0; /* Light grey text */
    --timeline-grid-color: #303030; /* Dark grid */
    --timeline-time-marker-color: #ff8a80; /* Lighter red for marker */
    --input-bg-color: #333333;
    --input-border-color: #555555;
    --modal-bg-color: #2e2e2e;
    --modal-shadow-color: rgba(0,0,0,0.5);
    --completed-color: #424242; /* Dark Grey */
    --completed-text-color: #9e9e9e; /* Lighter Grey */
    --selected-border-color: var(--primary-light);

    --resize-handle-bg: rgba(255, 255, 255, 0.3);
    --resize-handle-bg-hover: rgba(255, 255, 255, 0.6);
}

html, body {
    height: 100%;
    font-family: 'Roboto', sans-serif; /* Assuming Roboto is available or imported */
    background-color: var(--background-color);
    color: var(--text-color);
    font-size: 16px;
    line-height: 1.5;
    overflow: hidden; /* Prevent body scroll, panels handle their own */
    /* Improve touch scrolling */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* --- Layout --- */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh; /* Use full viewport height */
    height: 100dvh; /* Use dynamic viewport height where supported */
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--primary-color);
    color: var(--text-on-primary);
    padding: 0 var(--panel-padding);
    height: var(--header-height);
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.app-header h1 {
    font-size: 1.4rem;
    font-weight: 500;
}

.header-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.top-panel {
    display: flex;
    flex: 1; /* Takes remaining space, split 50/50 by children */
    /* Removed min-height, flex will distribute space */
    overflow: hidden; /* Prevent top panel itself from scrolling */
    /* Make top panel take ~40% height, bottom ~60% */
    flex-basis: 42vh;
    flex-shrink: 0;
}

.panel {
    padding: var(--panel-padding);
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    margin: 0.5rem; /* Small gap between panels */
    border-radius: var(--border-radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow-y: auto; /* Allow scrolling within panels if content overflows */
    max-height: 100%; /* Ensure they don't overflow the parent */
}

.timer-panel, .task-options-panel {
    flex: 1; /* Each takes half of the top panel */
    display: flex;
    flex-direction: column;
    /* overflow-y: auto; Moved to .panel */
}

/* Center timer content */
.timer-panel {
    align-items: center;
}

/* Allow task options to align left */
.task-options-panel {
    align-items: stretch;
}


.timeline-panel {
    /* Give timeline ~58% of viewport height */
    /* flex-basis: 58vh; Replaced by making top-panel basis 42vh */
    flex-grow: 1; /* Take remaining height */
    flex-shrink: 0; /* Prevent shrinking */
    display: flex;
    flex-direction: column;
    margin-top: 0; /* No top margin if it's below top-panel */
    overflow: hidden; /* Panel itself doesn't scroll, container inside does if needed */
}


.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
    padding: 0 var(--panel-padding); /* Align header with panel content */
}

.timeline-container {
    flex-grow: 1; /* Take remaining space in the panel */
    position: relative; /* Needed for absolute positioning of tasks */
    background-color: #fafafa; /* Slightly different bg for timeline */
    border: 1px solid var(--border-color);
    overflow-x: hidden; /* NO horizontal scrolling */
    overflow-y: hidden; /* Tasks shouldn't overflow vertically */
    /* Basic grid background */
    background-image: linear-gradient(to right, var(--timeline-grid-color) 1px, transparent 1px),
                      linear-gradient(to bottom, var(--timeline-grid-color) 1px, transparent 1px);
    /* background-size will be set dynamically by JS based on pixelsPerMinute */
    min-height: var(--task-height) + 20px; /* Ensure space for at least one task */
    width: 100%; /* Force it to take full width of its container */
}
body.dark-mode .timeline-container { background-color: #1e1e1e; }


/* --- Timer --- */
.timer-panel h2 {
    align-self: center; /* Center timer header */
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 1rem;
    color: var(--primary-dark);
}
body.dark-mode .timer-panel h2 {
     color: var(--primary-light);
}

.timer-mode-display {
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--primary-dark);
}
body.dark-mode .timer-mode-display {
    color: var(--primary-light);
}


.timer-time-display {
    font-size: 3.5rem;
    font-weight: 300;
    margin-bottom: 1rem;
    font-family: 'Roboto Mono', monospace; /* Monospaced for timer */
}

.timer-controls {
    display: flex;
    gap: 0.5rem;
}

/* --- Buttons --- */
.button {
    padding: 0.6em 1.2em;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    text-transform: uppercase;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    background-color: var(--primary-color);
    color: var(--text-on-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    -webkit-appearance: none; /* Fix iOS button styling */
    -moz-appearance: none;
    appearance: none;
}

.button:hover {
    background-color: var(--primary-light);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.button:active {
    background-color: var(--primary-dark);
}

.secondary-button {
    background-color: #f5f5f5; /* Light grey */
    color: var(--primary-color);
    border: 1px solid var(--border-color);
}

.secondary-button:hover {
    background-color: #eeeeee; /* Slightly darker grey */
}

.danger-button {
    background-color: var(--danger-color);
    color: var(--text-on-primary);
}
.danger-button:hover {
     background-color: #b71c1c; /* Darker Red */
}


.icon-button {
    background: none;
    border: none;
    color: var(--text-on-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.icon-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}
.icon-button .material-icons {
    font-size: 24px;
}

/* Adjust button colors for dark mode */
body.dark-mode .button {
    background-color: var(--primary-dark); /* Use a darker shade for primary action */
    color: var(--text-on-primary);
}
body.dark-mode .button:hover {
    background-color: var(--primary-color);
}
body.dark-mode .secondary-button {
    background-color: var(--panel-bg);
    color: var(--primary-light);
    border-color: var(--border-color);
}
body.dark-mode .secondary-button:hover {
     background-color: #333333;
}
body.dark-mode .icon-button {
    color: var(--text-color); /* Match text color */
}
body.dark-mode .icon-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}


/* --- Task Options --- */
.task-options-panel h2 {
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 1rem;
    padding-left: 0; /* Remove extra padding if panel has it */
    color: var(--primary-dark);
    align-self: flex-start; /* Align headers left */
}

body.dark-mode .task-options-panel h2 {
     color: var(--primary-light);
}


.task-templates-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    /* padding: 0 var(--panel-padding); Removed, panel has padding */
    width: 100%;
}

.task-template {
    background-color: var(--panel-bg);
    border: 1px dashed var(--border-color);
    padding: 0.8rem;
    border-radius: var(--border-radius);
    cursor: grab;
    text-align: center;
    transition: background-color 0.2s, border-color 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    user-select: none; /* Prevent text selection */
}

.task-template:hover {
    background-color: #e3f2fd; /* Light blue tint on hover */
    border-style: solid;
    border-color: var(--primary-light);
}
body.dark-mode .task-template:hover {
    background-color: #2a2a2a;
    border-color: var(--primary-color);
}

.task-template:active, .task-template.dragging {
    cursor: grabbing;
    opacity: 0.6;
}


/* --- Timeline Tasks --- */
.timeline-task {
    position: absolute;
    top: 5px; /* Small gap from top */
    height: var(--task-height);
    background-color: var(--secondary-color); /* Default, will be overridden */
    border-radius: var(--border-radius);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    cursor: grab; /* Default cursor */
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Align items left */
    padding: 0 0.5rem;
    overflow: visible; /* Allow handles to be slightly outside visually */
    color: var(--text-on-secondary); /* Default, check contrast */
    white-space: nowrap;
    transition: left 0.1s ease, width 0.1s ease, background-color 0.3s ease, opacity 0.3s ease, border-color 0.2s ease;
    user-select: none; /* Prevent text selection during drag */
    touch-action: none; /* Prevent browser scrolling when interacting with task */
}
body.dark-mode .timeline-task {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Selected State */
.timeline-task.selected {
    border-color: var(--selected-border-color);
    box-shadow: 0 0 0 2px var(--selected-border-color), 0 1px 3px rgba(0,0,0,0.1); /* Add outline */
}


.timeline-task .task-name {
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 5px; /* Space between name and controls */
    /* Allow clicks only when selected */
    pointer-events: none;
    user-select: none;
}
.timeline-task.selected .task-name {
    pointer-events: auto; /* Enable clicks on name only when task is selected */
    cursor: text; /* Indicate editable */
}

/* Completed State */
.timeline-task.completed {
    background-color: var(--completed-color) !important; /* Override original color */
    opacity: 0.7;
    border-color: #9e9e9e;
}
.timeline-task.completed .task-name {
    text-decoration: line-through;
    color: var(--completed-text-color) !important; /* Override contrast color */
    cursor: default; /* No text cursor if completed */
    pointer-events: none; /* Disable rename on completed tasks */
}
/* Adjust handle appearance for completed tasks */
.timeline-task.completed .resize-handle-left::before,
.timeline-task.completed .resize-handle-right::before {
    background-color: rgba(120, 120, 120, 0.4); /* Dimmer handle cue */
}


.timeline-task.dragging { /* Style for element being dragged */
    opacity: 0.5;
    z-index: 1000;
    cursor: grabbing;
    /* We'll use transform for positioning during drag via JS */
    transition: none; /* Disable transitions during drag for direct feedback */
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}


/* Task Controls (Check, Delete) */
.task-controls {
    position: absolute; /* Position relative to task */
    right: 4px;
    top: 50%;
    transform: translateY(-50%); /* Center vertically */
    opacity: 0; /* Hidden by default */
    transition: opacity 0.2s ease;
    background-color: rgba(0, 0, 0, 0.1); /* Semi-transparent background */
    border-radius: var(--border-radius);
    padding: 2px;
    display: flex; /* Arrange buttons horizontally */
    gap: 2px;
    z-index: 15; /* Above handles */
    pointer-events: none; /* Let clicks pass through unless hovering exactly */
}

.timeline-task:hover .task-controls,
.timeline-task.selected .task-controls { /* Show controls on hover OR when selected */
    opacity: 1;
    pointer-events: auto; /* Enable clicks when visible */
}
body.dark-mode .task-controls {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Control Buttons (Check, Delete) */
.task-complete-button,
.task-delete-button {
    background: none;
    border: none;
    color: inherit; /* Inherit contrast color from task */
    border-radius: 50%;
    width: 22px; /* Slightly larger tap target */
    height: 22px;
    font-size: 18px; /* Icon size */
    line-height: 22px;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.task-complete-button .material-icons,
.task-delete-button .material-icons {
    font-size: inherit; /* Match button font size */
}

.task-controls:hover { /* Highlight controls background on hover */
    background: rgba(0, 0, 0, 0.2);
}
body.dark-mode .task-controls:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Dim check button when completed */
.timeline-task.completed .task-complete-button {
    color: var(--completed-text-color) !important;
    opacity: 0.8;
}


/* New Resize Handles */
.resize-handle-left,
.resize-handle-right {
    position: absolute;
    top: 0;
    bottom: 0;
    width: var(--resize-handle-size);
    cursor: ew-resize;
    z-index: 10; /* Above task content, below controls */
    /* background: var(--resize-handle-bg); DEBUGGING: Make handles visible */
    /* Add subtle visual cue */
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Position centered on edge, slightly overlapping */
.resize-handle-left { left: calc(var(--resize-handle-size) / -2 + 2px); }
.resize-handle-right { right: calc(var(--resize-handle-size) / -2 + 2px); }

/* Visual cue for handles (optional) */
.resize-handle-left::before,
.resize-handle-right::before {
    content: '';
    display: block;
    width: 4px; /* Width of the visible line */
    height: 60%; /* Height relative to task height */
    background-color: var(--resize-handle-bg);
    border-radius: 2px;
    opacity: 0; /* Hidden by default, show on hover/selected */
    transition: opacity 0.2s ease, background-color 0.2s ease;
}
.timeline-task:hover .resize-handle-left::before,
.timeline-task:hover .resize-handle-right::before,
.timeline-task.selected .resize-handle-left::before,
.timeline-task.selected .resize-handle-right::before {
    opacity: 0.7; /* Make cues visible on hover/select */
}
.resize-handle-left:hover::before,
.resize-handle-right:hover::before {
     background-color: var(--resize-handle-bg-hover);
     opacity: 1;
}


/* Editing Task Name */
.task-name-input {
    position: absolute; /* Position over the span */
    left: 0.5rem; /* Match task padding */
    right: 55px; /* Space for controls (check + delete approx) */
    top: 50%;
    transform: translateY(-50%);
    width: calc(100% - 0.5rem - 55px); /* Fill available space */
    border: none;
    background: rgba(255, 255, 255, 0.95);
    padding: 6px;
    font: inherit;
    color: #000; /* Ensure contrast while editing */
    outline: none;
    border-radius: 2px;
    z-index: 20; /* Above everything else on the task */
    box-shadow: 0 0 0 2px var(--primary-color); /* Highlight editing field */
}
body.dark-mode .task-name-input {
     background: rgba(0, 0, 0, 0.95);
     color: #fff;
     box-shadow: 0 0 0 2px var(--primary-light);
}


/* --- Settings Modal --- */
.modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 1001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes slideIn { from { transform: translateY(-50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-50px); opacity: 0; } }


.modal.visible {
    display: block;
}
.modal.closing {
    animation: fadeOut 0.3s ease forwards;
}
.modal.closing .modal-content {
    animation: slideOut 0.3s ease forwards;
}


.modal-content {
    background-color: var(--modal-bg-color);
    margin: 10% auto;
    padding: 25px;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 600px;
    border-radius: var(--border-radius);
    box-shadow: 0 5px 15px var(--modal-shadow-color);
    position: relative;
    animation: slideIn 0.3s ease;
}

.close-button {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1; /* Ensure it doesn't affect layout */
}

.close-button:hover,
.close-button:focus {
    color: var(--text-color);
    text-decoration: none;
}

.settings-group {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.settings-group:last-child {
    border-bottom: none;
    padding-bottom: 0;
}


.settings-group h3 {
    margin-bottom: 0.8rem;
    font-size: 1.1rem;
    color: var(--primary-dark);
}
body.dark-mode .settings-group h3 {
    color: var(--primary-light);
}

.settings-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 500;
    font-size: 0.9rem;
}
.settings-group label.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
    cursor: pointer; /* Make label clickable for checkbox */
}


.settings-group input[type="number"],
.settings-group input[type="text"],
.settings-group input[type="color"],
.settings-group input[type="time"],
.settings-group input[type="checkbox"] {
    padding: 8px;
    margin-bottom: 0.8rem;
    border: 1px solid var(--input-border-color);
    background-color: var(--input-bg-color);
    color: var(--text-color);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    width: 100%; /* Default full width */
}
.settings-group input[type="checkbox"] {
    width: auto; /* Checkbox size determined by browser */
    margin-bottom: 0; /* Align with label */
    margin-right: 0.5rem; /* Space between box and text */
    flex-shrink: 0;
}
.settings-group input[type="color"] {
    height: 40px; /* Make color input taller */
    padding: 4px;
    width: 60px; /* Fixed width for color picker */
    min-width: 60px;
}
.settings-group input[type="time"] {
     width: auto; /* Let browser size time input */
     padding: 6px 8px;
}


.settings-group small {
    display: block;
    font-size: 0.8rem;
    color: #666;
    margin-top: -0.5rem;
    margin-bottom: 0.8rem;
}
body.dark-mode .settings-group small {
    color: #aaa;
}

.danger-zone {
    border-color: var(--danger-color);
    border-left: 3px solid var(--danger-color);
    padding-left: 1rem;
    margin-left: -1rem; /* Adjust to align visually */
}

/* Template Editor Styles */
.template-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    flex-wrap: wrap; /* Allow wrapping on small screens */
}
.template-item input {
    margin-bottom: 0; /* Override default margin */
}
.template-item input[type="text"] { flex-grow: 1; min-width: 120px; }
.template-item input[type="number"] { width: 70px; min-width: 70px; }
/* Removed fixed width for color */
.template-item button {
    padding: 4px 8px;
    font-size: 0.8rem;
    background-color: var(--danger-color);
    color: var(--text-on-primary); /* Ensure contrast */
    min-width: 30px;
    margin-left: auto; /* Push remove button to the right */
}
body.dark-mode .template-item button {
     color: #000; /* Text color for light red */
}


/* --- Drag & Drop Highlighting --- */
.timeline-container.drag-over {
    background-color: #e0f7fa; /* Light cyan highlight */
    border-style: dashed;
}
body.dark-mode .timeline-container.drag-over {
    background-color: #003c4e; /* Dark cyan highlight */
}

/* --- Current Time Marker --- */
.current-time-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--timeline-time-marker-color);
    z-index: 50; /* Above grid, below tasks being dragged */
    pointer-events: none; /* Don't interfere with clicks/drags */
    display: none; /* Hidden initially until positioned */
}

/* --- Utility --- */
.hidden {
    display: none;
}


/* --- Responsiveness (Adjusted) --- */
@media (max-width: 768px) {
    .top-panel {
        flex-direction: column;
        /* Let flexbox determine height based on timeline */
        /* max-height: calc(100vh - var(--header-height) - 40vh); Adjusted flex basis instead */
        flex-basis: 50vh; /* Give top panels slightly more height on mobile */
    }

    .timer-panel, .task-options-panel {
        flex-basis: auto; /* Allow them to size based on content */
        flex-grow: 1; /* Share the remaining space */
        min-height: 150px; /* Ensure some min height if content is sparse */
    }

    .timer-time-display {
        font-size: 2.8rem;
    }

    /* Timeline panel grows to fill remaining space */

    .modal-content {
        width: 95%;
        margin: 5% auto;
        max-height: 90vh;
        overflow-y: auto;
    }
    .app-header h1 {
        font-size: 1.2rem;
    }
    /* Ensure task controls are usable on touch */
    .timeline-task .task-controls {
        opacity: 0; /* Still hide by default */
    }
     .timeline-task.selected .task-controls {
         opacity: 1; /* Show only when selected on mobile */
    }
     .timeline-task:hover .task-controls {
         /* Don't rely on hover for mobile */
         opacity: inherit; /* Use selected state instead */
    }

}

@media (max-width: 480px) {
     /* Further adjustments for very small screens */
    :root {
        --panel-padding: 0.75rem;
    }
    .timer-time-display {
        font-size: 2.5rem;
    }
    .button {
        font-size: 0.8rem;
        padding: 0.5em 1em;
    }
    .app-header h1 {
        font-size: 1.1rem;
    }
    .template-item {
        gap: 0.3rem;
    }
     .template-item input[type="text"] { min-width: 100px; }
     .template-item input[type="number"] { width: 60px; min-width: 60px; }

     .task-name-input {
        right: 50px; /* Adjust space for smaller controls */
        width: calc(100% - 0.5rem - 50px);
     }
}