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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 100vw;
    padding: 10px;
}

.header {
    text-align: center;
    color: white;
    padding: 20px 0;
    margin-bottom: 20px;
}

.header h1 {
    font-size: 24px;
    margin-bottom: 8px;
}

.header p {
    font-size: 14px;
    opacity: 0.9;
}

.instructions {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    margin-bottom: 20px;
    padding: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

.instruction-content h3 {
    color: #333;
    font-size: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.instruction-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.instruction-content li {
    padding: 6px 0;
    color: #555;
    font-size: 14px;
    line-height: 1.5;
    border-left: 3px solid #667eea;
    padding-left: 12px;
    margin-bottom: 8px;
}

.instruction-content li:last-child {
    margin-bottom: 0;
}

.instruction-content strong {
    color: #667eea;
    font-weight: 600;
}

.example-viewer {
    background: white;
    border-radius: 12px;
    margin-bottom: 20px;
    padding: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    min-height: 250px;
    display: none;
}

.example-viewer.active {
    display: block;
}

.example-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #333;
}

.example-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.image-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid #e1e5e9;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #495057;
    text-align: left;
}

.section-images {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.section-image {
    flex-shrink: 0;
    width: 100px;
    height: 100px;
    border-radius: 6px;
    overflow: hidden;
    background: #f5f5f5;
    border: 1px solid #dee2e6;
    cursor: pointer;
    transition: transform 0.2s;
}

.section-image:hover {
    transform: scale(1.05);
}

.section-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.style-selector {
    background: white;
    border-radius: 12px;
    margin-bottom: 20px;
    padding: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.selector-label {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #333;
    text-align: left;
}

.dropdown-container {
    position: relative;
    width: 100%;
}

.dropdown-header {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    transition: border-color 0.2s;
}

.dropdown-header:hover {
    border-color: #667eea;
}

.dropdown-header.active {
    border-color: #667eea;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.dropdown-arrow {
    font-size: 12px;
    transition: transform 0.2s;
}

.dropdown-header.active .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #667eea;
    border-top: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.dropdown-list.active {
    display: block;
}

.dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f4;
    font-size: 14px;
    transition: background-color 0.2s;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background-color: #f8f9ff;
}

.dropdown-item.selected {
    background-color: #667eea;
    color: white;
}

.dropdown-list::-webkit-scrollbar {
    width: 6px;
}

.dropdown-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.dropdown-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.dropdown-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.input-section {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.prompt-section {
    margin-bottom: 16px;
}

.prompt-label {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.prompt-input {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    resize: none;
    font-family: inherit;
    overflow-y: auto;
}

.prompt-input:focus {
    outline: none;
    border-color: #667eea;
}

.upload-section {
    text-align: center;
}

.upload-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
}

.upload-btn:hover {
    background: #5a67d8;
}

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

.file-input {
    display: none;
}

.selected-files {
    margin-top: 12px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 12px;
    color: #666;
}

@media (max-width: 480px) {
    .section-image {
        width: 80px;
        height: 80px;
    }
    
    .container {
        padding: 8px;
    }
    
    .example-content {
        gap: 12px;
    }
    
    .section-title {
        font-size: 12px;
    }
    
    .dropdown-list {
        max-height: 180px;
    }
    
    .dropdown-item {
        padding: 10px 14px;
        font-size: 13px;
    }
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.modal-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 6px;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    font-weight: bold;
    color: #666;
    cursor: pointer;
    background: none;
    border: none;
    padding: 5px;
    line-height: 1;
}

.close-btn:hover {
    color: #000;
}

/* Enhanced Generation Functionality Styles */
.api-key-section {
    margin-bottom: 16px;
}

.api-key-input {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 2px solid #e1e5e9;
    background-color: white;
    color: #333;
    box-sizing: border-box;
    margin-bottom: 0.5rem;
    font-family: inherit;
    font-size: 14px;
}

.api-key-input:focus {
    outline: none;
    border-color: #667eea;
}

.upload-section-enhanced {
    margin-bottom: 16px;
}

.upload-area {
    border: 2px dashed #e1e5e9;
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
    background: #f8f9fa;
    cursor: pointer;
    margin-bottom: 12px;
}

.upload-area:hover, .upload-area.drag-over {
    border-color: #667eea;
    background: #f0f2ff;
}

.upload-area p {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    color: #333;
}

.upload-area span {
    color: #666;
    font-size: 0.9rem;
}

input[type="file"] {
    display: none;
}

#thumbnails-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    margin-top: 12px;
    margin-bottom: 12px;
}

.thumbnail-wrapper {
    position: relative;
    padding-top: 100%;
    border-radius: 6px;
    overflow: hidden;
    background: #f5f5f5;
    border: 1px solid #dee2e6;
}

.thumbnail-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-wrapper .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    padding: 0;
    line-height: 1;
}

.generation-section {
    margin-bottom: 16px;
}

.generate-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: transform 0.2s ease, opacity 0.2s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.generate-button:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.generate-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid transparent;
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.hidden {
    display: none !important;
}

.result-section {
    background: white;
    border-radius: 12px;
    margin-bottom: 20px;
    padding: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.result-container {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    border: 1px solid #e1e5e9;
}

.result-container img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.result-container p {
    color: #666;
    text-align: center;
    font-style: italic;
}

/* Prompt Toggle and Clear Buttons */
.prompt-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 16px;
}

.prompt-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

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

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

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #667eea;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

.toggle-label {
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

.clear-btn {
    background: #f8f9fa;
    color: #666;
    border: 1px solid #dee2e6;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
    min-width: fit-content;
    margin-left: auto;
}

.clear-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.prompt-section.inactive {
    opacity: 0.5;
    pointer-events: none;
}

.prompt-section.inactive .prompt-input {
    background-color: #f8f9fa;
}

@media (max-width: 600px) {
    .prompt-controls {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .clear-btn {
        margin-left: 0;
        order: 2;
        flex: 1;
        text-align: center;
    }
    
    .prompt-toggle {
        order: 1;
        flex: 1;
        justify-content: center;
    }
}

@media (max-width: 400px) {
    .prompt-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .clear-btn {
        margin-left: 0;
        text-align: center;
    }
    
    .prompt-toggle {
        justify-content: center;
    }
}
