* {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

#MainContainer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: white;
	overflow: hidden;
}

#Toolbar {
    min-height: 50px;
    height: auto;
    width: 100%;
    background: #f0f0f0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: relative;
    z-index: 1000;
    box-sizing: border-box;
    gap: 10px;
}

.ToolsContainer {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    flex: 1 1 auto;
}

.ActionsContainer {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-left: auto;
}

.ToolButton, .ActionButton {
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    background: #ddd;
    cursor: pointer;
    text-transform: capitalize;
    transition: background-color 0.2s;
}

.ToolButton:hover, .ActionButton:hover {
    background-color: #aaa !important;
}

.ToolButton.active {
    background-color: #999 !important;
}

.ColorContainer {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-left: 0;
}

.ColorButton {
    width: 30px;
    height: 30px;
    border: 2px solid #666;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    position: relative;
    transition: transform 0.1s;
}

.ColorButton:hover {
    transform: scale(1.1);
}

.ColorButton:active {
    transform: scale(0.95);
}

.ColorButton[data-color-index="0"] {
    background: #000000;
    border-color: #000;
}

.ColorButton[data-color-index="1"] {
    background: #ffffff;
}

.color-picker-input {
    position: absolute;
    opacity: 1;
    z-index: 1001;
}

.PressureContainer {
    display: flex;
    align-items: center;
    margin-left: 0;
    gap: 10px;
}

.PressureSliderContainer {
    display: flex;
    align-items: center;
    gap: 5px;
}

.PressureLabel {
    font-family: Arial, sans-serif;
    font-size: 14px;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100px;
    height: 5px;
    border-radius: 5px;
    background: #d3d3d3;
    outline: none;
    opacity: 0.7;
    -webkit-transition: .2s;
    transition: opacity .2s;
}

input[type="range"]:hover {
    opacity: 1;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
}

input[type="range"]:disabled {
    opacity: 0.5;
}

#PressureValue {
    font-family: Arial, sans-serif;
    font-size: 14px;
    width: 30px;
}

.LowerContainer {
    flex: 1;
    display: flex;
    position: relative;
    height: calc(100vh - var(--toolbar-height));
    overflow: hidden;
}

#LayerPanel {
    width: 70px;
    min-width: 60px;
    background: #f0f0f0;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
    position: relative;
}

.LayerScrollContainer {
    flex: 1;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
    min-height: 0;
}

.BackgroundColorContainer {
    width: 100%;
    padding: 10px 5px;
    background: #e8e8e8;
    border-top: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.BackgroundColorLabel {
    font-size: 12px;
    font-weight: bold;
    color: #555;
}

.BackgroundColorPreview {
    display: flex;
    align-items: center;
    gap: 5px;
}

#BackgroundColorSwatch {
    width: 30px;
    height: 20px;
    border: 1px solid #999;
    border-radius: 3px;
    cursor: pointer;
    background-image: linear-gradient(45deg, #ccc 25%, transparent 25%), 
                      linear-gradient(-45deg, #ccc 25%, transparent 25%), 
                      linear-gradient(45deg, transparent 75%, #ccc 75%), 
                      linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
}

#ClearBackgroundColor {
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 50%;
    background: #999;
    color: white;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#ClearBackgroundColor:hover {
    background: #777;
}

.UndoRedoContainer {
    width: 100%;
    padding: 10px 5px;
    display: flex;
    justify-content: space-around;
    background: #e0e0e0;
    border-top: 1px solid #ddd;
    flex-shrink: 0;
}

#UndoButton, #RedoButton {
    width: 25px;
    height: 25px;
    border: none;
    border-radius: 4px;
    background: #ddd;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#LayerPanel button:hover {
    background-color: #bbb !important;
}

#LayerPanel button:active {
    background-color: #999 !important;
}

#CanvasContainer {
    flex: 1;
    position: relative;
    overflow: auto;
    background: #888;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
}

canvas {
    touch-action: none;
    background: white;
    box-shadow: 0 0 10px rgba(0,0,0,0.3);
}

.BrushSelector {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    min-width: 150px;
    font-size: 14px;
}

.BrushSelector:hover {
    border-color: #aaa;
}

.BrushSelector:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.25);
}

@media (max-width: 768px) {
    #Toolbar {
        padding: 8px;
        gap: 8px;
    }
    
    .ToolButton, .ActionButton {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .BrushSelector {
        min-width: 120px;
        font-size: 13px;
    }
    
    .ColorButton {
        width: 28px;
        height: 28px;
    }
    
    input[type="range"] {
        width: 80px;
    }
    
    #LayerPanel {
        width: 60px;
        min-width: 50px;
    }
    
    .BackgroundColorLabel {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    #Toolbar {
        padding: 6px;
        gap: 6px;
    }
    
    .ToolButton, .ActionButton {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .BrushSelector {
        min-width: 100px;
        font-size: 12px;
    }
    
    #LayerPanel {
        width: 55px;
        min-width: 50px;
    }
}
