:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338CA;
    --bg-gradient: linear-gradient(135deg, #EEEEEE 0%, #EEEEEE 100%);
    --surface-color: rgba(255, 255, 255, 0.7);
    --surface-border: rgba(255, 255, 255, 0.5);
    --text-active: #000000;
    --text-inactive: #9CA3AF;
    --danger-color: #EF4444;
    --success-color: #60A5FA; /* Light Blue */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --border-radius-lg: 16px;
    --border-radius-full: 9999px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: #1F2937;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    transition: opacity 0.3s ease;
}

.hidden {
    display: none !important;
}

/* Glassmorphism utility */
.glass {
    background: var(--surface-color);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--surface-border);
}

/* Login Screen */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 32px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-card h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-active);
}

.login-card p {
    color: #6B7280;
    margin-bottom: 24px;
    font-size: 14px;
}

.login-card input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #D1D5DB;
    font-size: 16px;
    margin-bottom: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.login-card input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.login-card button {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: none;
    background: var(--primary-color);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.login-card button:active {
    transform: scale(0.98);
}

.error-msg {
    color: var(--danger-color);
    font-size: 14px;
    margin-top: 12px;
    min-height: 20px;
}

header.header-row {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.header-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.category-scroll {
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.category-scroll::-webkit-scrollbar {
    display: none;
}

.category-chips {
    display: flex;
    gap: 10px;
    align-items: center;
    width: max-content;
    padding: 4px 0;
}

.chip {
    padding: 8px 16px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.6);
    color: var(--text-inactive);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    border: 1px solid rgba(0, 0, 0, 0.05);
    user-select: none;
}

.chip:hover {
    background: rgba(255, 255, 255, 0.9);
}

.chip.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.chip.add-btn {
    background: transparent;
    border: 1px dashed #9CA3AF;
    color: #4B5563;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chip.add-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.danger-icon {
    color: var(--danger-color) !important;
}

.icon-btn {
    background: none;
    border: none;
    color: #4B5563;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.icon-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Todo List */
#todo-list {
    padding: 20px;
    padding-bottom: 100px; /* space for fab */
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.todo-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, background-color 0.3s;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.todo-item:active {
    transform: scale(0.98);
}

.todo-item .todo-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-right: 16px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.todo-text {
    font-size: 16px;
    line-height: 1.4;
    word-break: break-word;
    transition: color 0.3s, font-weight 0.3s;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Active Item specific styles per requirements */
.todo-item.active .todo-text {
    font-weight: 700;
    color: var(--text-active);
}

/* Inactive Item specific styles per requirements */
.todo-item.inactive {
    background: rgba(243, 244, 246, 0.7);
}

.todo-item.inactive .todo-text {
    font-weight: 400;
    color: var(--text-inactive);
    text-decoration: line-through;
}

.todo-meta {
    font-size: 12px;
    color: #6B7280;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.repeating-badge {
    background: #E0E7FF;
    color: #4338CA;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

/* iOS Switch */
.ios-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    flex-shrink: 0;
}

.ios-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
    background-color: var(--success-color);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--success-color);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Inactive toggle styling */
.todo-item.inactive .slider {
    background-color: #E5E7EB;
}
.todo-item.inactive input:checked + .slider {
    background-color: #9CA3AF;
}

/* FAB */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    transition: transform 0.2s, background-color 0.2s;
    box-shadow: var(--shadow-lg);
}

.fab:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.fab:active {
    transform: scale(0.95);
}

/* Overlay */
#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 90;
    opacity: 1;
    transition: opacity 0.3s;
}

#overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Floating Form */
.glass-form {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    padding: 24px;
    z-index: 110;
    box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.1);
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.glass-form.hidden {
    transform: translateY(100%);
    display: block !important; /* override utility */
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.form-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.close-btn {
    font-size: 24px;
    padding: 0;
    width: 32px;
    height: 32px;
}

#new-todo-text {
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid #E5E7EB;
    font-size: 16px;
    margin-bottom: 16px;
    outline: none;
    background: #F9FAFB;
    transition: border-color 0.2s, background-color 0.2s;
}

#new-todo-text:focus {
    border-color: var(--primary-color);
    background: white;
}

.form-row {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    font-size: 15px;
    color: #374151;
}

.form-row.space-between {
    justify-content: space-between;
}

.primary-btn {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: none;
    background: var(--primary-color);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background-color 0.2s, transform 0.1s;
}

.primary-btn:active {
    transform: scale(0.98);
}

/* Modal */
.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    width: 90%;
    max-width: 340px;
    border-radius: 20px;
    padding: 24px;
    z-index: 120;
    text-align: center;
    box-shadow: var(--shadow-lg);
    opacity: 1;
    transition: opacity 0.3s, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.hidden {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
    pointer-events: none;
    display: block !important;
}

.modal h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-active);
}

.modal p {
    font-size: 14px;
    color: #6B7280;
    margin-bottom: 24px;
}

.modal-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #D1D5DB;
    font-size: 16px;
    margin-bottom: 20px;
    outline: none;
    transition: border-color 0.2s;
    -webkit-user-select: text;
    user-select: text;
}

.modal input {
    -webkit-user-select: text;
    user-select: text;
}

@media (max-height: 600px) {
    .modal {
        top: 45%;
        max-height: 85vh;
        overflow-y: auto;
        padding: 18px 20px;
    }
}

.modal-input:focus {
    border-color: var(--primary-color);
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.modal-btn {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.modal-btn:active {
    transform: scale(0.95);
}

.modal-btn.cancel {
    background: #E5E7EB;
    color: #374151;
}

.modal-btn.danger {
    background: var(--danger-color);
    color: white;
}

/* Long Press Animation */
.todo-item.pressing {
    transform: scale(0.95);
    opacity: 0.8;
}

/* Custom Checkbox */
.checkbox-container {
    display: block;
    position: relative;
    padding-left: 32px;
    cursor: pointer;
    user-select: none;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: -2px;
    left: 0;
    height: 22px;
    width: 22px;
    background-color: #eee;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.checkbox-container:hover input ~ .checkmark {
    background-color: #ccc;
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--primary-color);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 8px;
    top: 4px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Stepper Component */
.stepper-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.9);
    padding: 3px 6px;
    border-radius: 10px;
    border: 1px solid #D1D5DB;
    transition: opacity 0.2s, border-color 0.2s;
}

.stepper-group.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.stepper-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid #D1D5DB;
    background: white;
    color: #374151;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s, transform 0.1s, border-color 0.15s;
}

.stepper-btn:hover {
    background-color: #F3F4F6;
    border-color: #9CA3AF;
}

.stepper-btn:active {
    transform: scale(0.92);
    background-color: #E5E7EB;
}

.stepper-input {
    width: 46px;
    height: 28px;
    text-align: center;
    border: 1px solid transparent;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    color: #1F2937;
    outline: none;
    -moz-appearance: textfield;
}

.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.stepper-input:focus {
    background: white;
    border: 1px solid var(--primary-color);
    border-radius: 6px;
}

.stepper-unit {
    font-size: 12px;
    font-weight: 500;
    color: #6B7280;
    padding-right: 4px;
    user-select: none;
}
