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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
    background-size: 400% 400%;
    animation: gradientBackground 15s ease infinite;
    min-height: 100vh;
    color: #333;
}

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

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

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.logo p {
    font-size: 1.1rem;
    color: rgba(255,255,255,0.9);
    font-weight: 300;
}

.main {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: hidden;
}

.upload-section {
    padding: 40px;
}

.upload-zone {
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f9fafb;
}

.upload-zone:hover {
    border-color: #667eea;
    background: #f3f4f6;
}

.upload-zone.dragover {
    border-color: #667eea;
    background: #eff6ff;
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: #6b7280;
    stroke-width: 1.5;
}

.upload-zone h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #374151;
}

.upload-zone p {
    color: #6b7280;
    font-size: 0.9rem;
}

.preview-section {
    padding: 30px 40px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

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

.preview-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #374151;
}

.image-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}

.image-preview {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

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

.image-preview .remove-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 10;
}

.image-preview:hover .remove-btn {
    opacity: 1;
    transform: scale(1.1);
}

.view-selector-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.image-preview:hover .view-selector-container {
    opacity: 1;
}

.view-selector {
    width: 100%;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #4a5568;
    background-color: rgba(49, 49, 49, 0.8);
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
    backdrop-filter: blur(2px);
}

.view-selector:focus {
    outline: none;
    border-color: #667eea;
}

.image-actions {
    display: flex;
    gap: 12px;
}

.btn-primary, .btn-secondary {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-size: 0.9rem;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

.results-section {
    padding: 40px;
    border-top: 1px solid #e5e7eb;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f4f6;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

@keyframes gradientBackground {
	0% {
		background-position: 0% 50%;
	}
	50% {
		background-position: 100% 50%;
	}
	100% {
		background-position: 0% 50%;
	}
}

.tags-container {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.tags-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #374151;
}

.tags-actions {
    display: flex;
    gap: 12px;
}

.focus-controls {
    display: flex;
    gap: 40px;
    align-items: flex-start;
    margin-bottom: 16px;
}

.focus-options {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 0;
}

.tag-count-section {
    min-width: 200px;
}

.tag-count-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.tag-count-header h4 {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    margin: 0;
}

.tag-count-header span {
    font-size: 1.1rem;
    font-weight: 600;
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    padding: 4px 8px;
    border-radius: 6px;
    min-width: 28px;
    text-align: center;
}

.slider-container {
    position: relative;
}

.slider-container input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #d1d5db;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    margin-bottom: 8px;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.1s ease;
}

.slider-container input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.slider-container input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.1s ease;
}

.slider-container input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.1);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 4px;
}

.tags-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 30px;
}

.tag-category-section {
    margin-bottom: 24px;
}

.tag-category-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 12px;
    padding-bottom: 4px;
    border-bottom: 2px solid #e2e8f0;
}

.tag-category-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    padding: 6px 12px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.tag:hover {
    background: #e5e7eb;
}

.tag.selected {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.tag.confidence-high {
    border-left: 3px solid #10b981;
}

.tag.confidence-medium {
    border-left: 3px solid #f59e0b;
}

.tag.confidence-low {
    border-left: 3px solid #ef4444;
}

.tags-output {
    margin-top: 30px;
}

.tags-output label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #374151;
}

.tags-output textarea {
    width: 100%;
    height: 120px;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.9rem;
    resize: vertical;
    background: #f9fafb;
}

.tags-output textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.focus-section {
    padding: 30px 40px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
}

.focus-header {
    margin-bottom: 20px;
}

.focus-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}

.focus-header p {
    color: #6b7280;
    font-size: 0.9rem;
}

.focus-option {
    display: flex;
    align-items: center;
    gap: 8px;
}

.focus-option input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: #667eea;
}

.focus-option label {
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    user-select: none;
}

.custom-focus {
    margin-top: 12px;
    animation: fadeIn 0.3s ease-in;
}

.custom-focus input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
    background: white;
    transition: border-color 0.2s ease;
}

.custom-focus input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.section-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: transparent;
    color: #6b7280;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-btn:hover:not(.active) {
    color: #374151;
    background: rgba(102, 126, 234, 0.05);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.text-prompt-section {
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.text-prompt-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.text-prompt-header p {
    color: #6b7280;
    font-size: 0.9rem;
}

#textPromptInput {
    width: 100%;
    min-height: 120px;
    padding: 16px;
    border: 2px solid #d1d5db;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    transition: border-color 0.2s ease;
    background: white;
}

#textPromptInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#generateFromText {
    align-self: flex-start;
    margin-top: 10px;
}

/* Chat styles */
.chat-section {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 60vh; /* Adjust as needed */
    max-height: 700px;
}

.chat-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.chat-header p {
    color: #6b7280;
    font-size: 0.9rem;
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-message {
    display: flex;
    max-width: 80%;
}

.ai-message {
    align-self: flex-start;
}

.user-message {
    align-self: flex-end;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
}

.ai-message .message-content {
    background: #eef2ff;
    color: #374151;
    border-bottom-left-radius: 4px;
}

.user-message .message-content {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message p {
    margin: 0;
}

.chat-input-container {
    display: flex;
    gap: 12px;
    border-top: 1px solid #e5e7eb;
    padding-top: 20px;
}

#chatInput {
    flex-grow: 1;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

#chatInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#chatSendBtn {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .logo h1 {
        font-size: 2rem;
    }
    
    .upload-zone {
        padding: 40px 20px;
    }
    
    .image-preview {
        flex-direction: column;
        align-items: center;
    }
    
    .image-actions {
        flex-direction: row;
        justify-content: center;
    }
    
    .tags-header {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
    }
    
    .tags-actions {
        justify-content: center;
    }
    
    .focus-controls {
        flex-direction: column;
        gap: 20px;
    }
    
    .tag-count-section {
        min-width: unset;
        width: 100%;
    }
    
    .focus-section {
        padding: 20px;
    }
    
    .focus-options {
        flex-direction: column;
        gap: 12px;
    }
}