:root {
    --primary: #ff6b6b;
    --primary-dark: #e63946;
    --primary-light: #ff8787;
    --secondary: #4ecdc4;
    --accent: #ffe66d;
    --bg-main: #1a1a1a;
    --bg-card: #242424;
    --bg-hover: #2e2e2e;
    --text-primary: #ffffff;
    --text-secondary: #a8a8a8;
    --border: rgba(255, 255, 255, 0.08);
    --success: #51cf66;
    --danger: #ff6b6b;
    --warning: #ffd93d;
}

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

body {
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    background: var(--bg-main);
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(255, 107, 107, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(78, 205, 196, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(255, 230, 109, 0.03) 0%, transparent 50%);
    color: var(--text-primary);
    overflow: hidden;
}

.container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(20px);
    padding: 1.25rem 2rem;
    box-shadow: 0 1px 0 var(--border);
    position: relative;
    z-index: 10;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.125rem;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 400;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.toolbar {
    background: var(--bg-card);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 0 var(--border);
}

.toolbar-section {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.btn {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: none;
    padding: 0.625rem 1.25rem;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    position: relative;
}

.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 10px;
    padding: 1px;
    background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.1));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.btn:hover::before {
    opacity: 1;
}

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

.btn:active {
    transform: translateY(0);
}

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

.btn-primary {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.btn-secondary {
    background: transparent;
    border: 2px solid var(--bg-hover);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(255, 107, 107, 0.1);
}

.icon {
    width: 1.125rem;
    height: 1.125rem;
    fill: currentColor;
}

.workspace {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.sidebar {
    width: 340px;
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: 1px 0 0 var(--border);
}

.filter-categories {
    padding: 1.5rem;
    background: rgba(36, 36, 36, 0.5);
}

.filter-categories h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.category-tab {
    background: var(--bg-hover);
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-tab:hover {
    background: #383838;
    color: var(--text-primary);
}

.category-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
}

.filters-container {
    flex: 1;
    padding: 1.5rem;
}

.filter-group {
    display: none;
}

.filter-group.active {
    display: block;
}

.filter-item {
    margin-bottom: 1.75rem;
}

.filter-item label {
    display: block;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.filter-item input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-hover);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.filter-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: white;
    border: 3px solid var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.filter-item input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.filter-item .value {
    display: inline-block;
    margin-left: 0.75rem;
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 600;
    min-width: 3rem;
}

.filter-preset-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.preset-btn {
    background: var(--bg-hover);
    border: none;
    color: var(--text-secondary);
    padding: 0.625rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-btn:hover {
    background: var(--secondary);
    color: white;
    transform: translateY(-1px);
}

.actions {
    padding: 1.5rem;
    background: rgba(36, 36, 36, 0.5);
    display: flex;
    gap: 0.75rem;
}

.actions .btn {
    flex: 1;
    font-size: 0.8125rem;
    padding: 0.625rem;
}

.canvas-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: 
        radial-gradient(ellipse at center, rgba(255, 107, 107, 0.02) 0%, transparent 40%),
        var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 2rem;
}

#canvas {
    max-width: 100%;
    max-height: 100%;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    background: white;
    border-radius: 4px;
}

.drop-zone {
    position: absolute;
    inset: 4rem;
    border: 3px dashed rgba(255, 107, 107, 0.3);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(26, 26, 26, 0.8);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.drop-zone.drag-over {
    border-color: var(--secondary);
    background: rgba(78, 205, 196, 0.05);
    transform: scale(0.98);
}

.drop-zone.hidden {
    display: none;
}

.drop-icon {
    width: 5rem;
    height: 5rem;
    fill: var(--primary);
    margin-bottom: 1.5rem;
    opacity: 0.8;
}

.drop-zone p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.drop-zone .small {
    font-size: 0.875rem;
}

.link-btn {
    background: none;
    border: none;
    color: var(--secondary);
    text-decoration: none;
    cursor: pointer;
    font-size: inherit;
    font-weight: 600;
    transition: color 0.2s ease;
}

.link-btn:hover {
    color: var(--primary);
    text-decoration: underline;
}

.zoom-controls {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    background: rgba(36, 36, 36, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    padding: 0.375rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.zoom-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    width: 2.25rem;
    height: 2.25rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-weight: 600;
}

.zoom-btn:hover {
    background: var(--bg-hover);
}

.zoom-level {
    font-size: 0.8125rem;
    padding: 0 1rem;
    min-width: 4.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-weight: 500;
}

.history-panel {
    width: 220px;
    background: var(--bg-card);
    box-shadow: -1px 0 0 var(--border);
    padding: 1.5rem;
    overflow-y: auto;
}

.history-panel h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-item {
    padding: 0.75rem;
    background: var(--bg-hover);
    border-radius: 8px;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.history-item:hover {
    background: #383838;
    border-color: rgba(255, 255, 255, 0.1);
}

.history-item.active {
    background: rgba(255, 107, 107, 0.15);
    border-color: var(--primary);
    color: var(--primary);
}

.batch-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.batch-modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2.5rem;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
}

.modal-content h2 {
    margin-bottom: 2rem;
    font-size: 1.5rem;
    font-weight: 700;
}

.batch-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.batch-image {
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.batch-image:hover {
    transform: scale(0.95);
    border-color: var(--border);
}

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

.batch-image.selected {
    border-color: var(--secondary);
}

.batch-image.selected::after {
    content: '✓';
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: var(--secondary);
    color: white;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.batch-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        left: -100%;
        top: 0;
        bottom: 0;
        z-index: 100;
        transition: left 0.3s ease;
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .history-panel {
        display: none;
    }
    
    .toolbar {
        flex-wrap: wrap;
    }
    
    .drop-zone {
        inset: 2rem;
    }
}