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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a1a;
    color: #fff;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Toolbar */
#toolbar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 10px 20px;
    background: #2a2a2a;
    border-bottom: 1px solid #3a3a3a;
    flex-wrap: wrap;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tool-btn, .action-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: #3a3a3a;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
}

.tool-btn:hover, .action-btn:hover {
    background: #4a4a4a;
}

.tool-btn.active {
    background: #007aff;
}

.tool-btn:active, .action-btn:active {
    transform: scale(0.95);
}

label {
    font-size: 12px;
    color: #aaa;
}

input[type="range"] {
    width: 100px;
}

input[type="color"] {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: transparent;
}

/* Brush selector */
.brush-selector select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #3a3a3a;
    background: #3a3a3a;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}

.brush-selector select:hover {
    background: #4a4a4a;
}

/* Main workspace with canvas and layers panel */
#workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Canvas Container */
#canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
}

#main-canvas {
    background: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    cursor: crosshair;
}

/* Layers Panel */
#layers-panel,
.layers-panel {
    width: 240px;
    background: #252525;
    border-left: 1px solid #3a3a3a;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.layers-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #2a2a2a;
    border-bottom: 1px solid #3a3a3a;
    font-weight: 600;
    font-size: 14px;
}

.layers-actions {
    display: flex;
    gap: 4px;
}

.layer-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    background: #3a3a3a;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.layer-btn:hover {
    background: #4a4a4a;
}

.layers-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: #2a2a2a;
    border-radius: 6px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.layer-item:hover {
    background: #333;
}

.layer-item.active {
    background: #007aff;
}

.layer-item.dragging {
    opacity: 0.5;
}

.layer-item.drag-over {
    border: 2px dashed #007aff;
}

.layer-visibility {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    opacity: 0.7;
}

.layer-visibility:hover {
    opacity: 1;
}

.layer-visibility.hidden {
    opacity: 0.3;
}

.layer-thumbnail {
    width: 40px;
    height: 30px;
    background: #1a1a1a;
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}

.thumb-canvas {
    width: 100%;
    height: 100%;
}

.layer-info {
    flex: 1;
    min-width: 0;
}

.layer-name {
    font-size: 12px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    outline: none;
    padding: 2px 4px;
    border-radius: 3px;
}

.layer-name:hover {
    background: rgba(255,255,255,0.1);
}

.layer-name:focus {
    background: rgba(255,255,255,0.2);
}

.layers-properties {
    padding: 16px;
    border-top: 1px solid #3a3a3a;
    background: #2a2a2a;
}

.property-row {
    margin-bottom: 12px;
}

.property-row:last-child {
    margin-bottom: 0;
}

.property-row label {
    display: block;
    margin-bottom: 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.property-row input[type="range"] {
    width: 100%;
}

.property-row select {
    width: 100%;
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #3a3a3a;
    background: #3a3a3a;
    color: #fff;
    font-size: 12px;
}

/* Status Bar */
#status-bar {
    display: flex;
    justify-content: space-between;
    padding: 8px 20px;
    background: #2a2a2a;
    border-top: 1px solid #3a3a3a;
    font-size: 12px;
    color: #888;
}

/* Color Picker Wrapper */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

#color-picker-native {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: transparent;
}

.color-picker-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: #3a3a3a;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.color-picker-btn:hover {
    background: #4a4a4a;
}

.advanced-picker-popup {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    z-index: 100;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.advanced-picker-popup .color-picker {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
}

/* Color Picker */
.color-picker {
    padding: 16px;
    background: #2a2a2a;
    border-radius: 8px;
    min-width: 200px;
}

.color-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.color-preview-box {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    border: 2px solid #3a3a3a;
    background: #ff0000;
}

#color-hex {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    background: #1a1a1a;
    color: #fff;
    font-size: 14px;
    font-family: monospace;
    text-transform: uppercase;
}

.color-gradient {
    position: relative;
    width: 100%;
    height: 150px;
    border-radius: 6px;
    margin-bottom: 12px;
    cursor: crosshair;
    background: linear-gradient(to top, #000, transparent),
                linear-gradient(to right, #fff, #ff0000);
}

.color-cursor {
    position: absolute;
    width: 12px;
    height: 12px;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.5);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.hue-slider {
    position: relative;
    width: 100%;
    height: 20px;
    border-radius: 10px;
    margin-bottom: 16px;
    cursor: pointer;
    background: linear-gradient(to right,
        #ff0000 0%, #ffff00 17%, #00ff00 33%,
        #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
}

.hue-cursor {
    position: absolute;
    top: 50%;
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.5);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.color-modes {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}

.mode-btn {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 4px;
    background: #3a3a3a;
    color: #aaa;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn:hover {
    background: #4a4a4a;
}

.mode-btn.active {
    background: #007aff;
    color: #fff;
}

.color-values .value-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-values label {
    font-size: 12px;
    color: #aaa;
    min-width: 16px;
}

.color-values input[type="number"] {
    width: 60px;
    padding: 6px 8px;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    background: #1a1a1a;
    color: #fff;
    font-size: 12px;
}

/* Responsive */
@media (max-width: 900px) {
    #layers-panel,
    .layers-panel {
        width: 200px;
    }
}

@media (max-width: 768px) {
    #toolbar {
        padding: 8px 10px;
        gap: 10px;
    }
    
    .tool-btn, .action-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    input[type="range"] {
        width: 60px;
    }
    
    #layers-panel,
    .layers-panel {
        width: 180px;
    }
}
