* {
    box-sizing: border-box;
}


:root {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #1f2933;
    background: #f3f4f6;
}


body {
    margin: 0;
    min-height: 100vh;
    background: #f3f4f6;
}


button,
input {
    font: inherit;
}


.app {
    width: min(100%, 720px);
    margin: 0 auto;
    padding: 20px 14px 40px;
}


.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}


h1 {
    margin: 0;
    font-size: clamp(1.65rem, 7vw, 2.2rem);
    line-height: 1.1;
}


.subtitle {
    margin: 6px 0 0;
    color: #6b7280;
}


.reset-button {
    flex: 0 0 auto;
    min-height: 46px;
    padding: 10px 16px;
    border: 0;
    border-radius: 12px;
    background: #dc2626;
    color: white;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
}

.reset-button:active {
    transform: scale(0.97);
}

.reset-button.confirming {
    background: #b45309;
}

.categories {
    display: grid;
    gap: 12px;
}

.category-card {
    overflow: hidden;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: white;
    box-shadow: 0 2px 8px rgb(0 0 0 / 0.05);
}

.category-header {
    width: 100%;
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 16px;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
}

.category-heading {
    min-width: 0;
}

.category-title {
    display: block;
    font-size: 1.05rem;
    font-weight: 750;
}

.category-progress {
    display: block;
    margin-top: 3px;
    color: #6b7280;
    font-size: 0.85rem;
}

.category-card.completed .category-title {
    color: #15803d;
}

.category-card.completed .category-progress {
    color: #16a34a;
}

.category-arrow {
    flex: 0 0 auto;
    font-size: 1.1rem;
    transition: transform 0.18s ease;
}

.category-card.collapsed .category-arrow {
    transform: rotate(-90deg);
}

.category-items {
    border-top: 1px solid #f0f1f3;
}

.category-card.collapsed .category-items,
.category-card.collapsed .category-controls {
    display: none;
}

.item-row {
    display: flex;
    align-items: center;
    gap: 13px;
    min-height: 54px;
    padding: 10px 16px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.item-row:last-child {
    border-bottom: 0;
}

.item-checkbox {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    margin: 0;
    accent-color: #16a34a;
    cursor: pointer;
}

.item-text {
    line-height: 1.3;
}

.item-checkbox:checked + .item-text {
    color: #6b7280;
    text-decoration: line-through;
}

.status-message {
    margin: 24px 0;
    text-align: center;
    color: #6b7280;
}

.error-message {
    color: #b91c1c;
}

[hidden] {
    display: none !important;
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.secondary-button {
    min-height: 46px;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    background: white;
    color: #1f2937;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
}

.secondary-button:active,
.crud-button:active {
    transform: scale(0.97);
}

.category-controls {
    display: flex;
    gap: 8px;
    padding: 8px 14px 10px;
    border-top: 1px solid #f0f1f3;
    background: #fafafa;
    flex-wrap: wrap;
}

.item-add-editor {
    flex: 1 0 100%;
    min-width: 0;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.item-add-textarea {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 96px;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font: inherit;
    resize: vertical;
}

.crud-button {
    min-height: 38px;
    padding: 7px 11px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: white;
    color: #374151;
    font-size: 0.85rem;
    font-weight: 650;
    cursor: pointer;
    touch-action: manipulation;
}

.crud-button.danger {
    color: #b91c1c;
    border-color: #fecaca;
    background: #fff7f7;
}

.item-main {
    display: flex;
    align-items: center;
    gap: 13px;
    flex: 1 1 auto;
    min-width: 0;
    cursor: pointer;
}

.item-actions {
    display: flex;
    gap: 5px;
    margin-left: auto;
    flex: 0 0 auto;
}

.item-action-button {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: white;
    color: #4b5563;
    font-size: 1rem;
    cursor: pointer;
    touch-action: manipulation;
}

.item-action-button.danger {
    color: #b91c1c;
}

@media (max-width: 480px) {
    .app {
        padding: 16px 12px 32px;
    }

    .app-header {
        align-items: flex-start;
    }

    .reset-button {
        min-width: 92px;
        padding-inline: 12px;
    }

    .category-header,
    .item-row {
        padding-left: 14px;
        padding-right: 14px;
    }
}