:root {
    --bg-dark: #0a0e1a;
    --glass-bg: rgba(15, 23, 42, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    
    --primary: #7c3aed;
    --primary-hover: #6d28d9;
    --secondary: #334155;
    --secondary-hover: #475569;
    --accent: #06b6d4;
    --accent-hover: #0891b2;
    --success: #10b981;
    --danger: #ef4444;
    
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Blobs */
.bg-blobs {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.4;
    animation: float 20s infinite alternate;
}

.blob-1 {
    top: -10%; left: -10%;
    width: 50vw; height: 50vw;
    background: var(--primary);
}

.blob-2 {
    bottom: -10%; right: -10%;
    width: 40vw; height: 40vw;
    background: var(--accent);
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(5%, 10%) scale(1.1); }
}

/* Layout Structure */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-height: 100vh;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.app-header {
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

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

.logo-icon {
    width: 32px;
    height: 32px;
}

.logo-text {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, #a78bfa, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-weight: 500;
}

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

.left-panel, .right-panel {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Upload Area */
.upload-area {
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    padding: 2rem 1rem;
    text-align: center;
    position: relative;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(0,0,0,0.2);
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: rgba(124, 58, 237, 0.1);
}

.upload-area.dragover {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { border-color: rgba(124, 58, 237, 0.5); }
    50% { border-color: rgba(124, 58, 237, 1); }
    100% { border-color: rgba(124, 58, 237, 0.5); }
}

.hidden-input {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
}

.upload-icon {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Pool Grid */
.pool-actions {
    display: flex;
    gap: 0.5rem;
}

.thumbnails-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

.thumbnail-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-item .filename {
    position: absolute;
    bottom: 0; left: 0; width: 100%;
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 0.6rem;
    padding: 2px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thumbnail-item.selected {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}

.thumbnail-item.in-group {
    border-color: var(--success);
    opacity: 0.6;
    pointer-events: none;
}

.thumbnail-remove {
    position: absolute;
    top: 4px; right: 4px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px; height: 20px;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
    z-index: 10;
}

.thumbnail-item:hover .thumbnail-remove {
    opacity: 1;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.02);
    border-radius: var(--radius-md);
    border: 1px dashed rgba(255,255,255,0.1);
}

/* Groups Area */
.grouping-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: auto;
}

.groups-area {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    flex: 1;
}

.group-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.group-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    border-left-color: var(--accent);
}

.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.group-count {
    font-size: 0.75rem;
    background: var(--glass-bg);
    padding: 2px 8px;
    border-radius: 12px;
    color: var(--text-muted);
}

.group-images {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    min-height: 60px;
    background: rgba(255,255,255,0.02);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

.group-thumb {
    width: 60px; height: 60px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.group-thumb:hover {
    opacity: 0.7;
}

.group-thumb::after {
    content: '✕';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    opacity: 0;
    pointer-events: none;
}

.group-thumb-wrapper {
    position: relative;
}
.group-thumb-wrapper:hover::after {
    content: '✕';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    text-shadow: 0 0 4px black;
    pointer-events: none;
    z-index: 2;
}

.group-controls {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

select {
    background: var(--secondary);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 0.4rem;
    font-size: 0.85rem;
    outline: none;
}

.group-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    outline: none;
}

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.w-full { width: 100%; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.5);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}
.btn-secondary:hover { background: var(--secondary-hover); }

.btn-accent {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: white;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}
.btn-outline:hover { background: rgba(255,255,255,0.05); }

.btn-danger-icon {
    background: transparent;
    color: var(--text-muted);
    padding: 0.25rem;
    font-size: 1.25rem;
}
.btn-danger-icon:hover { color: var(--danger); transform: scale(1.1); }

.btn-export-all {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4);
}
.btn-export-all:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.6);
}

/* Footer */
.app-footer {
    padding: 1rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.copyright {
    font-size: 0.75rem;
    opacity: 0.6;
}

.copyright strong {
    color: var(--primary);
    letter-spacing: 0.5px;
}

.disclaimer-link {
    color: var(--text-muted);
    text-decoration: none;
    opacity: 0.6;
    transition: var(--transition);
}
.disclaimer-link:hover {
    color: var(--primary);
    opacity: 1;
}

.disclaimer-content {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.disclaimer-section h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text-main);
}

.disclaimer-section p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.disclaimer-section ul {
    list-style: none;
    margin-top: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.disclaimer-section li {
    font-size: 0.85rem;
    color: var(--text-muted);
    padding-left: 1rem;
    position: relative;
    line-height: 1.5;
}

.disclaimer-section li::before {
    content: '—';
    position: absolute;
    left: 0;
    color: var(--text-muted);
}

.disclaimer-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    opacity: 0.6;
}

.text-danger {
    color: var(--danger);
    font-weight: 700;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    transition: opacity 0.3s;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 50px; height: 50px;
    border: 4px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Toast */
.toast-container {
    position: fixed;
    bottom: 1.5rem; right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 9999;
}

.toast {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-left: 4px solid var(--primary);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--accent); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateY(-10px); }
}

/* Help Button */
.btn-help {
    background: rgba(124, 58, 237, 0.15);
    border: 1px solid rgba(124, 58, 237, 0.4);
    color: #c4b5fd;
    padding: 0.55rem 1.1rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    white-space: nowrap;
    transition: var(--transition);
}
.btn-help:hover {
    background: rgba(124, 58, 237, 0.3);
    border-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(124, 58, 237, 0.4);
}

/* Tutorial Overlay */
.tutorial-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeInOverlay 0.3s ease;
}

.tutorial-overlay.hidden {
    display: none;
}

@keyframes fadeInOverlay {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tutorial-modal {
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.tutorial-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.tutorial-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
}

/* Steps */
.tutorial-steps {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.tutorial-step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.tutorial-step:hover {
    background: rgba(124, 58, 237, 0.08);
    border-color: rgba(124, 58, 237, 0.2);
    transform: translateX(4px);
}

.step-number {
    min-width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: white;
    flex-shrink: 0;
}

.step-content h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.step-content p {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Tips */
.tutorial-tips {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.tutorial-tips h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--success);
}

.tutorial-tips ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tutorial-tips li {
    font-size: 0.85rem;
    color: var(--text-muted);
    padding-left: 1.25rem;
    position: relative;
    line-height: 1.5;
}

.tutorial-tips li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: bold;
}

/* Footer */
.tutorial-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Responsive */
@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    .upload-area {
        width: 100%;
    }
    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .tutorial-modal {
        max-height: 85vh;
        padding: 1.5rem;
    }
    .tutorial-step {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}
