:root {
    /* Light Theme (Default) */
    --bg-color: #FAFAFA;
    --surface-color: #FFFFFF;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    --accent-color: #4F46E5;
    /* Indigo */
    --accent-hover: #4338CA;
    --danger-color: #EF4444;
    --success-color: #10B981;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

    /* Priority Colors */
    --priority-high: #EF4444;
    --priority-medium: #F59E0B;
    --priority-low: #10B981;
}

[data-theme="dark"] {
    --bg-color: #121212;
    --surface-color: #1E1E1E;
    --text-primary: #F3F4F6;
    --text-secondary: #9CA3AF;
    --border-color: #374151;
    --accent-color: #6366F1;
    --accent-hover: #818CF8;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    transition: background-color 0.3s, color 0.3s;
    height: 100vh;
    overflow: hidden;
    /* Prevent body scroll, we scroll main */
    display: flex;
    flex-direction: column;
}

.app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 800px;
    /* Constrain on desktop */
    margin: 0 auto;
    width: 100%;
    position: relative;
    background-color: var(--bg-color);
    /* Match body for seamless desktop view */
}

/* Header */
/* Header */
.app-header {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    /* Stack top row and progress */
    background-color: var(--bg-color);
    z-index: 10;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.progress-info {
    width: 100%;
}

.progress-status {
    display: flex;
    justify-content: flex-end;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-color);
    margin-top: 8px;
}

.header-left h1 {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.date-display {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

.icon-btn:hover {
    background-color: var(--border-color);
}

/* Filter Chips */
.filter-nav {
    display: flex;
    gap: 8px;
    padding: 0 24px 16px 24px;
    overflow-x: auto;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

.filter-nav::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-chip.active {
    background-color: var(--text-primary);
    color: var(--bg-color);
    border-color: var(--text-primary);
}

/* Task List */
.task-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 24px;
    padding-bottom: 180px;
    /* Increased padding to clear the fixed bottom input bar */
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 60px;
    font-size: 0.9rem;
}

.task-item {
    display: flex;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
    animation: fadeIn 0.3s ease;
    group: relative;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.task-checkbox-wrapper {
    margin-right: 12px;
}

.custom-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-secondary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.task-item.completed .custom-checkbox {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.custom-checkbox i {
    color: white;
    font-size: 10px;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s;
}

.task-item.completed .custom-checkbox i {
    opacity: 1;
    transform: scale(1);
}

.task-content {
    flex: 1;
}

.task-text {
    font-size: 15px;
    color: var(--text-primary);
    transition: color 0.2s;
}

.task-item.completed .task-text {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.task-meta {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-secondary);
}

.meta-tag {
    display: flex;
    align-items: center;
    gap: 4px;
}

.priority-indicator {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.priority-high-dot {
    background-color: var(--priority-high);
}

.priority-medium-dot {
    background-color: var(--priority-medium);
}

.priority-low-dot {
    background-color: var(--priority-low);
}

.delete-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 8px;
    cursor: pointer;
    opacity: 0;
    /* Hidden by default on desktop */
    transition: opacity 0.2s, color 0.2s;
}

.delete-btn:hover {
    color: var(--danger-color);
}

.task-item:hover .delete-btn {
    opacity: 1;
}

/* Mobile: always show delete or use swipe (simplified to always visible for now on touch) */
@media (hover: none) {
    .delete-btn {
        opacity: 0.5;
    }
}

/* Bottom Input Bar */
.input-bar-container {
    position: fixed;
    /* Stick to viewport to handle keyboard resize better */
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--surface-color);
    border-top: 1px solid var(--border-color);
    padding: 16px 24px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    /* Safe area for swipe bar */
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
    z-index: 100;
    /* Ensure it stays on top */
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 800px;
    /* Match app-wrapper width roughly */
    margin: 0 auto;
}

.input-primary {
    display: flex;
    gap: 12px;
    align-items: center;
}

#task-input {
    flex: 1;
    border: none;
    background: var(--bg-color);
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 15px;
    color: var(--text-primary);
}

#task-input:focus {
    outline: 2px solid var(--accent-color);
}

.add-btn {
    width: 44px;
    height: 44px;
    background-color: var(--text-primary);
    color: var(--bg-color);
    border: none;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.add-btn:active {
    transform: scale(0.95);
}

.input-options {
    display: flex;
    gap: 8px;
    /* Tighter gap */
    flex-wrap: wrap;
    /* Allow wrapping to fit screen */
    width: 100%;
}

.input-options::-webkit-scrollbar {
    display: none;
}

/* Pill Styling for Options */
.select-wrapper,
.date-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background-color: var(--bg-color);
    padding: 6px 10px;
    /* Slightly more compact */
    border-radius: 20px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    flex: 1 0 auto;
    /* Allow expanding to fill gaps */
    justify-content: center;
}



.select-wrapper:hover,
.date-wrapper:hover {
    border-color: var(--accent-color);
    background-color: var(--surface-color);
}

.options-icon {
    position: static;
    /* Flow naturally inside pill */
    margin-right: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.minimal-select,
.minimal-date {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 12px;
    padding: 0;
    cursor: pointer;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
}

.minimal-select:focus,
.minimal-date:focus {
    outline: none;
}

/* Progress Bar in Header */
.progress-container {
    height: 4px;
    background-color: var(--border-color);
    width: 100%;
    margin-top: 16px;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background-color: var(--accent-color);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 2px;
}

/* Custom styles for select opacity 0 hack if we wanted pure custom icons, 
   but for now we keep native select for reliability */

@media (min-width: 801px) {
    .app-wrapper {
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.05);
        height: 90vh;
        margin-top: 5vh;
        border-radius: 20px;
        overflow: hidden;
    }

    .input-bar-container {
        border-radius: 0 0 20px 20px;
    }
}