:root {
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --container-bg: rgba(255, 255, 255, 0.85);
    --text-color: #2d3436;
    --text-muted: #636e72;
    --primary-color: #6c5ce7;
    --accent-color: #a29bfe;
    --danger-color: #ff7675;
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --border: 1px solid rgba(255, 255, 255, 0.4);
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

[data-theme="dark"] {
    --bg-gradient: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
    --container-bg: rgba(30, 39, 46, 0.85);
    --text-color: #dfe6e9;
    --text-muted: #b2bec3;
    --primary-color: #74b9ff;
    --accent-color: #0984e3;
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --border: 1px solid rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

body {
    background: var(--bg-gradient);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
    transition: background 0.5s ease;
}

#preloader {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}
[data-theme="dark"] #preloader { background: #1e272e; }

.spinner {
    width: 50px; height: 50px;
    border: 5px solid rgba(108, 92, 231, 0.2);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.background-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    animation: float 6s ease-in-out infinite;
}
.shape-1 { width: 300px; height: 300px; background: var(--primary-color); top: -50px; left: -50px; opacity: 0.4; }
.shape-2 { width: 250px; height: 250px; background: var(--accent-color); bottom: -50px; right: -50px; opacity: 0.4; animation-delay: 3s; }

.container {
    background: var(--container-bg);
    width: 100%;
    max-width: 450px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 24px;
    border: var(--border);
    box-shadow: var(--shadow);
    padding: 2.5rem;
    position: relative;
    overflow: hidden;
}

header { margin-bottom: 1.5rem; }
.header-top { display: flex; justify-content: space-between; align-items: center; }
h1 { font-size: 2rem; font-weight: 600; color: var(--text-color); }

#theme-toggle {
    background: none; border: none; font-size: 1.2rem;
    color: var(--text-color); cursor: pointer; transition: var(--transition);
}
#theme-toggle:hover { transform: rotate(15deg) scale(1.1); color: var(--primary-color); }

#date-display { font-size: 0.9rem; color: var(--text-muted); margin-top: 5px; }

.input-group { position: relative; display: flex; gap: 10px; margin-bottom: 1.5rem; }
input {
    width: 100%; padding: 14px 18px; border-radius: 12px;
    border: 2px solid transparent; background: rgba(255,255,255,0.5);
    color: var(--text-color); outline: none; font-size: 1rem;
    transition: var(--transition); box-shadow: inset 0 2px 5px rgba(0,0,0,0.02);
}
[data-theme="dark"] input { background: rgba(0,0,0,0.2); }

input:focus { border-color: var(--primary-color); background: transparent; }

#add-btn {
    background: var(--primary-color); color: white; border: none;
    border-radius: 12px; width: 50px; cursor: pointer;
    font-size: 1.2rem; transition: var(--transition);
}
#add-btn:hover { transform: scale(1.05); box-shadow: 0 5px 15px rgba(108, 92, 231, 0.4); }

.filters { display: flex; gap: 15px; margin-bottom: 1.5rem; border-bottom: 1px solid rgba(0,0,0,0.05); padding-bottom: 10px; }
.filter-btn {
    font-size: 0.85rem; color: var(--text-muted); cursor: pointer;
    position: relative; transition: var(--transition); font-weight: 500;
}
.filter-btn.active { color: var(--primary-color); }
.filter-btn.active::after {
    content: ''; position: absolute; bottom: -11px; left: 0; width: 100%;
    height: 2px; background: var(--primary-color); border-radius: 2px;
}

ul { list-style: none; max-height: 400px; overflow-y: auto; padding-right: 5px; }

ul::-webkit-scrollbar { width: 6px; }
ul::-webkit-scrollbar-thumb { background: #ccc; border-radius: 10px; }
[data-theme="dark"] ul::-webkit-scrollbar-thumb { background: #555; }

li {
    background: rgba(255,255,255,0.6);
    margin-bottom: 10px; padding: 12px 15px; border-radius: 12px;
    display: flex; justify-content: space-between; align-items: center;
    border: 1px solid transparent; transition: var(--transition);
    animation: slideIn 0.3s ease forwards;
}
[data-theme="dark"] li { background: rgba(255,255,255,0.05); }

li:hover { transform: translateY(-2px); border-color: var(--primary-color); box-shadow: 0 5px 15px rgba(0,0,0,0.05); }

.task-info { display: flex; align-items: center; gap: 12px; cursor: pointer; flex: 1; }
.check-circle {
    width: 22px; height: 22px; border: 2px solid var(--text-muted);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.check-circle i { font-size: 0.7rem; color: white; opacity: 0; transform: scale(0.5); transition: var(--transition); }
li span { font-size: 0.95rem; color: var(--text-color); transition: var(--transition); }

li.completed .check-circle { background: var(--primary-color); border-color: var(--primary-color); }
li.completed .check-circle i { opacity: 1; transform: scale(1); }
li.completed span { text-decoration: line-through; color: var(--text-muted); opacity: 0.7; }

.delete-btn {
    background: none; border: none; color: var(--danger-color);
    cursor: pointer; opacity: 0; transform: translateX(10px); transition: var(--transition);
}
li:hover .delete-btn { opacity: 1; transform: translateX(0); }
.delete-btn:hover { transform: scale(1.2); }

.app-footer {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 1.5rem; font-size: 0.8rem; color: var(--text-muted);
}
#clear-completed {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    transition: var(--transition);
}
#clear-completed:hover { color: var(--danger-color); text-decoration: underline; }

.empty-state { text-align: center; margin-top: 2rem; color: var(--text-muted); display: none; }
.empty-state i { font-size: 3rem; margin-bottom: 10px; opacity: 0.3; }

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes slideIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes float { 0% { transform: translate(0, 0); } 50% { transform: translate(20px, -20px); } 100% { transform: translate(0, 0); } }
@keyframes fadeOut { to { opacity: 0; transform: scale(0.9); } }