* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    view-transition-name: none;
    
    /* Light Theme Variables */
    --bg-gradient: linear-gradient(135deg, #fbc2eb 0%, #a6c1ee 50%, #fbc2eb 100%);
    --sidebar-bg: rgba(255, 255, 255, 0.6);
    --container-bg: rgba(255, 255, 255, 0.4);
    --container-border: rgba(255, 255, 255, 0.5);
    --text-primary: #1d1d1f;
    --text-secondary: #666;
    --h1-gradient: linear-gradient(90deg, #1d1d1f, #555);
    --input-bg: rgba(255, 255, 255, 0.6);
    --input-focus: rgba(255, 255, 255, 0.9);
    --input-focus-ring: rgba(166, 193, 238, 0.5);
    --btn-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --btn-shadow: rgba(118, 75, 162, 0.3);
    --li-bg: rgba(255, 255, 255, 0.5);
    --li-border: rgba(255, 255, 255, 0.3);
    --icon-bg: rgba(255, 255, 255, 0.5);
    --icon-hover: rgba(255, 255, 255, 0.9);
    --subtask-bg: rgba(255, 255, 255, 0.3);
    --nav-active-bg: rgba(255, 255, 255, 0.8);
}

[data-theme="dark"] {
    /* Dark Theme Variables */
    --bg-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #1a1a2e 100%);
    --sidebar-bg: rgba(20, 20, 36, 0.8);
    --container-bg: rgba(30, 30, 46, 0.6);
    --container-border: rgba(255, 255, 255, 0.1);
    --text-primary: #e2e8f0;
    --text-secondary: #a0aec0;
    --h1-gradient: linear-gradient(90deg, #e2e8f0, #a0aec0);
    --input-bg: rgba(0, 0, 0, 0.3);
    --input-focus: rgba(0, 0, 0, 0.5);
    --input-focus-ring: rgba(102, 126, 234, 0.5);
    --btn-gradient: linear-gradient(135deg, #4c51bf 0%, #6b46c1 100%);
    --btn-shadow: rgba(76, 81, 191, 0.4);
    --li-bg: rgba(0, 0, 0, 0.2);
    --li-border: rgba(255, 255, 255, 0.05);
    --icon-bg: rgba(255, 255, 255, 0.1);
    --icon-hover: rgba(255, 255, 255, 0.2);
    --subtask-bg: rgba(0, 0, 0, 0.15);
    --nav-active-bg: rgba(255, 255, 255, 0.1);
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-gradient);
    background-size: 200% 200%;
    animation: gradientBG 10s ease infinite;
    color: var(--text-primary);
    min-height: 100vh;
    transition: background 0.5s, color 0.5s;
    overflow: hidden; /* App Shell prevents body scroll */
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* APP SHELL LAYOUT */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* SIDEBAR */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(25px) saturate(200%);
    -webkit-backdrop-filter: blur(25px) saturate(200%);
    border-right: 1px solid var(--container-border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    z-index: 10;
    transition: background 0.5s, border 0.5s;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.sidebar-header h2 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: var(--h1-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-grow: 1;
}

.nav-btn {
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    background: transparent;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.nav-btn:hover {
    background: var(--icon-bg);
}

.nav-btn.active {
    background: var(--nav-active-bg);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--container-border);
}

/* MAIN CONTENT */
.main-content {
    flex-grow: 1;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    padding: 40px 20px;
}

.view-section {
    width: 100%;
    display: none;
    animation: fadeIn 0.3s ease-out;
}
.view-section.active {
    display: flex;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.container {
    background: var(--container-bg);
    backdrop-filter: blur(25px) saturate(200%);
    -webkit-backdrop-filter: blur(25px) saturate(200%);
    border: 1px solid var(--container-border);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
    border-radius: 24px;
    width: 100%;
    max-width: 600px;
    padding: 30px;
    transition: background 0.5s, border 0.5s;
    align-self: flex-start;
}

.placeholder-container {
    text-align: center;
    padding: 60px 20px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--container-border);
        padding: 15px;
    }
    .nav-links {
        flex-direction: row;
        overflow-x: auto;
    }
    .nav-btn {
        white-space: nowrap;
    }
    .sidebar-footer {
        display: none;
    }
    .main-content {
        padding: 20px 10px;
    }
}

/* Existing UI Styles from here */

.status-text {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    min-height: 18px;
    transition: color 0.5s;
    line-height: 1.4;
}

form {
    display: flex;
    margin-bottom: 25px;
    position: relative;
}

#todo-input {
    flex-grow: 1;
    padding: 16px 20px;
    font-size: 16px;
    color: var(--text-primary);
    border: none;
    background: var(--input-bg);
    border-radius: 12px;
    outline: none;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
    transition: background 0.3s, box-shadow 0.3s, color 0.3s;
}

#todo-input:focus {
    background: var(--input-focus);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05), 0 0 0 3px var(--input-focus-ring);
}

form button {
    position: absolute;
    right: 6px;
    top: 6px;
    bottom: 6px;
    padding: 0 20px;
    font-size: 15px;
    font-weight: 600;
    background: var(--btn-gradient);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

form button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--btn-shadow);
}
form button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#todo-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.task-item {
    display: flex;
    flex-direction: column;
    padding: 14px 16px;
    background: var(--li-bg);
    border: 1px solid var(--li-border);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    cursor: grab;
    view-transition-name: none;
    
    opacity: 1;
    transform: scale(1) translateY(0);
    transition: 
        background 0.3s, border 0.3s, display 0.4s, 
        opacity 0.4s ease-out, transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transition-behavior: allow-discrete;
}

.task-item:active {
    cursor: grabbing;
}

.task-item.dragging {
    opacity: 0.5;
    background: var(--input-focus);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.task-item.drag-over {
    border: 2px dashed var(--input-focus-ring);
    transform: scale(1.02);
}

@starting-style {
    .task-item {
        opacity: 0;
        transform: scale(0.9) translateY(-10px);
    }
}

.task-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.analysis-card {
    background: var(--li-bg);
    border: 1px solid var(--input-focus-ring);
    border-radius: 16px;
    padding: 16px 20px;
    margin-bottom: 25px;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    animation: fadeInDown 0.4s ease-out;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.date-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--icon-bg);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.date-badge::before {
    content: "📅";
    font-size: 10px;
}

.item-text {
    flex-grow: 1;
    margin-right: 15px;
    word-break: break-word;
    font-size: 16px;
    font-weight: 500;
    transition: color 0.3s;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.item-text-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.item-text-meta {
    display: flex;
    gap: 8px;
    align-items: center;
}

.subtask-list {
    list-style: none;
    margin-top: 10px;
    padding-left: 15px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-left: 2px solid var(--input-focus-ring);
}

.subtask-item {
    background: var(--subtask-bg);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: opacity 0.3s, text-decoration 0.3s;
}

.subtask-item::before {
    content: "○";
    margin-right: 8px;
    color: var(--text-secondary);
}

.subtask-item.completed {
    opacity: 0.6;
    text-decoration: line-through;
}

.subtask-item.completed::before {
    content: "●";
    color: var(--input-focus-ring);
}

.item-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.icon-btn {
    background: var(--icon-bg);
    color: var(--text-primary);
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.icon-btn:hover:not(:disabled) {
    background: var(--icon-hover);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transform: translateY(-1px);
}

.delete-btn {
    color: #ff4d4f;
}
.delete-btn:hover:not(:disabled) {
    background: rgba(255, 77, 79, 0.1);
    color: #ff4d4f;
}

.actions {
    margin-top: 25px;
    text-align: center;
}

#clear-completed-btn {
    background: var(--icon-bg);
    color: var(--text-primary);
    border: 1px solid var(--li-border);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

#clear-completed-btn:hover {
    background: var(--icon-hover);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.edit-input {
    flex-grow: 1;
    padding: 8px;
    font-size: 16px;
    margin-right: 10px;
    border: 1px solid var(--li-border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-primary);
    outline: none;
    transition: background 0.3s, color 0.3s;
}
.edit-input:focus {
    border-color: var(--input-focus-ring);
}
