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

:root {
    --primary: #2563EB;
    --primary-light: #60A5FA;
    --bg-page: #F0F4FF;
    --bg-card: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #6B7280;
    --border: #DBEAFE;
    --green: #16A34A;
    --green-bg: #DCFCE7;
    --amber: #B45309;
    --amber-bg: #FEF3C7;
    --red: #DC2626;
    --red-bg: #FEE2E2;
    --blue-badge-bg: #EFF6FF;
    --blue-badge-color: #2563EB;
}

body {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 1rem;
    background-color: var(--bg-page);
    font-family: 'Ubuntu', sans-serif;
}

main {
    width: 100%;
    max-width: 440px;
}

.page-header {
    margin-bottom: 1.25rem;
    padding-left: 4px;
}

.page-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.page-header p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/*  CARD  */
article {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: 12px;
    padding: 1.25rem;
    width: 100%;
    box-shadow:
        0 1px 2px rgba(37, 99, 235, 0.04),
        0 4px 8px rgba(37, 99, 235, 0.06),
        0 8px 16px rgba(37, 99, 235, 0.06);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

article:hover {
    transform: translateY(-4px);
    box-shadow:
        0 2px 4px rgba(37, 99, 235, 0.06),
        0 8px 16px rgba(37, 99, 235, 0.1),
        0 16px 32px rgba(37, 99, 235, 0.1);
}

/* Done state: muted overall */
article.is-done {
    opacity: 0.8;
}

/*  CARD TOP ROW  */
.card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 8px;
    flex-wrap: wrap;
}

/* Priority badge */
[data-testid="test-todo-priority"] {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--red-bg);
    color: var(--red);
}

/* Status badge (display only) */
[data-testid="test-todo-status"] {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--blue-badge-bg);
    color: var(--blue-badge-color);
}

/* Tags + status control: same row, tags left, dropdown right */
.tags-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 8px;
}

/* Tags list inside the row — no bottom margin, row handles spacing */
.tags-status-row [data-testid="test-todo-tags"] {
    margin-bottom: 0;
}

/* Status control dropdown — styled like Delete button, square-ish border */
[data-testid="test-todo-status-control"] {
    font-family: 'Ubuntu', sans-serif;
    font-size: 12px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: 8px;
    border: 0.5px solid var(--border);
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s ease;
    appearance: auto;
}

[data-testid="test-todo-status-control"]:hover {
    border-color: var(--primary-light);
}

[data-testid="test-todo-status-control"]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Screen-reader only label */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/*  PRIORITY INDICATOR  */
[data-testid="test-todo-priority-indicator"] {
    width: 100%;
    height: 3px;
    border-radius: 999px;
    background: var(--red);
    /* default High; JS overrides */
    margin-bottom: 12px;
    transition: background 0.3s ease;
}

/*  ICONS  */
[data-testid="test-todo-status"] svg,
[data-testid="test-todo-priority"] svg {
    width: 12px;
    height: 12px;
}

.icon {
    display: inline-flex;
    align-items: center;
}

.emoji-fallback {
    font-size: 12px;
}

/*  TITLE ROW  */
.title-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
    position: relative;
}

.title-row label {
    cursor: pointer;
    flex: 1;
}

.title-row h2 {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
    transition: color 0.2s ease, text-decoration 0.2s ease;
}

.title-row input[type="checkbox"] {
    margin-top: 4px;
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: #16A34A;
    position: relative;
    z-index: 1;
}

/*  DESCRIPTION / COLLAPSIBLE  */
.collapsible-section {
    margin: 0 0 0 26px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.collapsible-section p[data-testid="test-todo-description"] {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 10px;
}

/* Collapsed state: clip to ~3 lines */
.collapsible-section.is-collapsible.is-collapsed {
    max-height: 4.8em;
    /* ~3 lines at 1.6 line-height */
    -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
}

/* Expanded state: let it breathe */
.collapsible-section.is-collapsible:not(.is-collapsed) {
    max-height: 600px;
    -webkit-mask-image: none;
    mask-image: none;
}

/* Non-collapsible: just show normally */
.collapsible-section:not(.is-collapsible) {
    max-height: none;
}

/* Expand toggle button */
.expand-toggle {
    display: none;
    /* JS shows it when needed */
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--primary);
    font-size: 11px;
    font-family: 'Ubuntu', sans-serif;
    font-weight: 500;
    cursor: pointer;
    margin: 0 0 10px 26px;
    padding: 0;
    transition: opacity 0.2s ease;
}

.expand-toggle svg {
    width: 13px;
    height: 13px;
    transition: transform 0.2s ease;
}

.expand-toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

.expand-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 3px;
}

/*  OVERDUE INDICATOR  */
[data-testid="test-todo-overdue-indicator"] {
    display: none;
    /* shown via JS */
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    color: var(--red);
    background: var(--red-bg);
    padding: 3px 10px;
    border-radius: 999px;
    width: fit-content;
    margin: 0 0 10px 26px;
    animation: fadeIn 0.2s ease;
}

[data-testid="test-todo-overdue-indicator"] svg {
    width: 12px;
    height: 12px;
}

/*  DIVIDER  */
.divider {
    border: none;
    border-top: 0.5px solid var(--border);
    margin: 14px 0;
}

/*  DUE DATE  */
[data-testid="test-todo-due-date"] {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

[data-testid="test-todo-due-date"] svg {
    width: 13px;
    height: 13px;
}

/*  EDIT FORM  */
.edit-form {
    background: var(--bg-page);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: fadeIn 0.2s ease;
}

.edit-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.edit-field label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.edit-field input[type="text"],
.edit-field input[type="date"],
.edit-field textarea,
.edit-field select {
    font-family: 'Ubuntu', sans-serif;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    outline: none;
    transition: border-color 0.2s ease;
    resize: none;
}

.edit-field textarea {
    resize: vertical;
    min-height: 72px;
}

.edit-field select {
    cursor: pointer;
}

.edit-field input:focus,
.edit-field textarea:focus,
.edit-field select:focus {
    border-color: var(--primary);
}

.edit-form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 4px;
}

[data-testid="test-todo-save-button"] {
    font-family: 'Ubuntu', sans-serif;
    font-size: 12px;
    padding: 5px 16px;
    border-radius: 8px;
    border: none;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

[data-testid="test-todo-cancel-button"] {
    font-family: 'Ubuntu', sans-serif;
    font-size: 12px;
    padding: 5px 16px;
    border-radius: 8px;
    border: 0.5px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: opacity 0.2s ease;
}

/*  TAGS  */
[data-testid="test-todo-tags"] {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

[data-testid="test-todo-tags"] li {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--bg-page);
    color: var(--text-secondary);
    border: 0.5px solid var(--border);
}

/*  CARD ACTIONS  */
.card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 0.5px solid var(--border);
    padding-top: 12px;
}

.action-buttons {
    display: flex;
    gap: 4px;
}

[data-testid="test-todo-time-remaining"] {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 10px;
    font-weight: 500;
    font-style: italic;
    color: var(--green);
    padding-top: 6px;
}

[data-testid="test-todo-time-remaining"] svg {
    width: 14px;
    height: 14px;
}

[data-testid="test-todo-edit-button"] {
    font-size: 12px;
    padding: 5px 14px;
    border-radius: 8px;
    border: 0.5px solid var(--border);
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Ubuntu', sans-serif;
}

[data-testid="test-todo-edit-button"]:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

[data-testid="test-todo-delete-button"] {
    font-size: 12px;
    padding: 5px 14px;
    border-radius: 8px;
    border: 0.5px solid #FECACA;
    background: transparent;
    color: var(--red);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Ubuntu', sans-serif;
}

/*  DELETED STATE  */
.deleted-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 8px;
}

.deleted-message p {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.deleted-message span {
    font-size: 12px;
    color: var(--text-secondary);
}

/*  FOCUS & HOVER  */
button:hover {
    opacity: 0.8;
}

button:focus-visible,
input[type="checkbox"]:focus-visible,
select:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/*  ANIMATIONS  */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

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

@keyframes ripple {
    to {
        width: 40px;
        height: 40px;
        opacity: 0;
    }
}

/*  RESPONSIVE  */
@media (min-width: 480px) {
    main {
        max-width: 460px;
    }
}

@media (min-width: 768px) {
    body {
        align-items: center;
        padding: 3rem 2rem;
    }

    main {
        max-width: 500px;
    }

    article {
        padding: 1.75rem;
    }

    .title-row h2 {
        font-size: 18px;
    }

    .collapsible-section p[data-testid="test-todo-description"] {
        font-size: 14px;
    }

    .card-actions {
        margin-top: 16px;
        gap: 12px;
    }

    [data-testid="test-todo-time-remaining"] {
        font-size: 12px;
    }

    /* On tablet+: priority & status can sit side by side */
    .card-top {
        flex-wrap: nowrap;
    }
}

@media (min-width: 1200px) {
    main {
        max-width: 540px;
    }

    article {
        padding: 2rem;
    }
}

/*  MOBILE: Edit form stacks vertically */
@media (max-width: 480px) {
    .edit-form-actions {
        flex-direction: column;
    }

    [data-testid="test-todo-save-button"],
    [data-testid="test-todo-cancel-button"] {
        width: 100%;
        text-align: center;
    }

    .card-top {
        gap: 6px;
    }
}