:root {
    --bg-color: #f9f9f9;
    --card-bg: #ffffff;
    --text-color: #333333;
    --accent-color: #007bff;
    --border-color: #eeeeee;
    --danger-color: #ff4d4d;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.container {
    background: var(--card-bg);
    width: 100%;
    max-width: 600px;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 1rem;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    outline: none;
    flex-grow: 1;
    word-break: break-word;
    padding-right: 1rem;
}

h1:empty::before {
    content: "Untitled Checklist";
    color: #999;
}

.actions button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
    opacity: 0.6;
    transition: opacity 0.2s, color 0.2s;
    padding: 0.5rem;
    border-radius: 4px;
}

.actions button:hover {
    opacity: 1;
    color: var(--accent-color);
    background-color: #f0f7ff;
}

main {
    margin-bottom: 2rem;
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.item, .heading {
    display: flex;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    gap: 0.75rem;
}

.item:last-child, .heading:last-child {
    border-bottom: none;
}

.heading {
    margin-top: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.heading-text {
    flex-grow: 1;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
    word-break: break-word;
    outline: none;
}

.item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--accent-color);
}

.item-text {
    flex-grow: 1;
    font-size: 1rem;
    transition: color 0.2s, text-decoration 0.2s;
    word-break: break-word;
    outline: none;
}

.item.completed .item-text {
    color: #888;
    text-decoration: line-through;
}

.delete-btn {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    padding: 0.25rem;
}

.item:hover .delete-btn, .heading:hover .delete-btn {
    opacity: 0.8;
}

.delete-btn:hover {
    opacity: 1 !important;
    background-color: #fff0f0;
    border-radius: 4px;
}

.add-item {
    margin-top: 1.5rem;
}

.add-item input {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}

.add-item input:focus {
    border-color: var(--accent-color);
}

footer {
    text-align: center;
    font-size: 0.8rem;
    color: #999;
    margin-top: 2rem;
}

@media (max-width: 480px) {
    .container {
        padding: 1.5rem;
    }
}
