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

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #fdf2f8 0%, #faf5ff 50%, #fff7ed 100%);
    min-height: 100vh;
}

.app-container {
    min-height: 100vh;
}

/* Header */
.header-gradient {
    background: linear-gradient(135deg, #FF6B6B 0%, #FF69B4 50%, #DDA0DD 100%);
    padding: 2rem 1rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.header-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shine 4s infinite;
}

@keyframes shine {
    0% { left: -100%; }
    100% { left: 100%; }
}

.header-content {
    position: relative;
    z-index: 1;
}

.header-title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.header-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.version-badge {
    background: rgba(255,255,255,0.25);
    backdrop-filter: blur(10px);
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.9; }
}

.header-subtitle {
    color: rgba(255,255,255,0.9);
    margin-top: 0.5rem;
    font-size: 1rem;
}

/* Main Content */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Cards */
.card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

/* Collapsible Sections */
.collapsible-section {
    margin-bottom: 1rem;
    overflow: hidden;
}

.collapsible-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
}

.collapsible-header:hover {
    background: rgba(255, 107, 107, 0.05);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-icon {
    font-size: 1.25rem;
}

.chevron {
    font-size: 0.75rem;
    transition: transform 0.3s ease;
    color: #666;
}

.chevron.open {
    transform: rotate(180deg);
}

.collapsible-content {
    padding: 0 1.25rem 1.25rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #555;
    margin-bottom: 0.5rem;
}

.button-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.button-group.wrap {
    flex-wrap: wrap;
}

.select-btn {
    padding: 0.5rem 0.875rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1.5px solid #e5e7eb;
    background: white;
    color: #555;
    cursor: pointer;
    transition: all 0.2s ease;
}

.select-btn:hover {
    border-color: #FF69B4;
    background: #fff5f7;
}

.select-btn.selected {
    background: linear-gradient(135deg, #FF69B4, #DDA0DD);
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(255, 105, 180, 0.3);
    transform: scale(1.02);
}

/* Color Swatches */
.swatch-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.color-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.2s ease;
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch.selected {
    border-color: #FF69B4;
    box-shadow: 0 0 0 3px rgba(255, 105, 180, 0.3);
    transform: scale(1.1);
}

/* Dropdowns */
.dropdown-container {
    margin-bottom: 1rem;
}

.dropdown-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #555;
    margin-bottom: 0.5rem;
}

.dropdown-select {
    width: 100%;
    padding: 0.625rem 1rem;
    border-radius: 8px;
    border: 1.5px solid #e5e7eb;
    background: white;
    font-size: 0.875rem;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dropdown-select:focus {
    outline: none;
    border-color: #FF69B4;
    box-shadow: 0 0 0 3px rgba(255, 105, 180, 0.15);
}

/* Toggles */
.toggles-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toggle-switch {
    width: 48px;
    height: 26px;
    border-radius: 13px;
    background: #e5e7eb;
    border: none;
    cursor: pointer;
    position: relative;
    transition: background 0.2s ease;
}

.toggle-switch.active {
    background: linear-gradient(135deg, #FF69B4, #DDA0DD);
}

.toggle-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    transition: transform 0.2s ease;
}

.toggle-switch.active .toggle-knob {
    transform: translateX(22px);
}

.toggle-label {
    font-size: 0.875rem;
    color: #555;
}

/* Custom Textarea */
.custom-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1.5px solid #e5e7eb;
    font-size: 0.875rem;
    resize: none;
    min-height: 80px;
    transition: all 0.2s ease;
}

.custom-textarea:focus {
    outline: none;
    border-color: #FF69B4;
    box-shadow: 0 0 0 3px rgba(255, 105, 180, 0.15);
}

.custom-textarea::placeholder {
    color: #aaa;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.randomize-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: linear-gradient(135deg, #FFD93D, #FF9500);
    color: white;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.randomize-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 149, 0, 0.35);
}

.reset-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: #f3f4f6;
    color: #555;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* Prompt Card */
.prompt-card {
    padding: 1.25rem;
}

.prompt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.copy-btn {
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    background: #f3f4f6;
    border: none;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.prompt-preview {
    background: linear-gradient(135deg, #fdf2f8, #faf5ff);
    padding: 1rem;
    border-radius: 8px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    color: #666;
    word-wrap: break-word;
}

/* Generate Button */
.generate-btn {
    width: 100%;
    padding: 1.125rem 1.5rem;
    border-radius: 12px;
    background: linear-gradient(135deg, #FF6B6B 0%, #FF69B4 50%, #DDA0DD 100%);
    background-size: 200% 200%;
    color: white;
    font-size: 1.25rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 105, 180, 0.4);
    animation: gradient-shift 4s ease infinite;
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 105, 180, 0.5);
}

.generate-btn:disabled {
    opacity: 0.85;
    cursor: not-allowed;
}

.generate-btn.loading {
    animation: pulse-loading 1.5s ease-in-out infinite;
}

@keyframes gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@keyframes pulse-loading {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; }
}

.loading-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Image Card */
.image-card {
    padding: 1.25rem;
}

.image-container {
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(135deg, #f9fafb, #f3f4f6);
    min-height: 280px;
}

.generated-image-wrapper {
    position: relative;
}

.generated-image {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
}

.bounce-in {
    animation: bounceIn 0.5s ease-out;
}

@keyframes bounceIn {
    0% { transform: scale(0.9); opacity: 0; }
    60% { transform: scale(1.02); }
    100% { transform: scale(1); opacity: 1; }
}

.image-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    flex-wrap: wrap;
    padding: 1rem;
}

.generated-image-wrapper:hover .image-overlay {
    opacity: 1;
}

.overlay-btn {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background: white;
    color: #333;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.overlay-btn:hover {
    background: #f3f4f6;
    transform: scale(1.05);
}

.overlay-btn.favorited {
    background: #FF69B4;
    color: white;
}

.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    color: #aaa;
    gap: 0.75rem;
    border: 2px dashed #ddd;
    border-radius: 12px;
    margin: 0.5rem;
}

.placeholder-icon {
    font-size: 3rem;
}

.error-message {
    background: #fef2f2;
    color: #dc2626;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
}

/* History */
.toggle-history-btn {
    width: 100%;
    padding: 0.875rem 1rem;
    border-radius: 10px;
    background: white;
    border: 1.5px solid #e5e7eb;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-history-btn:hover {
    border-color: #FF69B4;
    background: #fff5f7;
}

.history-card {
    padding: 1.25rem;
}

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

.tab {
    flex: 1;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    font-weight: 500;
    color: #888;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
}

.tab:hover {
    color: #FF69B4;
}

.tab.active {
    color: #FF69B4;
    border-bottom-color: #FF69B4;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.history-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.history-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.history-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.6));
    padding: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.history-item:hover .history-overlay {
    opacity: 1;
}

.history-time {
    font-size: 0.7rem;
    color: white;
}

.clear-btn {
    width: 100%;
    padding: 0.625rem 1rem;
    border-radius: 8px;
    background: #fef2f2;
    color: #dc2626;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-btn:hover {
    background: #fee2e2;
}

.empty-state {
    text-align: center;
    color: #aaa;
    padding: 2rem 1rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

.modal-image {
    max-width: 100%;
    max-height: 70vh;
    display: block;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    justify-content: center;
}

.modal-btn {
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    background: linear-gradient(135deg, #FF69B4, #DDA0DD);
    color: white;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 105, 180, 0.35);
}

.modal-prompt {
    padding: 0 1rem 1rem;
    font-size: 0.8rem;
    color: #666;
    max-width: 600px;
}

/* Confetti */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    top: -20px;
    border-radius: 3px;
    animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Toast */
.toast-notification {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #333, #555);
    color: white;
    padding: 0.875rem 1.5rem;
    border-radius: 50px;
    font-weight: 500;
    z-index: 9998;
    animation: toast-pop 0.3s ease-out;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

@keyframes toast-pop {
    0% { transform: translateX(-50%) translateY(20px); opacity: 0; }
    100% { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* Footer */
.footer {
    padding: 2rem 1rem;
    text-align: center;
    border-top: 1px solid #e5e7eb;
    margin-top: 2rem;
    background: white;
}

.footer-disclaimer {
    color: #888;
    margin-bottom: 0.5rem;
}

.footer-credit {
    color: #aaa;
    font-size: 0.875rem;
}

.berry-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    transition: transform 0.2s ease;
}

.berry-btn:hover {
    transform: scale(1.3);
}

.footer-link {
    color: #FF69B4;
    text-decoration: none;
    font-weight: 500;
}

.footer-link:hover {
    text-decoration: underline;
}

.berry-mode-text {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #FF69B4;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Berry Mode */
.berry-mode {
    background: linear-gradient(135deg, #9B59B6 0%, #DDA0DD 50%, #FF69B4 100%) !important;
}

.berry-mode .card {
    background: rgba(255, 255, 255, 0.95);
}

.berry-mode .footer {
    background: rgba(255, 255, 255, 0.9);
}

/* Responsive */
@media (max-width: 768px) {
    .header-title {
        font-size: 1.4rem;
    }
    
    .header-subtitle {
        font-size: 0.9rem;
    }
    
    .main-content {
        padding: 1rem 0.75rem;
    }
    
    .select-btn {
        padding: 0.4rem 0.7rem;
        font-size: 0.8rem;
    }
    
    .color-swatch {
        width: 32px;
        height: 32px;
    }
    
    .generate-btn {
        font-size: 1.1rem;
        padding: 1rem;
        position: sticky;
        bottom: 1rem;
        z-index: 100;
    }
    
    .history-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .modal-actions {
        flex-wrap: wrap;
    }
    
    .modal-btn {
        flex: 1;
        min-width: 120px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #FF6B6B, #FF69B4);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #FF69B4, #DDA0DD);
}

.mt-4 {
    margin-top: 1rem;
}