body {
    margin: 0 auto;
    padding: 10px;
    font-family: system-ui, -apple-system, sans-serif;
    line-height: 1.5;
    max-width: 1200px;
    background: #f5f5f5;
    box-sizing: border-box;
    min-height: 100vh;
    padding-bottom: env(safe-area-inset-bottom, 20px);
}

#product-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 10px;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 768px) {

    html,
    body {
        position: relative;
        height: 100%;
        margin: 0;
        padding: 0;
        overflow-x: hidden;
    }

    body {
        padding: 8px 8px 80px 8px;
    }

    #product-container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        padding: 8px;
        margin-bottom: 60px;
        width: 100%;
        box-sizing: border-box;
        padding-bottom: calc(env(safe-area-inset-bottom) + 32px);
    }
}

.product-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
    width: 100%;
    min-width: 0;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.product-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.preview-content {
    padding: 0.75rem;
}

.preview-content h3 {
    margin: 0 0 0.25rem;
    font-size: 0.9rem;
    line-height: 1.2;
}

.preview-description {
    font-size: 0.8em;
    color: #666;
    margin: 0;
    line-height: 1.3;
}

.preview-site {
    margin-top: 0.5rem;
    /* Reduced margin */
    padding-top: 0.5rem;
    /* Reduced padding */
}

/* Loading state styles */
.product-card-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    color: #666;
}

.product-link.loading {
    position: relative;
}

.product-link.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #3498db, transparent);
    animation: loading 1.5s infinite;
}

.loading-label {
    font-size: 0.7rem;
    color: #3498db;
    margin-left: 0.5rem;
}

@keyframes loading {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    #product-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 8px;
    }

    .product-card {
        min-height: 240px;
    }

    .preview-image {
        height: 160px;
    }

    .preview-content {
        height: 80px;
        padding: 0.4rem;
    }

    body {
        padding: 8px;
    }
}

.product-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    /* Reduced card height to ~2/3 of original (400px -> 267px) */
    min-height: 267px;
}

.product-card:hover {
    border-color: #ccc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.product-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.preview-image {
    width: 100%;
    /* Set image height to 2/3 of card height (178px of 267px total) */
    height: 178px;
    background: #f8f9fa;
    flex-shrink: 0;
    /* ensure cropping of horizontal overflow and enable absolute positioning of the img */
    position: relative;
    overflow: hidden;
}

.preview-image img {
    /* Make the image exactly the preview height so top & bottom are visible,
       let width scale automatically and be clipped horizontally by the container.
       Center the image horizontally. */
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    height: 100%;
    width: auto;
    display: block;
    box-sizing: border-box;
}

.preview-content {
    padding: 0.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    /* Ensure content area takes exactly 1/3 of card height */
    height: 89px;
}

.preview-content h3 {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: #1a1a1a;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.preview-description {
    font-size: 0.75rem;
    color: #666;
    margin: 0.15rem 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.25;
    flex: 1;
    max-height: 2.5em;
}

.preview-site {
    margin-top: 0.2rem;
    padding-top: 0.2rem;
    border-top: 1px solid #eee;
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #666;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}