/* --- THE MAIN DRAWER --- */
#tools-drawer {
    position: fixed;
    top: 60px;
    right: -160px;
    width: 160px;
    background: var(--ui-face);
    color: var(--ui-text);
    
    /* 3D Bevel matched to the OS */
    border-top: 2px solid var(--ui-light);
    border-left: 2px solid var(--ui-light);
    border-bottom: 2px solid var(--ui-dark);
    border-right: 2px solid var(--ui-dark);
    
    box-shadow: -4px 4px 0px rgba(0,0,0,0.5);
    transition: right 0.3s cubic-bezier(0, 0, 0.2, 1);
    z-index: 6000;
}

#tools-drawer.open {
    right: 0;
}

/* --- DRAWER TABS (Tools & Doodletop) --- */
.drawer-tab, .drawer-handle, #tools-tab, #doodletop-tab, .tab {
    position: absolute;
    /* This exactly offsets the width, meaning the tab's background will 
       perfectly overlap the drawer's left border to blend seamlessly! */
    left: -44px; 
    top: 20px;
    width: 44px !important;
    height: auto !important;
    min-height: 130px !important;
    
    background: var(--ui-face);
    color: var(--ui-text);
    
    /* 3D Bevel matched to the drawer, with NO right border */
    border-top: 2px solid var(--ui-light) !important;
    border-left: 2px solid var(--ui-light) !important;
    border-bottom: 2px solid var(--ui-dark) !important;
    border-right: none !important;
    
    display: flex !important;
    flex-direction: column !important; 
    align-items: center !important;
    justify-content: flex-start !important;
    padding: 8px 4px !important; 
    box-sizing: border-box !important;
    
    /* Shadow adjusted so it doesn't bleed inside the drawer */
    filter: drop-shadow(-3px 3px 4px rgba(0,0,0,0.6)) !important;
    cursor: pointer;
    writing-mode: horizontal-tb !important; 
    transform: none !important;
    z-index: 6001; /* Stay above the drawer */
}

/* The Icon */
.drawer-tab img, .drawer-handle img, #tools-tab img, #doodletop-tab img, .tab img {
    width: 24px !important; 
    height: 24px !important;
    margin: 0 0 8px 0 !important; 
    object-fit: contain !important;
    flex-shrink: 0 !important;
    transform: none !important; 
}

/* The Text Container */
.drawer-tab span, .drawer-handle span, #tools-tab span, #doodletop-tab span, .tab span {
    display: block !important;
    width: 12px !important; 
    word-break: break-all !important;
    overflow-wrap: break-word !important;
    text-transform: uppercase !important;
    line-height: 1.1 !important;
    font-size: 11px !important;
    white-space: normal !important;
    text-align: center !important;
    letter-spacing: 0 !important;
    transform: none !important; 
    direction: ltr !important;
}

/* --- TOOLS CONTENT & SECTIONS --- */
#tools-content {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.tool-section {
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(128,128,128,0.5);
    padding-bottom: 5px;
}

/* --- THEME PAINTER --- */
#color-preview {
    width: 50px; height: 50px;
    position: relative;
    border: 2px solid var(--ui-text);
    cursor: pointer;
    margin: 0 auto 10px auto;
    background: #444;
}
#bg-color-box {
    position: absolute; bottom: 0; right: 0; width: 30px; height: 30px;
    background: var(--desktop-bg); border: 1px solid white; z-index: 1;
}
#fg-color-box {
    position: absolute; top: 0; left: 0; width: 30px; height: 30px;
    background: var(--win-bg); border: 1px solid white; z-index: 2;
}

#color-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
}
.color-swatch {
    height: 20px;
    border: 1px solid #000;
    cursor: pointer;
}

/* --- QUICK TOGGLES (3-wide grid) --- */
.icon-grid { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 6px; 
    margin-top: 10px; 
}

.icon-btn { 
    width: 100%; 
    aspect-ratio: 1 / 1; 
    background: var(--ui-face); 
    border-top: 2px solid var(--ui-light); 
    border-left: 2px solid var(--ui-light); 
    border-right: 2px solid var(--ui-dark); 
    border-bottom: 2px solid var(--ui-dark); 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    padding: 0; 
    outline: none; 
}

.icon-btn img { 
    width: 24px; 
    height: 24px; 
    image-rendering: pixelated; 
    filter: drop-shadow(1px 1px 0px rgba(0,0,0,0.5)); 
    transition: transform 0.1s; 
    pointer-events: none; 
}

/* Active / Depressed States */
.icon-btn:active, .icon-btn.depressed { 
    border-top: 2px solid var(--ui-dark); 
    border-left: 2px solid var(--ui-dark); 
    border-right: 2px solid var(--ui-light); 
    border-bottom: 2px solid var(--ui-light); 
    background: var(--win-bg); 
}

.icon-btn:active img, .icon-btn.depressed img { 
    transform: translate(1px, 1px); 
    filter: drop-shadow(0px 0px 0px rgba(0,0,0,0)); 
}