:root{
    --bg-page: #ffffff;
    --bg-panel: #f3f3f3;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --text-primary: rgba(0,0,0,0.7);
    --text-secondary: rgba(0,0,0,0.6);
    --text-muted: rgba(0,0,0,0.4);
    --shadow-card: rgba(0,0,0,0.08);
    --track-bg: #e0e0e0;
    --completed-bg: #eafaf0;
}

body.dark{
    --bg-page: #121212;
    --bg-panel: #1c1c1c;
    --bg-card: #262626;
    --bg-input: #1c1c1c;
    --text-primary: rgba(255,255,255,0.85);
    --text-secondary: rgba(255,255,255,0.6);
    --text-muted: rgba(255,255,255,0.35);
    --shadow-card: rgba(0,0,0,0.4);
    --track-bg: #3a3a3a;
    --completed-bg: #1c3327;
}

/* ---- Page header ---- */

.page-header{
    width:800px;
    max-width: calc(100% - 40px);
    margin: 0 auto;
    text-align: center;
}
.page-header h1{
    margin: 0;
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    transition: color 0.3s ease;
}
.page-header .cursor{
    display:inline-block;
    color: #8bc34a;
    animation: cursor-blink 1.1s steps(1) infinite;
}
@keyframes cursor-blink{
    0%, 50% { opacity: 1; }
    50.01%, 100% { opacity: 0; }
}
.page-subtitle{
    margin: 6px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
    transition: color 0.3s ease;
}

body{
    margin:0;
    display:flex;
    gap:28px;
    flex-flow: column wrap;
    box-sizing: border-box;
    background-color: var(--bg-page);
    transition: background-color 0.3s ease;
    font-family: 'JetBrains Mono', monospace;
    padding: 40px 20px 60px;
}
.form{
    display:flex;
    padding:28px 24px;
    background-color: var(--bg-panel);
    flex-flow: row wrap;
    width:800px;
    margin:0 auto;
    justify-content: center;
    align-items: center;
    gap:20px;
    transition: background-color 0.3s ease;
    border-radius: 16px;
    max-width: calc(100% - 40px);
    box-sizing: border-box;
}
.input{
    width:400px;
    height:35px;
    border:2px solid #03a9f4;
    border-radius: 15px;
    caret-color: var(--text-primary);
    text-indent: 25px;
    font-size: 15px;
    font-family: 'JetBrains Mono', monospace;
    background-color: var(--bg-input);
    color: var(--text-primary);
}
.input:focus{
    outline:none;
    border-color: #8bc34a;
}
.category-input{
    width:150px;
    height:35px;
    border:2px solid #607d8b;
    border-radius: 15px;
    text-indent: 15px;
    font-size: 14px;
    font-family: 'JetBrains Mono', monospace;
    background-color: var(--bg-input);
    color: var(--text-primary);
}
.category-input:focus{
    outline:none;
    border-color: #8bc34a;
}
.date-input{
    width:140px;
    height:31px;
    border:2px solid #607d8b;
    border-radius: 15px;
    text-indent: 10px;
    font-size: 13px;
    font-family: 'JetBrains Mono', monospace;
    background-color: var(--bg-input);
    color: var(--text-primary);
}
.date-input:focus{
    outline:none;
    border-color: #8bc34a;
}
.add{
    width:150px;
    height:46px;
    border:2px solid transparent;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color:white;
    background-color: #03a9f4;
    cursor:pointer;
    font-family: 'JetBrains Mono', monospace;
    transition: transform 0.15s ease, background-color 0.2s ease;
}
.add:hover{
    background-color: #0288c4;
    transform: translateY(-1px);
}
.tasks{
    margin:0 auto;
    background-color: var(--bg-panel);
    width:800px;
    max-width: calc(100% - 40px);
    box-sizing: border-box;
    display:flex;
    flex-flow: column wrap;
    justify-content: center;
    align-items: center;
    gap:14px;
    padding:28px 24px;
    border-radius: 16px;
    transition: background-color 0.3s ease;
}
.task{
    background-color: var(--bg-card);
    color: var(--text-primary);
    width:75%;
    display:flex;
    flex-flow: row wrap;
    gap:8px;
    padding:14px 16px;
    justify-content: space-around;
    align-items: center;
    font-size: 15px;
    font-family: 'JetBrains Mono', monospace;
    transition: background-color 0.3s ease, opacity 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease, color 0.3s ease;
    box-shadow: 0 1px 3px var(--shadow-card);
    border-left: 6px solid var(--task-accent, #ccc);
    border-radius: 10px;
}

.task div{
    width:400px;
}

/* Drag handle + up/down controls */
.task{
    cursor: grab;
}
.task.dragging{
    cursor: grabbing;
    opacity: 0.4;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}
.reorder-controls{
    display:flex;
    flex-flow: column wrap;
    gap:3px;
    width:auto !important;
}
.move-btn{
    background-color: #607d8b;
    color:white;
    border:2px solid transparent;
    border-radius: 6px;
    font-size: 10px;
    padding:4px 6px;
    cursor:pointer;
    line-height: 1;
    transition: transform 0.15s ease, background-color 0.2s ease, opacity 0.2s ease;
}
.move-btn:hover:not(:disabled){
    background-color: #455a64;
    transform: scale(1.1);
}
.move-btn:disabled{
    opacity: 0.3;
    cursor: not-allowed;
}

/* Inline edit input, matches the h2 it replaces */
.edit-input{
    width:100%;
    font-family: 'JetBrains Mono', monospace;
    font-size: 17px;
    padding: 3px 6px;
    border: 2px solid #03a9f4;
    border-radius: 6px;
    box-sizing: border-box;
    outline: none;
}
.edit-input:focus{
    border-color: #8bc34a;
}

.edit-btn{
    background-color: #03a9f4;
}
.edit-btn:hover{
    background-color: #0288c4;
}

.task h2{
    margin:0;
    font-size:16px;
    font-weight: 500;
    letter-spacing: 0.1px;
    transition: color 0.3s ease, text-decoration-color 0.3s ease;
}

/* Completed task state */
.task.completed{
    background-color: var(--completed-bg);
    opacity: 0.8;
}
.task.completed h2{
    text-decoration: line-through;
    text-decoration-color: #8bc34a;
    color: var(--text-muted);
}

.task button{
    background-color: orangered;
    color:white;
    border: 2px solid transparent;
    border-radius: 50%;
    font-size: 15px;
    padding:10px 10px;
    cursor:pointer;
    transition: transform 0.15s ease, background-color 0.2s ease;
}
.task button:hover{
    transform: scale(1.1);
}

.complete-btn{
    background-color: #8bc34a;
}
.complete-btn:hover{
    background-color: #7cb342;
}
.task.completed .complete-btn{
    background-color: #9e9e9e;
}
.task.completed .complete-btn:hover{
    background-color: #8bc34a;
}

/* ---- Categories: filter bar, badges, spotlight ---- */

.filter-bar{
    margin:0 auto;
    width:800px;
    max-width: calc(100% - 40px);
    display:flex;
    flex-flow: row wrap;
    gap:10px;
    padding: 0 20px;
    box-sizing: border-box;
}
.filter-pill{
    background-color: var(--bg-card);
    color: var(--pill-color, #555);
    border: 2px solid var(--pill-color, #555);
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 13px;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.filter-pill:hover{
    transform: scale(1.05);
}
.filter-pill.active{
    background-color: var(--pill-color, #555);
    color: white;
}

.category-badge{
    display:inline-block;
    background-color: var(--badge-color, #999);
    color: white;
    font-size: 10px;
    font-family: 'JetBrains Mono', monospace;
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: 4px;
    letter-spacing: 0.3px;
}

/* Spotlight: dim non-matching tasks in place instead of hiding/reflowing them */
.task.spotlight-dim{
    opacity: 0.25;
    transform: scale(0.98);
}
.task.spotlight-active{
    opacity: 1;
    transform: scale(1.01);
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
}

/* ---- Due dates ---- */

.due-badge{
    display:inline-block;
    font-size: 10px;
    font-family: 'JetBrains Mono', monospace;
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: 4px;
    margin-left: 6px;
    letter-spacing: 0.3px;
    border: 1px solid transparent;
}
.due-upcoming{
    background-color: #e3f2fd;
    color: #1565c0;
    border-color: #90caf9;
}
.due-today{
    background-color: #fff3e0;
    color: #ef6c00;
    border-color: #ffb74d;
}
.due-overdue{
    background-color: #ffebee;
    color: #c62828;
    border-color: #ef9a9a;
}

/* Overdue tasks get a soft red glow layered on top of whatever box-shadow
   they already have (dragging, spotlight, etc.) rather than overriding
   the category accent border - urgency and category stay independent signals */
.task.overdue{
    box-shadow: 0 0 0 2px rgba(198, 40, 40, 0.35), 0 1px 3px rgba(0,0,0,0.08);
}

/* ---- Progress bar ---- */

.progress-container{
    margin:0 auto;
    width:800px;
    max-width: calc(100% - 40px);
    padding: 0 20px;
    box-sizing: border-box;
}
.progress-label{
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    transition: color 0.3s ease;
}
.progress-track{
    width:100%;
    height:14px;
    background-color: var(--track-bg);
    border-radius: 10px;
    overflow: hidden;
    transition: background-color 0.3s ease;
}
.progress-fill{
    height:100%;
    width:0%;
    border-radius: 10px;
    transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.5s ease;
}

/* Little celebratory pulse once everything's done */
.progress-container.complete .progress-label{
    color: #2e7d32;
    font-weight: bold;
}
.progress-container.complete .progress-fill{
    animation: progress-pulse 1.2s ease-in-out 2;
}
@keyframes progress-pulse{
    0%, 100% { box-shadow: 0 0 0 0 rgba(139, 195, 74, 0.6); }
    50% { box-shadow: 0 0 0 6px rgba(139, 195, 74, 0); }
}

/* ---- Search ---- */

.search-container{
    margin:0 auto;
    width:800px;
    max-width: calc(100% - 40px);
    padding: 0 20px;
    box-sizing: border-box;
    position: relative;
    display:flex;
    align-items: center;
}
.search-input{
    width:100%;
    height:38px;
    border:2px solid #03a9f4;
    border-radius: 20px;
    text-indent: 20px;
    padding-right: 40px;
    font-size: 14px;
    font-family: 'JetBrains Mono', monospace;
    box-sizing: border-box;
    background-color: var(--bg-input);
    color: var(--text-primary);
}
.search-input:focus{
    outline:none;
    border-color: #8bc34a;
}
.search-clear{
    position: absolute;
    right: 30px;
    background: none;
    border: none;
    color: #999;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, color 0.15s ease;
}
.search-clear.visible{
    opacity: 1;
    pointer-events: auto;
}
.search-clear:hover{
    color: #c62828;
}

/* Matched substring inside a task's title */
.task mark{
    background-color: #fff59d;
    color: inherit;
    border-radius: 3px;
    padding: 0 2px;
}

/* ---- Theme toggle ---- */

.theme-toggle{
    position: fixed;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--text-secondary);
    background-color: var(--bg-card);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    display:flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease, transform 0.15s ease, border-color 0.3s ease;
    z-index: 100;
}
.theme-toggle:hover{
    transform: scale(1.1) rotate(15deg);
}

/* ---- Undo toast ---- */

.undo-toast{
    position: fixed;
    bottom: -80px; /* parked off-screen; .visible slides it up */
    left: 50%;
    transform: translateX(-50%);
    display:flex;
    align-items: center;
    gap: 16px;
    background-color: #323232;
    color: white;
    padding: 14px 18px;
    border-radius: 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.3);
    transition: bottom 0.35s ease;
    overflow: hidden;
    z-index: 200;
    max-width: 90vw;
}
.undo-toast.visible{
    bottom: 24px;
}
.undo-message{
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60vw;
}
.undo-btn{
    background: none;
    border: none;
    color: #8bc34a;
    font-family: 'JetBrains Mono', monospace;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background-color 0.15s ease;
    flex-shrink: 0;
}
.undo-btn:hover{
    background-color: rgba(139, 195, 74, 0.15);
}
/* Countdown bar that shrinks over the undo window. Starts at 0 width and
   is only animated while .running is present, so re-triggering a delete
   (see the reflow trick in deleteWithUndo) restarts it cleanly. */
.undo-bar{
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background-color: #8bc34a;
    transform-origin: left;
    transform: scaleX(0);
}
.undo-bar.running{
    animation: undo-countdown 5s linear forwards;
}
@keyframes undo-countdown{
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}