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

body {
    font-family: system-ui, sans-serif;
    background: #f5f5f5;
    color: #222;
    min-height: 100vh;
}

header {
    background: #2c7a4b;
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

header h1 {
    font-size: 1.4rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
}

.logout-link {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
}

.logout-link:hover {
    color: white;
    text-decoration: underline;
}

main {
    max-width: 600px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* Add form */

.add-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.add-form input[type="text"] {
    flex: 1;
    padding: 0.6rem 0.8rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
}

.add-form input[type="text"]:focus {
    outline: none;
    border-color: #2c7a4b;
    box-shadow: 0 0 0 2px rgba(44, 122, 75, 0.2);
}

.add-form button {
    padding: 0.6rem 1.2rem;
    background: #2c7a4b;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
}

.add-form button:hover {
    background: #235f3c;
}

/* Item list */

#item-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.item:not(.checked) {
    order: 0;
}

.item.checked {
    order: 2;
}

.item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: white;
    padding: 0.7rem 1rem;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.item input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    cursor: pointer;
    accent-color: #2c7a4b;
    flex-shrink: 0;
}

.item-text {
    flex: 1;
    font-size: 1rem;
}

.item.checked .item-text {
    text-decoration: line-through;
    color: #999;
}

.delete-btn {
    background: none;
    border: none;
    color: #bbb;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    line-height: 1;
}

.delete-btn:hover {
    color: #e53e3e;
    background: #fff0f0;
}

/* Checked section divider */

.checked-section-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.75rem 0 0.25rem;
    border-top: 1px solid #e8e8e8;
    margin-top: 0.25rem;
    order: 1;
}

/* Login page */

.login-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 2rem;
    margin-top: 3rem;
}

.login-title {
    font-size: 1.4rem;
    color: #2c7a4b;
    margin-bottom: 1.5rem;
    text-align: center;
}

.login-error {
    background: #fff0f0;
    border: 1px solid #fca5a5;
    color: #b91c1c;
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.login-form label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #444;
    margin-top: 0.5rem;
}

.login-form input[type="text"],
.login-form input[type="password"] {
    padding: 0.6rem 0.8rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
}

.login-form input[type="text"]:focus,
.login-form input[type="password"]:focus {
    outline: none;
    border-color: #2c7a4b;
    box-shadow: 0 0 0 2px rgba(44, 122, 75, 0.2);
}

.login-form button[type="submit"] {
    margin-top: 1rem;
    padding: 0.7rem;
    background: #2c7a4b;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
}

.login-form button[type="submit"]:hover {
    background: #235f3c;
}

/* Header back nav */

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.back-link {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.9rem;
}

.back-link:hover {
    color: white;
    text-decoration: underline;
}

/* Lists page */

#lists-container {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    padding: 0.8rem 1rem;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.list-row-link {
    flex: 1;
    font-size: 1rem;
    color: #222;
    text-decoration: none;
    font-weight: 500;
}

.list-row-link:hover {
    color: #2c7a4b;
}

.list-row-date {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: #aaa;
    margin-top: 0.1rem;
}

.list-row-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.rename-btn {
    background: none;
    border: none;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    line-height: 1;
    color: #bbb;
}

.rename-btn:hover {
    background: #f0f0f0;
}

.rename-form {
    flex: 1;
    margin-right: 0.5rem;
}

.rename-form input[type="text"] {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid #2c7a4b;
    border-radius: 6px;
    font-size: 1rem;
    box-shadow: 0 0 0 2px rgba(44, 122, 75, 0.2);
    outline: none;
}

/* Mode segmented switch */

.mode-switch {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 20px;
    padding: 3px;
    gap: 2px;
}

.mode-option {
    background: transparent;
    border: none;
    border-radius: 16px;
    padding: 0.2rem 0.55rem;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s;
}

.mode-option.active {
    background: white;
}

/* Action mode search */

.action-search-wrapper {
    display: none;
    margin-bottom: 1.5rem;
}

body.action-mode .action-search-wrapper {
    display: block;
}

body.action-mode .add-form {
    display: none;
}

.action-search-input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
}

.action-search-input:focus {
    outline: none;
    border-color: #2c7a4b;
    box-shadow: 0 0 0 2px rgba(44, 122, 75, 0.2);
}

body.action-mode .delete-btn {
    display: none;
}

body.action-mode #item-list .item.checked {
    display: none;
}

body.action-mode.show-checked #item-list .item.checked {
    display: flex;
}

body.action-mode #item-list .checked-section-header {
    display: none;
}

body.action-mode.show-checked #item-list .checked-section-header {
    display: block;
}

/* Checked summary button */

.checked-summary {
    display: none;
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.5rem 1rem;
    background: none;
    border: 1px dashed #ccc;
    border-radius: 6px;
    color: #999;
    font-size: 0.85rem;
    cursor: pointer;
    text-align: center;
}

.checked-summary:hover {
    border-color: #aaa;
    color: #666;
}

/* Item rename button */

.rename-item-btn {
    background: none;
    border: none;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    line-height: 1;
}

body.action-mode .rename-item-btn {
    display: none;
}

body.action-mode #item-list .item:not(.checked) {
    cursor: pointer;
}

@keyframes tap-flash {
    0%   { background: #c6e8d4; }
    100% { background: white; }
}

.item.tapped {
    animation: tap-flash 0.3s ease-out;
}

/* Inline item rename input */

.item-rename-input {
    flex: 1;
    font-size: 1rem;
    font-family: inherit;
    border: none;
    border-bottom: 1px solid #2c7a4b;
    outline: none;
    background: transparent;
    padding: 0;
    color: inherit;
}

/* Empty state */

.empty-state {
    text-align: center;
    color: #999;
    padding: 2rem;
    font-size: 0.95rem;
}
