@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Navy & Orange Theme matching icon-512.png */
    --bg-primary: #020617;
    --bg-secondary: #0f172a;
    --bg-dark: #070e27;
    --bg-glass: rgba(15, 23, 42, 0.9);
    --bg-body: radial-gradient(circle at center, #070e27 0%, #020617 100%);
    
    --header-bg: rgba(15, 23, 42, 0.7);
    --panel-bg: rgba(15, 23, 42, 0.5);
    --input-bg: rgba(2, 6, 23, 0.5);
    --btn-send-bg: rgba(15, 23, 42, 0.8);
    --overlay-bg: rgba(0, 0, 0, 0.8);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-inverse: #0f172a;

    --accent-color: #f97316;
    --accent-hover: #fb923c;
    --accent-glow: rgba(249, 115, 22, 0.3);
    --text-on-accent: #f8fafc;

    --success-color: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --danger-color: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);

    --border-color: rgba(59, 130, 246, 0.2);
    --border-light: rgba(255, 255, 255, 0.1);
    
    --hover-bg: rgba(255, 255, 255, 0.05);
    --shadow-color: rgba(0, 0, 0, 0.5);

    --radius-lg: 12px;
    --radius-md: 8px;
    --radius-sm: 4px;

    --shadow-lg: 0 10px 25px -5px var(--shadow-color), 0 8px 10px -6px var(--shadow-color);

    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
}

body.light-theme {
    --bg-primary: #f0f7ff;
    --bg-secondary: #ffffff;
    --bg-dark: #e0f2fe;
    --bg-glass: rgba(240, 247, 255, 0.85);
    --bg-body: radial-gradient(circle at center, #e0f2fe 0%, #f0f7ff 100%);

    --header-bg: rgba(255, 255, 255, 0.8);
    --panel-bg: rgba(255, 255, 255, 0.5);
    --input-bg: rgba(255, 255, 255, 0.8);
    --btn-send-bg: rgba(249, 115, 22, 0.1);
    --overlay-bg: rgba(15, 23, 42, 0.4);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-inverse: #f8fafc;
    --text-on-accent: #f8fafc;

    --border-color: rgba(15, 23, 42, 0.1);
    --border-light: rgba(15, 23, 42, 0.1);

    --hover-bg: rgba(15, 23, 42, 0.05);
    --shadow-color: rgba(15, 23, 42, 0.1);
    
    --success-bg: rgba(16, 185, 129, 0.15);
    --danger-bg: rgba(239, 68, 68, 0.15);

    --shadow-lg: 0 10px 25px -5px var(--shadow-color), 0 8px 10px -6px var(--shadow-color);
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg-body);
    background-attachment: fixed;
    color: var(--text-primary);
    font-size: 14px;
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
    overflow-x: hidden;
    transition: color 0.3s ease;
}

#app {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
    padding-bottom: calc(120px + env(safe-area-inset-bottom));
    box-sizing: border-box;
    position: relative;
    transition: background-color 0.3s ease;
}

header {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 16px 20px;
    background: var(--header-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    width: 100%;
    box-sizing: border-box;
    overflow: visible;
    transition: background-color 0.3s ease;
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    margin-bottom: 0.75rem;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.list-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background-color: var(--bg-dark);
    border: 0.6px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    color: var(--text-primary);
}

.task-checkbox {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: var(--bg-dark);
    border: 0.6px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

#search-input {
    width: 100%;
    background: var(--bg-dark);
    border: 0.6px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 6px 12px 6px 44px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    height: 36px;
}

.input-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    z-index: 900;
}

.input-field {
    flex: 1;
    height: 48px;
    padding: 0 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s ease;
}

.input-field:focus {
    border-color: var(--accent-color);
    background: rgba(2, 6, 23, 0.8);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

main {
    margin-top: 1rem;
    padding-top: 1rem;
    /* The actual visible gap between header border and first item */
}

/* Ensure task/list containers allow native vertical panning on touch devices */
#tasks-container,
#lists-container {
    overflow-y: auto;
}



/* Utilities */
/* Unified visibility helpers */
.hidden {
    display: none;
}


.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.slide-in-right {
    animation: slideInRight 0.3s ease-out;
}

.slide-in-left {
    animation: slideInLeft 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(20px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.page-reveal {
    animation: pageReveal 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes pageReveal {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
        filter: blur(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

.btn-delete-item {
    background: var(--danger-bg);
    border: 1px solid var(--danger-bg);
    color: #ff4d4d;
    /* More vivid red for visibility */
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 1;
    /* Fully visible */
    min-width: 32px;
    min-height: 32px;
    flex-shrink: 0;
    /* Never squash on mobile */
    margin-left: 0.5rem;
}

.btn-delete-item:hover {
    background: rgba(239, 68, 68, 0.4);
    border-color: #ff4d4d;
}

.inline-edit-input {
    background: var(--bg-dark);
    border: 0.6px solid var(--accent-color);
    color: var(--text-primary);
    padding: 2px 4px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: inherit;
    width: 100%;
    outline: none;
}

.item-text {
    cursor: text;
    padding: 2px 0;
}

.item-text:hover {
    background: var(--hover-bg);
    border-radius: 2px;
}

/* Components */
/* Progress bar as a row helper */

.header-row {
    width: 100%;
    display: flex;
    align-items: center;
    position: relative;
    margin-bottom: 10px;
}

.header-row:last-child {
    margin-bottom: 0;
}

.progress-row {
    display: none;
    /* Hidden by default, shown via class by JS */
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    margin: 4px 0;
    min-height: 24px;
    z-index: 10;
}

.progress-row.visible-row {
    display: flex !important;
}

.hidden {
    display: none !important;
}

/* Animations pour les boutons d'actions groupées */
#btn-check-all,
#btn-uncheck-all {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

#btn-check-all:hover {
    background: var(--success-bg) !important;
    border-color: var(--success-color) !important;
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 5px 15px rgba(16, 185, 129, 0.3);
    color: var(--text-inverse) !important;
}

#btn-uncheck-all:hover {
    background: var(--hover-bg) !important;
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 5px 15px var(--shadow-color);
}

#btn-check-all:active,
#btn-uncheck-all:active {
    transform: translateY(0) scale(0.98);
}

#list-actions-row {
    width: 100%;
    display: flex;
    margin-top: 0.5rem;
}



.title-row {
    justify-content: center;
    /* Center the title */
    position: relative;
    min-height: 32px;
}

#back-button {
    position: absolute;
    left: -4px;
}

#refresh-button {
    position: absolute;
    right: -4px;
}

.controls-row {
    justify-content: space-between;
    gap: 0.75rem;
}

#search-container {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

#search-container i {
    position: absolute;
    left: 14px;
    width: 14px;
    height: 14px;
    color: var(--text-secondary);
    pointer-events: none;
    opacity: 0.6;
}



#search-input:focus {
    border-color: var(--accent-color);
    background: var(--bg-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

/* Progress bar as a row helper */

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 2px;
}

#header-progress-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.01em;
}

#header-progress-pct {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent-color);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#header-progress-pct.complete {
    color: var(--success-color);
    text-shadow: 0 0 8px rgba(77, 164, 78, 0.3);
}

.progress-track {
    height: 14px;
    width: 100%;
    background: var(--bg-dark);
    border: 1.5px solid var(--border-light);
    border-radius: 99px;
    overflow: hidden;
    position: relative;
    box-shadow:
        inset 0 4px 8px var(--shadow-color),
        0 2px 0 var(--hover-bg);
    /* Outer rim light */
    display: flex !important;
    margin-top: 6px;
    backdrop-filter: blur(5px);
}

.progress-track::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 8px;
    right: 8px;
    height: 3px;
    background: var(--border-light);
    border-radius: 99px;
    z-index: 10;
    pointer-events: none;
}

/* Ludic "Pop" Animation when updating */
.progress-row.hit-animate {
    animation: progress-pop 0.4s cubic-bezier(0.17, 0.89, 0.32, 1.49);
}

@keyframes progress-pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.025);
        filter: brightness(1.1);
    }

    100% {
        transform: scale(1);
    }
}

#header-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg,
            #3b82f6,
            #6366f1,
            #f97316,
            #6366f1,
            #3b82f6);
    background-size: 300% 100%;
    border-radius: 99px;
    transition: width 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* Slower, more liquid bounce */
    box-shadow:
        0 0 20px rgba(59, 130, 246, 0.5),
        inset 0 2px 5px var(--bg-glass);
    animation: shimmer 4s infinite linear;
    /* Slower color animation */
    position: relative;
    overflow: visible;
    /* Allow sparks to fly out */
}

/* Dynamite Fuse Sparks at the tip: spawned via JS */
.spark-particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: #fff;
    border-radius: 50%;
    z-index: 30;
    pointer-events: none;
    box-shadow: 0 0 6px #fff, 0 0 12px #ffae00, 0 0 18px #ff4d00;
}

@keyframes spark-burn {
    0% {
        transform: translate(0, 0) scale(1.5);
        opacity: 1;
        filter: brightness(2);
    }

    100% {
        transform: translate(var(--dx), var(--dy)) scale(0);
        opacity: 0;
        filter: brightness(0.5);
    }
}

@keyframes spark-float {

    0%,
    100% {
        transform: translateY(-50%) scale(1) rotate(0deg);
        opacity: 0.8;
    }

    50% {
        transform: translateY(-70%) scale(1.4) rotate(20deg);
        opacity: 1;
        filter: brightness(1.5);
    }
}

/* Confetti particles for 100% celebration */
.confetti-particle {
    position: fixed;
    width: 10px;
    height: 10px;
    z-index: 9999;
    pointer-events: none;
    border-radius: 2px;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-10vh) translateX(0) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(110vh) translateX(20px) rotate(720deg);
        opacity: 0;
    }
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

#header-progress-fill.complete {
    background: linear-gradient(90deg, #10b981, #34d399, #10b981);
    background-size: 200% 100%;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.6), inset 0 2px 4px var(--bg-glass);
    animation: shimmer 1.5s infinite linear, celebration-pulse 2s infinite ease-in-out;
}

@keyframes celebration-pulse {

    0%,
    100% {
        filter: brightness(1) drop-shadow(0 0 5px rgba(77, 164, 78, 0.4));
    }

    50% {
        filter: brightness(1.3) drop-shadow(0 0 15px rgba(77, 164, 78, 0.8));
    }
}



/* Specific override for header using glass-panel to ensure dropdowns work */
header.glass-panel {
    overflow: visible !important;
}


h1 {
    margin: 0;
    font-size: 1.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Optimized Header Spacing on Mobile */
@media (max-width: 520px) {
    header {
        padding: 10px 12px;
    }

    .header-row {
        margin-bottom: 8px;
    }

    #header-title {
        font-size: 1.15rem;
    }

    .controls-row {
        gap: 0.5rem;
    }

    #search-input {
        height: 32px;
        font-size: 13px;
        padding: 4px 8px 4px 34px;
    }

    .progress-row {
        margin-top: 2px;
        min-height: 22px;
    }

    .progress-row.visible-row {
        display: flex !important;
        margin-top: 4px;
        margin-bottom: 2px;
        min-height: 24px;
    }

    #header-progress-label {
        font-size: 0.7rem;
        font-weight: 600;
        color: var(--text-primary);
        /* High visibility */
    }

    #header-progress-pct {
        font-size: 0.85rem;
    }

    .progress-track {
        height: 12px;
        background: var(--bg-dark) !important;
        display: flex !important;
        border: 1px solid var(--border-light) !important;
    }

    main {
        margin-top: 2rem;
        /* Give more breath for sticky 3-row header */
        padding-top: 0.5rem;
    }
}


.btn-icon {
    background: transparent;
    border: 1px solid transparent;
    /* Reserve space for border */
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.55rem;
    /* Increased from 0.4rem for better click zone on desktop/mobile */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: all 0.1s;
}

.btn-icon:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.btn-icon:active {
    background: rgba(0, 0, 0, 0.2);
    transform: translateY(1px);
}

.btn-icon-small {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    /* Increased from 0.25rem */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-icon-small:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.section-bullet {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 0.75rem;
    flex-shrink: 0;
    box-shadow: 0 0 5px var(--shadow-color);
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border-light);
}

.section-bullet:hover {
    transform: scale(1.2);
    filter: brightness(1.2);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

/* List Styles */
.list-item {
    padding: 0.45rem 1.25rem;
    /* Massive reduction of vertical padding (-40%) */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.1s;
    touch-action: pan-y;
    /* Allow vertical scroll */
}

.list-item:active {
    transform: scale(0.98);
}

.list-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background-color: var(--bg-dark);
    /* Default dark */
    border: 0.6px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    color: var(--text-primary);
}

.list-meta {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Task Styles */
.task-item {
    padding: 0.34rem 1rem;
    /* Massive reduction of vertical padding (-40%) */
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 0.6px solid transparent;
    touch-action: pan-y;
    /* Allow vertical scroll */
}

.task-item.in-section {
    margin-left: 1.25rem;
    padding-left: 0.75rem;
    border-left: 0.6px solid var(--border-light);
    /* Subtle grouping line */
}

.task-checkbox {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    /* Sharper */
    background: var(--bg-dark);
    /* Inner shadow look */
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    box-shadow: inset 0 1px 3px var(--shadow-color);
    flex-shrink: 0;
}

.task-item.done .task-checkbox {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    box-shadow: none;
}

.task-item.done span {
    text-decoration: line-through;
    color: var(--text-secondary);
}

/* Drag Handle */
.drag-handle {
    cursor: grab;
    color: var(--text-secondary);
    padding: 0;
    margin-right: 0.25rem;
    opacity: 0.5;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 0;
    margin-right: 0;
    height: 32px;
    box-sizing: border-box;
    flex-shrink: 0;
    touch-action: none;
    /* Prevent scroll when dragging handle */
}

.drag-handle:hover {
    opacity: 1;
}

.drag-handle:active {
    cursor: grabbing;
}

/* Dragging State */
.dragging {
    opacity: 0.5 !important;
    background: var(--bg-secondary) !important;
    border: 1px dashed var(--accent-color) !important;
    cursor: grabbing !important;
}

.drag-over {
    /* Kept for generic drop zones, although ideally replaced */
    border-top: 2px solid var(--accent-color) !important;
}

.drag-over-top {
    border-top: 2px solid var(--accent-color) !important;
}

.drag-over-bottom {
    border-bottom: 2px solid var(--accent-color) !important;
}

.drag-over-header {
    border: 2px solid var(--accent-color) !important;
    background: rgba(235, 118, 0, 0.1) !important;
    border-radius: var(--radius-md);
}

.dragging-active .drop-zone-spacer {
    opacity: 0.5;
    background: var(--hover-bg);
    border: 1px dashed var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    pointer-events: auto;
    /* Essential for catching drop */
}

.drag-over-boundary {
    box-shadow: 0 0 15px var(--accent-glow) !important;
    border: 2px dashed var(--accent-color) !important;
    background: rgba(235, 118, 0, 0.1) !important;
    height: 48px !important;
    opacity: 1 !important;
    color: var(--accent-color) !important;
}

.drop-zone-spacer {
    height: 14px;
    margin: 4px 0;
    transition: all 0.2s ease;
    border-radius: var(--radius-md);
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    /* Only interactive when dragging */
}

.list-header.sub-header {
    margin-left: 1.5rem;
    /* Slightly more than items to emphasize role */
    padding-left: 0.75rem;
    border-left: 0.6px solid var(--border-light);
    /* Reduced to 0.6px */
    background: var(--hover-bg);
    /* Darker than main headers */
    font-size: 0.85rem;
    min-height: 20px;
    /* Reduced from 32px (-40%) */
}

.task-item.in-sub-section {
    margin-left: 3.25rem;
    /* Triple the base indent for clarity */
    padding-left: 0.75rem;
    border-left: 0.6px solid var(--border-light);
}

/* Collapse Arrow */
.collapse-arrow {
    cursor: pointer;
    color: var(--text-secondary);
    transition: transform 0.2s;
    margin-right: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    /* Increased from 20px for better touch target */
    height: 32px;
    /* Increased from 20px for better touch target */
}

.collapse-arrow.collapsed {
    transform: rotate(-90deg);
}

.list-header {
    background: transparent;
    padding: 0.5rem 0.5rem 0.16rem 0.5rem;
    /* Reduced by 40% */
    color: var(--accent-color);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-color);
    margin-top: 0.5rem;
    margin-bottom: 0.75rem;
    /* Space before first item in section */
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: default;
}

.list-header .item-text {
    cursor: pointer;
}

/* Edit (pencil) button: hide by default and show on header hover (desktop),
   but always show on touch devices where hover isn't available. */
.list-header .btn-icon-small {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    transform: translateY(0);
    margin-left: 0.5rem;
}

.list-header:hover .btn-icon-small {
    opacity: 1;
    pointer-events: auto;
}

/* Touch devices: make the edit button always visible */
@media (hover: none) {
    .list-header .btn-icon-small {
        opacity: 1;
        pointer-events: auto;
    }
}

.btn-lock-section {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: calc(2rem + env(safe-area-inset-bottom));
    right: 2rem;
    width: 64px;
    height: 64px;
    /* Standard Button Style for FAB in Blender */
    border-radius: var(--radius-lg);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    box-shadow: 0 4px 12px var(--shadow-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
    z-index: 50;
}

.fab:active {
    transform: scale(0.9);
}

/* Input Bar */
.input-bar {
    position: fixed;
    bottom: calc(1.5rem + env(safe-area-inset-bottom));
    left: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    width: calc(100% - 2rem);
    max-width: 568px;
    /* 600 - padding */
    z-index: 50;
}

.input-field {
    flex: 1;
    padding: 1rem;
    border-radius: var(--radius-lg);
    border: 0.6px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
}

.input-field:focus {
    outline: none;
    border-color: var(--accent-color);
}

.btn-send {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--btn-send-bg);
    color: var(--accent-color);
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-send:hover {
    background: var(--bg-dark);
    border-color: var(--accent-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.btn-send:active {
    transform: translateY(1px);
    background: var(--bg-primary);
}

/* Control group alignment (Filter + Settings) */
.controls-row>div:last-child {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    justify-content: flex-end;
}

#search-container {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    max-width: none;
}

#search-container input {
    width: 100% !important;
    box-sizing: border-box;
}

.touch-ghost {
    background: var(--bg-glass) !important;
    border: 1px solid var(--accent-color) !important;
    box-shadow: var(--shadow-lg) !important;
    transform: scale(1.02) !important;
    /* No translate shift, centered under finger */
    z-index: 10000 !important;
    opacity: 0.8 !important;
    /* Increased opacity for better visibility */
    pointer-events: none !important;
    border-radius: var(--radius-lg);
}

.list-header.selected-section {
    background: rgba(235, 118, 0, 0.15) !important;
    border-left: 4px solid var(--accent-color) !important;
    transition: background 0.3s ease;
}

/* Row visibility helper */
.header-row.hidden {
    display: none !important;
}

/* Item Explosion Animation */
.exploding {
    animation: item-implode 0.4s cubic-bezier(0.1, 0.7, 0.1, 1) forwards;
    pointer-events: none;
}

@keyframes item-implode {
    0% {
        transform: scale(1);
        opacity: 1;
        filter: brightness(1);
    }

    30% {
        transform: scale(1.1) rotate(2deg);
        filter: brightness(2);
    }

    100% {
        transform: scale(0.4) rotate(-4deg);
        opacity: 0;
        filter: brightness(3);
    }
}

.explosion-particle {
    position: fixed;
    width: 8px;
    height: 8px;
    z-index: 10000;
    pointer-events: none;
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.6);
}

@keyframes explosion-fly {
    0% {
        transform: translate(0, 0) scale(2);
        opacity: 1;
        filter: brightness(1.5);
    }

    100% {
        transform: translate(var(--dx), var(--dy)) scale(0);
        opacity: 0;
    }
}


/* Enhanced Page Reveal with Glow - Adjusted for Curtain */
@keyframes pageReveal {
    0% {
        opacity: 0;
        transform: scale(0.98);
        filter: blur(10px) brightness(0.8);
    }

    40% {
        opacity: 0.3;
    }

    100% {
        opacity: 1;
        transform: scale(1);
        filter: blur(0) brightness(1);
    }
}

/* Theme Switch Slider */
.theme-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

input:checked+.slider:before {
    transform: translateX(20px);
    background-color: white;
}

.slider svg {
    position: absolute;
    top: 5px;
    width: 12px;
    height: 12px;
    z-index: 0;
    transition: opacity 0.4s;
}

.icon-sun {
    left: 6px;
    color: #ffcc00;
    opacity: 0;
    /* Hidden in dark mode by default */
}

.icon-moon {
    right: 6px;
    color: #a3a3a3;
    opacity: 1;
    /* Visible in dark mode */
}

input:checked+.slider .icon-sun {
    opacity: 1;
}

input:checked+.slider .icon-moon {
    opacity: 0;
}

/* --- New Theme-Aware Classes --- */

/* Login Screen */
.login-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    padding: 2rem;
    text-align: center;
    background: var(--bg-body);
}

.login-screen h1 {
    color: var(--accent-color);
    margin-bottom: 2rem;
    font-size: 2rem;
    font-weight: 700;
}

.login-screen p {
    margin-bottom: 2rem;
    color: var(--text-secondary);
}

.login-btn {
    width: auto !important;
    padding: 1rem 2rem !important;
    border-radius: 2rem !important;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.login-btn.secondary {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--accent-color) !important;
}

/* PWA Banner */
.pwa-banner {
    margin: 1rem;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border-color);
}

.pwa-banner-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.pwa-banner-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.pwa-banner-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.pwa-install-btn {
    width: auto !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.8rem !important;
    height: auto !important;
}

/* Profile & Avatar */
.profile-container {
    position: relative;
    display: flex;
    align-items: center;
    margin-left: 0.5rem;
}

.avatar-img, .avatar-fallback {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--accent-color);
    object-fit: cover;
}

.avatar-fallback {
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-fallback i {
    width: 16px;
    height: 16px;
    color: var(--text-primary);
}

.user-dropdown {
    position: absolute;
    top: 120%;
    right: 0;
    min-width: max-content;
    padding: 0.5rem;
    z-index: 1000;
    animation: fadeIn 0.1s ease-out;
}

.logout-menu-btn {
    width: 100% !important;
    justify-content: flex-start !important;
    color: var(--danger-color) !important;
    font-size: 0.9rem !important;
    white-space: nowrap;
}

.logout-menu-btn i {
    width: 16px;
    height: 16px;
    margin-right: 0.5rem;
}

/* Task Input Bar */
.task-input-bar {
    padding: 0.5rem !important;
    background: var(--bg-glass) !important;
}

.header-mode-toggle {
    color: var(--text-secondary) !important;
    width: 48px !important;
    height: 48px !important;
    border-radius: 8px !important;
    position: relative;
}

.mini-plus {
    position: absolute;
    width: 10px !important;
    height: 10px !important;
    top: 6px;
    right: 6px;
}

.task-input {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Modals & Overlays */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal-content {
    width: 92%;
    max-width: 340px;
    padding: 1.5rem;
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-lg);
}

.modal-content.compact {
    max-width: 320px;
}

.modal-content.medium {
    max-width: 380px;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.modal-btn {
    width: 100% !important;
    border-radius: 0.5rem !important;
    justify-content: flex-start !important;
    gap: 0.75rem;
    font-size: 1rem !important;
    padding: 0.75rem !important;
    background: var(--hover-bg) !important;
    color: var(--text-primary) !important;
}

.modal-btn.primary {
    background: var(--hover-bg) !important;
    color: var(--accent-color) !important;
    border: 0.6px solid var(--accent-glow) !important;
}

.modal-btn.danger {
    background: var(--danger-bg) !important;
    color: var(--danger-color) !important;
    border: 0.6px solid var(--danger-bg) !important;
}

.modal-btn.success {
    background: var(--success-bg) !important;
    color: var(--success-color) !important;
    border: 0.6px solid var(--success-bg) !important;
    justify-content: center !important;
}

.modal-btn.cancel {
    justify-content: center !important;
    margin-top: 0.5rem;
}

.modal-btn.secondary-alt {
    justify-content: center !important;
    background: var(--border-color) !important;
    color: var(--text-primary) !important;
}

.modal-row {
    display: flex;
    gap: 0.75rem;
}

.modal-divider {
    border: none;
    border-top: 0.6px solid var(--border-color);
    margin: 0.5rem 0;
}

.modal-title-small {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.modal-title-large {
    margin-top: 0;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

#modal-title {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
    color: var(--accent-color);
}

#modal-desc {
    margin: 0 0 1.5rem 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    letter-spacing: 0.01em;
}

/* Color Grid */
.color-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

/* Collaboration */
.modal-owner-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    word-break: break-all;
}

.collab-section {
    margin-bottom: 1.5rem;
}

.collab-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.collab-input-group {
    display: flex;
    gap: 0.5rem;
}

.collab-input {
    flex: 1;
    min-width: 0;
    background: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.6rem 0.8rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
}

.collab-add-btn {
    flex-shrink: 0;
    width: 42px !important;
    height: 42px !important;
    justify-content: center !important;
    background: var(--accent-color) !important;
    color: white !important;
}

.collab-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 1.5rem;
    padding-right: 0.5rem;
}

/* Utilities */
.z-top { z-index: 1001; }
.z-top-top { z-index: 1002; }