:root {
    color-scheme: dark;
    --page-bg: #191920;
    --bg-color: #1f1f28;
    --panel-bg: #2a2a37;
    --text-color: #dcd7ba;
    --muted-text: #c8c093;
    --accent-color: #c4b28a;
    --secondary-color: #8ea49e;
    --red-color: #c4746e;
    --border-color: color-mix(in srgb, var(--accent-color) 18%, transparent);
    --frame-border: color-mix(in srgb, var(--accent-color) 40%, transparent);
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Base */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 32px 16px;
    background: var(--page-bg);
    color: var(--text-color);
    font-family: var(--font-mono);
    line-height: 1.6;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: clamp(20px, 4vw, 40px);
    background: var(--bg-color);
    border: 1px solid var(--border-color);
}

/* Hero */
header {
    margin: 8px 0 32px;
}

@keyframes hero-in {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

header h1 {
    margin: 0;
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 600;
    letter-spacing: -0.05em;
    animation: hero-in 700ms 120ms ease-out both;
}

#dot {
    color: var(--red-color);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

button, input {
    font: inherit;
    border-radius: 0;
}

button {
    cursor: pointer;
    transition: background-color 0.1s ease, color 0.1s ease, border-color 0.1s ease;
}

/* Task form */
#todo-form {
    display: flex;
    gap: 12px;
    margin: 0 0 32px;
}

#todo-input {
    flex: 1;
    min-width: 0;
    padding: 0.65rem 1rem;
    background: var(--panel-bg);
    color: var(--text-color);
    border: 1px solid var(--frame-border);
}

#todo-input::placeholder {
    color: var(--muted-text);
    opacity: 0.75;
}

#todo-form button {
    align-self: center;
    flex-shrink: 0;
    padding: 0.35rem 0.75rem;
    background: transparent;
    color: var(--secondary-color);
    border: 1px solid color-mix(in srgb, var(--secondary-color) 55%, transparent);
    font-size: 0.85rem;
    font-weight: 500;
}

#todo-form button:hover {
    background: color-mix(in srgb, var(--secondary-color) 10%, transparent);
    border-color: var(--secondary-color);
}

#todo-form button:active {
    background: color-mix(in srgb, var(--secondary-color) 18%, transparent);
}

/* Task panel and filters */
.tasks-panel {
    position: relative;
    min-width: 0;
    padding: 20px 12px 12px;
    border: 1px solid var(--frame-border);
}

.panel-label {
    position: absolute;
    top: 0;
    left: 16px;
    transform: translateY(-50%);
    margin: 0;
    padding: 0 8px;
    background: var(--bg-color);
    color: var(--red-color);
    font-size: 0.85rem;
    font-weight: 500;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

#todo-counter {
    margin: 0;
    color: var(--muted-text);
    font-size: 0.8rem;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.filters button {
    padding: 4px 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted-text);
    font-size: 0.8rem;
}

.filters button:hover {
    color: var(--red-color);
}

.filters button.active {
    color: var(--red-color);
    border-bottom-color: var(--red-color);
}

/* Task list */
#todo-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

#todo-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 8px;
    border-top: 1px solid var(--border-color);
}

#todo-list li:hover {
    background: var(--panel-bg);
}

#todo-list li > span {
    min-width: 0;
    overflow-wrap: anywhere;
}

#todo-list li.completed > span {
    text-decoration: line-through;
    opacity: 0.55;
}

#todo-list li > div {
    display: flex;
    flex-shrink: 0;
    gap: 8px;
}

#todo-list button {
    padding: 4px 6px;
    border: 1px solid transparent;
    background: transparent;
    font-size: 0.8rem;
}

#todo-list button[data-action="toggle"] {
    color: var(--secondary-color);
}

#todo-list button[data-action="delete"] {
    color: var(--red-color);
}

#todo-list button:hover {
    border-color: currentColor;
}

button:focus-visible, input:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 3px;
}

/* Responsive layout */
@media (max-width: 560px) {
    body {
        padding: 16px 8px;
    }

    .container {
        padding: 20px 12px;
    }

    .toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    #todo-form {
        gap: 8px;
    }

    #todo-input {
        padding-inline: 10px;
    }

    #todo-form button {
        padding-inline: 10px;
    }

    #todo-list li {
        flex-wrap: wrap;
    }
}

@media (prefers-reduced-motion: reduce) {
    button {
        transition: none;
    }

    header h1 {
        animation: none;
    }
}
