body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #1e1e1e;
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

#ui-container {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 10;
    pointer-events: none; /* Let clicks pass through the container to the canvas */
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

/* Nasconde la scrollbar ma mantiene lo scroll */
#ui-container::-webkit-scrollbar {
    width: 0px;
    background: transparent;
}

h1 {
    font-size: 1.4rem;
    margin: 0 0 5px 0;
    color: #e0e0e0;
    pointer-events: auto;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#btn-lang {
    pointer-events: auto;
    cursor: pointer;
    background: transparent;
    border: none;
    transition: transform 0.2s;
}

#btn-lang:hover {
    transform: scale(1.1);
}

.panel {
    background: rgba(40, 40, 40, 0.85);
    border: 1px solid #555;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    pointer-events: auto; /* Catch clicks on panels */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.panel h3 {
    margin: 0 0 10px 0;
    font-size: 14px;
    text-transform: uppercase;
    color: #ccc;
    letter-spacing: 1px;
}

p {
    font-size: 0.8rem;
    color: #aaaaaa;
    line-height: 1.4;
    margin: 0;
}

button {
    background: #e0e0e0;
    color: #222;
    border: 1px solid #aaa;
    padding: 6px 9px;
    cursor: pointer;
    border-radius: 3px;
    margin-right: 4px;
    margin-bottom: 4px;
    transition: all 0.2s ease;
    font-weight: 600;
    font-size: 11px;
}

button:hover:not([disabled]) {
    background: #d0d0d0;
    border-color: #888;
}

button[disabled] {
    background: #444;
    color: #777;
    border-color: #333;
    text-decoration: line-through;
    cursor: not-allowed;
}

/* Varianti bottoni colorati per il repair per mantenerli distinti ma in stile */
.btn-soft {
    background: #3eb55c;
    color: #fff;
    border-color: #28a745;
}
.btn-soft:hover:not([disabled]) {
    background: #28a745;
    border-color: #1e7e34;
}

.btn-hard {
    background: #e05362;
    color: #fff;
    border-color: #dc3545;
}
.btn-hard:hover:not([disabled]) {
    background: #dc3545;
    border-color: #bd2130;
}

.repair-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 5px;
    padding-bottom: 10px;
    border-bottom: 1px solid #555;
}
.repair-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.repair-group small {
    font-size: 0.75rem;
    color: #999;
    line-height: 1.2;
}

input[type="file"] {
    font-size: 0.8rem;
    color: #ccc;
}

input[type="range"] {
    cursor: pointer;
}

#analysis-results {
    font-size: 0.8rem;
    color: #ffaa00;
    background: #222;
    padding: 10px;
    border-radius: 4px;
    white-space: pre-wrap;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    border: 1px solid #444;
}

.drawer-handle { display: none; }

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

#btn-upload-header {
    display: none; /* Hidden on desktop */
    background-color: #3a86ff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.2s;
    pointer-events: auto;
    text-align: center;
}

#btn-upload-header:hover {
    background-color: #2b65c2;
}

@media (max-width: 768px) {
    body {
        height: 100dvh;
    }

    #ui-container {
        position: fixed;
        width: 100%;
        max-height: 70dvh; /* A bit taller because of panels */
        top: auto;
        bottom: 0;
        left: 0;
        padding: 60px 20px calc(20px + env(safe-area-inset-bottom));
        border-radius: 24px 24px 0 0;
        background: rgba(25, 25, 25, 0.98);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        box-shadow: 0 -10px 30px rgba(0,0,0,0.6);
        pointer-events: auto;
        border: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        box-sizing: border-box;
        transition: max-height 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
        overflow-y: scroll;
    }
    
    #ui-container.collapsed {
        max-height: 130px;
        overflow-y: hidden;
    }
    
    .drawer-handle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 80px;
        cursor: pointer;
        z-index: 20;
    }

    .handle-text {
        font-size: 14px;
        font-weight: 600;
        color: rgba(255, 255, 255, 0.7);
        text-transform: uppercase;
        letter-spacing: 1px;
        background: rgba(255, 255, 255, 0.1);
        padding: 8px 24px;
        border-radius: 24px;
    }

    .header {
        margin-top: 10px;
    }

    .desktop-title {
        display: none;
    }

    #btn-upload-header {
        display: inline-block;
        margin-right: auto;
        align-self: center;
        min-height: 38px;
        line-height: 38px;
        padding: 0 20px;
        border-radius: 19px;
        font-size: 13px;
        position: relative;
        z-index: 30; /* Bring above drawer handle */
    }

    #btn-lang {
        position: relative;
        z-index: 30;
    }

    .panel-desktop-only {
        display: none;
    }

    button, input[type="file"], input[type="range"], select {
        min-height: 48px;
        font-size: 14px;
        border-radius: 10px;
    }
    
    .panel {
        background: rgba(40, 40, 40, 0.6);
        border: 1px solid rgba(255,255,255,0.05);
        border-radius: 16px;
        padding: 15px;
        box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
        margin-bottom: 15px;
    }

    .subtitle {
        display: none; /* Hide long subtitle on mobile to save space */
    }
}

