* {
    box-sizing: border-box;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: sans-serif;
    background-color: #f0f0f0;
    overflow: hidden; /* Keep this to prevent main page scroll */
}

.app-container {
    display: grid;
    grid-template-columns: 200px 1fr;
    width: 100%;
    height: 100%;
}

.toolbar {
    flex-shrink: 0;
    width: 200px;
    background-color: #fff;
    padding: 15px;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    overflow-y: auto;
}

.tool-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.tool-label {
    font-weight: bold;
    font-size: 14px;
    color: #555;
    margin: 0 0 5px 0;
}

.tool-btn, .util-btn {
    border: 2px solid transparent;
    background: #eee;
    border-radius: 10px;
    width: 50px;
    height: 50px;
    font-size: 24px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tool-group .tool-btn {
    display: inline-flex;
}

.tool-btn.active {
    border-color: #007bff;
    background-color: #e0efff;
}

.palette {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.color-box {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}

.color-box.active {
    transform: scale(1.2);
    border-color: #007bff;
}

.canvas-container {
    display: flex;
    justify-content: center; /* Changed from flex-start */
    align-items: center;     /* Changed from flex-start */
    padding: 20px;
    background-color: #e9e9e9;
    overflow: hidden;
    position: relative;
    min-width: 0;
    max-width: 100%;
    max-height: 100%;
}

.konvajs-content {
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
    max-width: 100%;
}

/* --- START: NEW STYLES --- */
.image-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.thumbnail {
    width: 45px;
    height: 45px;
    border-radius: 8px;
    border: 2px solid #ccc;
    cursor: pointer;
    object-fit: cover;
    transition: all 0.2s ease-in-out;
}

.thumbnail:hover {
    border-color: #999;
    transform: scale(2);

}

.thumbnail.active {
    border-color: #007bff;
    transform: scale(1.2);
}

/* --- END: NEW STYLES --- */

/* --- MODIFICATION --- */
/* Added standard home button style */
.home-btn-subpage {
    /* This is a mix of the old .util-btn and the new standard */
    font-size: 1.8em;
    color: #333;
    text-decoration: none;
    padding: 10px;
    z-index: 100;
    transition: transform 0.1s;

    /* Copied from .util-btn to keep the button look */
    border: 2px solid transparent;
    background: #eee;
    border-radius: 10px;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.home-btn-subpage:active {
    transform: scale(0.9);
}
/* --- END MODIFICATION --- */


/* --- START: DESKTOP STYLES --- */
@media (min-width: 1024px) {
    .app-container {
        grid-template-columns: 240px 1fr;
    }

    .toolbar {
        width: 240px;
    }

    .image-selector, .palette {
        grid-template-columns: 1fr 1fr 1fr;
    }
}
/* --- END: DESKTOP STYLES --- */

/* --- TABLET PORTRAIT FIXES --- */
@media (max-width: 768px) and (orientation: portrait) {
    .app-container {
        grid-template-columns: 140px 1fr;
    }

    .toolbar {
        width: 140px;
        padding: 10px;
        gap: 15px;
    }

    .tool-btn, .util-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    /* --- MODIFICATION --- */
    /* Added home button sizing for this view */
    .home-btn-subpage {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    /* --- END MODIFICATION --- */

    .color-box, .thumbnail {
        width: 30px;
        height: 30px;
    }

    .canvas-container {
        padding: 10px;
    }
}
