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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    color: #fff;
    -webkit-tap-highlight-color: transparent;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(90deg, #00d2ff, #3a7bd5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: #8892a6;
    font-size: 1.1rem;
}

main {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 30px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Upload Section */
.upload-section {
    margin-bottom: 20px;
}

#imageInput {
    display: none;
}

.upload-label {
    display: block;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-label:hover,
.upload-label:active {
    border-color: #3a7bd5;
    background: rgba(58, 123, 213, 0.1);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #8892a6;
}

.upload-content svg {
    opacity: 0.7;
}

.upload-hint {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Preview Grid for Multiple Images */
.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.preview-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.2);
}

.preview-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

.preview-item .image-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: #00d2ff;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 6px;
    text-align: center;
}

.preview-item .remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 59, 48, 0.9);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.preview-item .remove-btn:hover {
    background: #ff3b30;
}

/* Add More Button */
.add-more-btn {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    color: #8892a6;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 20px;
}

.add-more-btn:hover {
    border-color: #3a7bd5;
    color: #3a7bd5;
    background: rgba(58, 123, 213, 0.1);
}

/* Prompt Tip */
.prompt-tip {
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(58, 123, 213, 0.1);
    border-left: 3px solid #3a7bd5;
    border-radius: 0 8px 8px 0;
    font-size: 0.85rem;
    color: #8892a6;
}

.prompt-tip strong {
    color: #3a7bd5;
}

/* Prompt Section */
.prompt-section {
    margin-bottom: 20px;
}

.prompt-section label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
}

#promptInput {
    width: 100%;
    padding: 15px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 16px;
    min-height: 100px;
    resize: vertical;
    transition: border-color 0.3s;
}

#promptInput:focus {
    outline: none;
    border-color: #3a7bd5;
}

#promptInput::placeholder {
    color: #6b7280;
}

.example-prompts {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.example-prompts span {
    color: #8892a6;
    font-size: 0.9rem;
}

.example-btn {
    background: rgba(58, 123, 213, 0.2);
    border: 1px solid rgba(58, 123, 213, 0.5);
    color: #3a7bd5;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s;
}

.example-btn:hover,
.example-btn:active {
    background: rgba(58, 123, 213, 0.4);
}

/* Aspect Ratio Section */
.aspect-ratio-section {
    margin-bottom: 20px;
}

.aspect-ratio-section label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
}

#aspectRatio {
    width: 100%;
    padding: 14px 15px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: border-color 0.3s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238892a6' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 45px;
}

#aspectRatio:focus {
    outline: none;
    border-color: #3a7bd5;
}

#aspectRatio option {
    background: #1a1a2e;
    color: #fff;
    padding: 10px;
}

/* Submit Button */
.submit-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(90deg, #00d2ff, #3a7bd5);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    -webkit-tap-highlight-color: transparent;
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(58, 123, 213, 0.4);
}

.submit-btn:active:not(:disabled) {
    transform: translateY(0);
}

.submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.spinner {
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

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

/* Error Message */
.error-message {
    background: rgba(255, 59, 48, 0.2);
    border: 1px solid rgba(255, 59, 48, 0.5);
    color: #ff6b6b;
    padding: 15px;
    border-radius: 12px;
    margin-top: 20px;
    text-align: center;
    word-break: break-word;
}

/* Result Section */
.result-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.result-section h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #00d2ff;
}

.result-container {
    text-align: center;
    margin-bottom: 20px;
}

.result-container img {
    max-width: 100%;
    max-height: 500px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.download-btn {
    display: block;
    text-align: center;
    padding: 16px;
    background: rgba(46, 204, 113, 0.2);
    border: 2px solid rgba(46, 204, 113, 0.5);
    color: #2ecc71;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s;
}

.download-btn:hover,
.download-btn:active {
    background: rgba(46, 204, 113, 0.4);
}

/* Footer */
footer {
    text-align: center;
    margin-top: 40px;
    color: #6b7280;
    padding-bottom: 20px;
}

footer a {
    color: #3a7bd5;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Mobile Responsive Styles */
@media (max-width: 600px) {
    .container {
        padding: 20px 15px;
    }

    header {
        margin-bottom: 25px;
    }

    h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    main {
        padding: 20px 15px;
        border-radius: 16px;
    }

    .upload-label {
        padding: 30px 15px;
    }

    .upload-content svg {
        width: 40px;
        height: 40px;
    }

    #imagePreview {
        max-height: 250px;
    }

    .remove-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    #promptInput {
        min-height: 80px;
        padding: 12px;
    }

    .example-prompts {
        gap: 6px;
    }

    .example-prompts span {
        width: 100%;
        margin-bottom: 4px;
    }

    .example-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    #aspectRatio {
        padding: 12px;
        padding-right: 40px;
    }

    .submit-btn {
        padding: 14px;
        font-size: 1rem;
    }

    .result-container img {
        max-height: 350px;
    }

    .download-btn {
        padding: 14px;
    }
}

/* Extra small screens */
@media (max-width: 380px) {
    h1 {
        font-size: 1.5rem;
    }

    main {
        padding: 15px 12px;
    }

    .example-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
}

/* Safe area for notched phones */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
}
