body {
    margin: 0;
    background: #0b0c10;
    color: #e9eef3;
    font-family: system-ui, sans-serif;
    display: flex;
    justify-content: center;
}

.wrap {
    text-align: center;
    padding: 16px;
    max-width: 1200px;
}

.sub {
    color: #9aa4b2;
    margin-top: -6px;
}

/* Canvas loading overlay */
#canvas-container {
    position: relative;
    display: flex;
    justify-content: center;
    margin: 12px auto;
    width: 90vw;
    max-width: 280px;
}

canvas {
    display: block;
    background: #fff;
    border: 2px solid #23283b;
    border-radius: 8px;
    touch-action: none;
    width: 100%;
    height: auto;
}

#canvas-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    z-index: 10;
    pointer-events: none;
}

#canvas-loading-overlay.hidden {
    display: none;
}

.buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
}

button,
.upload-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 999px;
    background: #1b1f2e;
    color: #e9eef3;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s ease;
}

button:hover,
.upload-btn:hover {
    background: #252a3d;
}

#classify {
    background: #2e5090;
    font-weight: 700;
}

#classify:hover {
    background: #3a63b0;
}

.results {
    display: grid;
    /* Stack by default on mobile (1 column) */
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 20px;
}

/* On screens 768px or wider, switch to 3 columns */
@media (min-width: 768px) {
    .results {
        grid-template-columns: repeat(3, 1fr);
    }
}

.model-card {
    background: #11131a;
    border: 1px solid #23283b;
    border-radius: 12px;
    padding: 12px;
    text-align: left;
}

.model-card h2 {
    margin-top: 0;
    text-align: center;
}

.model-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.model-card li {
    border-bottom: 1px solid #23283b;
    padding: 4px 0;
}

.info-note {
    font-size: 0.85em;
    color: #9aa4b2;
    font-style: italic;
    margin: 8px 0;
    padding: 8px;
    background: #1a1c24;
    border-radius: 6px;
    border-left: 3px solid #3a63b0;
}

#train-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}

#train-controls input {
    padding: 6px;
    border-radius: 6px;
    border: 1px solid #2e344e;
    background: #11131a;
    color: #fff;
}

#train-controls button {
    background: #2e3450;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 6px;
    cursor: pointer;
}

#train-controls button:hover {
    background: #3a4468;
}

.custom-upload-btn {
    display: inline-block;
    padding: 6px 12px;
    margin-bottom: 8px;
    border: none;
    border-radius: 8px;
    background: #2e3450;
    color: #fff;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9em;
    text-align: center;
    transition: background 0.2s ease;
}

.custom-upload-btn:hover {
    background: #3a4468;
}

#train-progress {
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.2) inset;
}

.roast-box {
    margin-top: 12px;
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 8px;
    background: #11131a;
    color: #ff8e8e;
    font-weight: 600;
    text-align: center;
    min-height: 40px;
    transition: background 0.3s ease;
}

/* --- Combined Image Styles --- */
.combined-image {
    margin: 16px auto;
    max-width: 512px;
    min-height: 50px;
    border-radius: 12px;
    overflow: hidden;
    background: #0b0c10;
    position: relative;
}

.combined-image img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
    border: 2px solid #23283b;
}

.combined-image.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    color: #9aa4b2;
    font-size: 0.9em;
    border: 2px dashed #23283b;
}

.combined-image.loading::after {
    content: '🎨 Generating AI masterpiece...';
}

/* --- New Gallery Styles --- */
.gallery-container {
    margin-top: 30px;
    text-align: left;
    border-top: 2px solid #23283b;
    padding-top: 16px;
}

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

.gallery-header h2 {
    margin: 0;
}

.small-btn {
    padding: 4px 10px;
    font-size: 0.8em;
    background: #3a2e50;
    color: #e9eef3;
}

.small-btn:hover {
    background: #4a3a68;
}

.gallery-grid {
    display: grid;
    /* Adjust minmax to control the size of gallery items */
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}

.gallery-item {
    background: #11131a;
    border: 1px solid #23283b;
    border-radius: 8px;
    overflow: hidden;
    font-size: 0.8em;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    background: white;
    /* In case of transparent PNGs */
}

.gallery-stats {
    padding: 8px;
}

.gallery-stats strong {
    color: #fff;
    display: block;
    margin-bottom: 4px;
    /* Truncate long labels */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-stats ul {
    list-style: none;
    margin: 0;
    padding: 0;
    color: #9aa4b2;
    font-size: 0.9em;
}
