:root {
    --bg-color: #f6f1e8;
    --ink-color: #1a1a1a;
    --accent-color: #ff6b6b;
    --warning-color: #ff9f43;
    --font-main: 'Comic Sans MS', 'Chalkboard SE', 'Marker Felt', sans-serif;
    --border-width: 3px;
    --safe-bottom: env(safe-area-inset-bottom, 20px);
}

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

body {
    background-color: var(--bg-color);
    color: var(--ink-color);
    font-family: var(--font-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: clamp(10px, 4vw, 40px);
}

.app-shell {
    width: min(920px, 92vw);
    background: white;
    border: var(--border-width) solid var(--ink-color);
    box-shadow: 8px 8px 0px var(--ink-color);
    display: flex;
    flex-direction: column;
    min-height: 80vh;
    max-height: 90vh;
    position: relative;
    transform: rotate(-0.3deg);
}

@media (max-width: 600px) {
    body {
        padding: 0;
    }
    .app-shell {
        width: 100vw;
        min-height: 100vh;
        max-height: 100vh;
        border: none;
        box-shadow: none;
        transform: none;
    }
}

header {
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    border-bottom: 2px dashed var(--ink-color);
}

.logo {
    font-size: clamp(1.5rem, 5vw, 2.2rem);
}

.date-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-btn, .today-btn {
    background: none;
    border: 2px solid var(--ink-color);
    font-family: inherit;
    cursor: pointer;
    padding: 5px 10px;
    font-weight: bold;
}

.date-picker-trigger {
    position: relative;
    font-size: 1.1rem;
    cursor: pointer;
}

#date-picker-input {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

#list-area {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
}

#task-list {
    list-style: none;
}

.task-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    gap: 12px;
}

.checkbox-box {
    width: 28px;
    height: 28px;
    border: 3px solid var(--ink-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.task-item.completed .checkbox-box::after {
    content: 'X';
    font-weight: 900;
    font-size: 22px;
}

.task-text {
    flex-grow: 1;
    font-size: 1.1rem;
    position: relative;
}

.task-item.completed .task-text {
    opacity: 0.5;
}

.task-item.completed .task-text::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 2px;
    background: var(--ink-color);
    transform: rotate(-1deg);
}

.task-deadline {
    font-size: 0.8rem;
    padding: 2px 6px;
    border: 1px solid #ccc;
}

.task-deadline.due-soon { border-color: var(--warning-color); color: var(--warning-color); }
.task-deadline.overdue { border-color: var(--accent-color); color: var(--accent-color); font-weight: bold; }

.delete-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.3;
    transition: opacity 0.2s;
}

@media (min-width: 601px) {
    .task-item .delete-btn { opacity: 0; }
    .task-item:hover .delete-btn { opacity: 1; }
}

@media (max-width: 600px) {
    .task-item .delete-btn { opacity: 0.6; }
}

.add-section {
    padding: 20px;
    padding-bottom: var(--safe-bottom);
    background: #fff;
    border-top: 2px dashed var(--ink-color);
}

.input-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

#task-input {
    flex-grow: 1;
    min-width: 200px;
    border: none;
    border-bottom: 2px solid var(--ink-color);
    font-family: inherit;
    font-size: 1.1rem;
    padding: 8px;
}

#deadline-input {
    border: 1px solid var(--ink-color);
    font-family: inherit;
    padding: 5px;
}

#add-btn {
    background: var(--ink-color);
    color: white;
    border: none;
    padding: 8px 20px;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 4px 4px 0px #666;
}

footer {
    padding: 10px 20px;
    font-size: 0.75rem;
    text-align: center;
    background: #fafafa;
}

.empty-state {
    text-align: center;
    padding: 50px 0;
    font-style: italic;
    opacity: 0.6;
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink-color);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    z-index: 1000;
}
