* {
    box-sizing: border-box;
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: 'Comic Neue', sans-serif;
    /* Use consistent font */
    background: linear-gradient(135deg, #f0f8ff 0%, #e6f7ff 100%);
    /* Subtle gradient */
    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: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    padding: 15px;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    overflow-y: auto;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
}

.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;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tool-btn,
.util-btn {
    border: none;
    background: #fff;
    border-radius: 15px;
    width: 50px;
    height: 50px;
    font-size: 24px;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

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

.tool-btn:hover,
.util-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.1);
}

.tool-btn:active,
.util-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.tool-btn.active {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.3);
}

.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 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.color-box.active {
    transform: scale(1.2);
    border-color: #333;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

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

.konvajs-content {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    max-width: 100%;
    border-radius: 20px;
    /* Rounded corners for the canvas */
    background: white;
    /* Ensure canvas has white bg */
}

/* --- 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;
    }
}