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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 8px;
}

.header {
    padding: 20px 12px;
    margin-bottom: 20px;
    text-align: center;
}

.search-form {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
}

#searchQuery {
    flex: 2;
    min-width: 250px;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    background: white;
}

#siteFilter {
    flex: 1;
    min-width: 150px;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
}

#searchButton {
    padding: 12px 24px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

#searchButton:hover {
    background: #2980b9;
}

#searchButton:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

#searchQuery:focus, #siteFilter:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

#searchQuery:disabled, #siteFilter:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}



.loading {
    text-align: center;
    padding: 60px 0;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e1e8ed;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.results {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.engine-section {
    min-width: 0;
}

.engine-title {
    color: #2c3e50;
    margin: 0 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #ecf0f1;
    font-size: 18px;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.image-item {
    border-radius: 8px;
    overflow: hidden;
    background: #f8f9fa;
    transition: transform 0.2s;
    cursor: pointer;
    position: relative;
}

.image-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.image-item img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
    border-radius: 4px;
}

.image-size-overlay {
    position: absolute;
    bottom: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 4px;
    font-size: 10px;
    font-family: monospace;
    font-weight: 500;
    white-space: nowrap;
}

.image-domain-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 4px;
    font-size: 10px;
    opacity: 0.9;
    white-space: nowrap;
}

.error {
    text-align: center;
    padding: 60px 0;
    color: #e74c3c;
}

.load-more {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

#loadMoreBtn {
    padding: 12px 32px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

#loadMoreBtn:hover {
    background: #219a52;
}

#loadMoreBtn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

@media (max-width: 1024px) and (min-width: 769px) {
    .results {
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .search-form {
        flex-direction: column;
        max-width: 400px;
        gap: 8px;
    }
    
    #searchQuery, #siteFilter {
        min-width: unset;
    }
    
    .results {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .image-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 8px;
    }
    
    .image-item img {
        height: 120px;
    }
}