:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #6366f1;
    --secondary: #06b6d4;
    --bg-dark: #0f172a;
    --bg-medium: #1e293b;
    --bg-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #334155;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
}

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

header {
    background: var(--bg-medium);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border);
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

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

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

.toolbar {
    background: var(--bg-medium);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

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

.btn {
    background: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

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

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

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

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary-light);
}

.btn-secondary:hover {
    background: rgba(79, 70, 229, 0.1);
}

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

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

.sidebar {
    width: 320px;
    background: var(--bg-medium);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.filter-categories {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.filter-categories h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

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

.category-tab {
    background: var(--bg-light);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.375rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

.category-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

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

.filter-group {
    display: none;
}

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

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

.filter-item label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

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

.filter-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.filter-item input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-light);
}

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

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

.preset-btn {
    background: var(--bg-light);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.actions {
    padding: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
}

.actions .btn {
    flex: 1;
    font-size: 0.75rem;
    padding: 0.5rem;
}

.canvas-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #0a0f1c;
}

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

#canvas {
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    background: white;
}

.drop-zone {
    position: absolute;
    inset: 2rem;
    border: 2px dashed var(--border);
    border-radius: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.9);
    transition: all 0.3s;
}

.drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.1);
}

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

.drop-icon {
    width: 4rem;
    height: 4rem;
    fill: var(--text-secondary);
    margin-bottom: 1rem;
}

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

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

.link-btn {
    background: none;
    border: none;
    color: var(--primary-light);
    text-decoration: underline;
    cursor: pointer;
    font-size: inherit;
}

.zoom-controls {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    background: var(--bg-medium);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    padding: 0.25rem;
}

.zoom-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    width: 2rem;
    height: 2rem;
    cursor: pointer;
    border-radius: 0.25rem;
    transition: background 0.2s;
}

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

.zoom-level {
    font-size: 0.75rem;
    padding: 0 0.75rem;
    min-width: 4rem;
    text-align: center;
}

.history-panel {
    width: 200px;
    background: var(--bg-medium);
    border-left: 1px solid var(--border);
    padding: 1rem;
    overflow-y: auto;
}

.history-panel h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

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

.history-item {
    padding: 0.5rem;
    background: var(--bg-light);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    background: #475569;
}

.history-item.active {
    background: var(--primary);
}

.batch-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

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

.modal-content {
    background: var(--bg-medium);
    border-radius: 0.5rem;
    padding: 2rem;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-bottom: 1.5rem;
}

.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: 0.375rem;
    position: relative;
    cursor: pointer;
}

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

.batch-image.selected::after {
    content: '✓';
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--success);
    color: white;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.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;
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .history-panel {
        display: none;
    }
    
    .toolbar {
        flex-wrap: wrap;
    }
}