* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: flex;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #1a1a1e;
    color: #e0e0e6;
}

/* Left Sidebar Panel */
#sidebar {
    width: 350px;
    min-width: 300px;
    flex-shrink: 0;
    height: 100%;
    background: #242429;
    border-right: 1px solid #36363d;
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 20px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.3);
}

kbd {
    background-color: #2a2a30;
    border: 1px solid #4a4a52;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.2);
    color: #e0e0e0;
    display: inline-block;
    font-size: 0.85em;
    font-weight: 600;
    line-height: 1;
    padding: 2px 5px;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #ffffff;
    border-bottom: 2px solid #3b82f6;
    padding-bottom: 8px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.slider-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    font-weight: 500;
}

.slider-header span.axis-x {
    color: #ef4444;
}

.slider-header span.axis-y {
    color: #3b82f6;
}

.slider-header span.axis-z {
    color: #10b981;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #36363d;
    outline: none;
    accent-color: #3b82f6;
    cursor: pointer;
}

/* Matrix Display Box */
.matrix-box {
    background: #18181b;
    border: 1px solid #3f3f46;
    border-radius: 8px;
    padding: 16px;
}

.matrix-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    text-align: center;
    font-family: "Courier New", Courier, monospace;
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.matrix-cell {
    background: #27272a;
    padding: 8px 4px;
    border-radius: 4px;
    border: 1px solid #3f3f46;
    color: #85f1e8;
}

/* Buttons */
.btn {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
}

.btn:hover {
    background: #2563eb;
}

.btn-secondary {
    background: #374151;
    margin-top: 8px;
}

.btn-secondary:hover {
    background: #4b5563;
}

/* Right 3D Canvas Area */
#canvas-container {
    flex: 1;
    height: 100%;
    position: relative;
}

#loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.1rem;
    font-weight: 500;
    color: #9ca3af;
    background: rgba(0, 0, 0, 0.7);
    padding: 12px 24px;
    border-radius: 8px;
    pointer-events: none;
    z-index: 5;
    border: 1px solid #36363d;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #242429;
    border: 1px solid #3f3f46;
    border-radius: 12px;
    width: 90%;
    max-width: 750px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #3f3f46;
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.modal-header h3 {
    text-align: center !important;
    font-size: 1.5rem;
    color: #ffffff;
}

.modal-body {
    font-size: 1rem;
    line-height: 1.6;
    color: #d1d5db;
}

.modal-body p {
    margin-bottom: 12px;
}

.modal-footer {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.modal-footer .btn {
    width: auto;
    padding: 8px 20px;
}

a {
    color: #3b82f6;
    text-decoration: none;
}

a:hover {
    color: #a4bee7;
}

input[type=range] {
    width: 100%;
    margin: 7.75px 0;
    background-color: transparent;
    -webkit-appearance: none;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
    background: #e9e9e9;
    border: 1px solid #010101;
    border-radius: 6.2px;
    width: 100%;
    height: 6.5px;
    cursor: pointer;
}

input[type=range]::-webkit-slider-thumb {
    margin-top: -8.75px;
    width: 22px;
    height: 22px;
    background: #066bd1;
    border: 1.2px solid #000000;
    border-radius: 50px;
    cursor: pointer;
    -webkit-appearance: none;
}

input[type=range]:focus::-webkit-slider-runnable-track {
    background: #f6f6f6;
}

input[type=range]::-moz-range-track {
    background: #e9e9e9;
    border: 1px solid #010101;
    border-radius: 6.2px;
    width: 100%;
    height: 6.5px;
    cursor: pointer;
}

input[type=range]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    background: #066bd1;
    border: 1.2px solid #000000;
    border-radius: 50px;
    cursor: pointer;
}

input[type=range]::-ms-track {
    background: transparent;
    border-color: transparent;
    border-width: 8.75px 0;
    color: transparent;
    width: 100%;
    height: 6.5px;
    cursor: pointer;
}

input[type=range]::-ms-fill-lower {
    background: #dcdcdc;
    border: 1px solid #010101;
    border-radius: 12.4px;
}

input[type=range]::-ms-fill-upper {
    background: #e9e9e9;
    border: 1px solid #010101;
    border-radius: 12.4px;
}

input[type=range]::-ms-thumb {
    width: 22px;
    height: 22px;
    background: #066bd1;
    border: 1.2px solid #000000;
    border-radius: 50px;
    cursor: pointer;
    margin-top: 0px;
    /*Needed to keep the Edge thumb centred*/
}

input[type=range]:focus::-ms-fill-lower {
    background: #e9e9e9;
}

input[type=range]:focus::-ms-fill-upper {
    background: #f6f6f6;
}

/*TODO: Use one of the selectors from https://stackoverflow.com/a/20541859/7077589 and figure out
how to remove the virtical space around the range input in IE*/
@supports (-ms-ime-align:auto) {

    /* Pre-Chromium Edge only styles, selector taken from hhttps://stackoverflow.com/a/32202953/7077589 */
    input[type=range] {
        margin: 0;
        /*Edge starts the margin from the thumb, not the track as other browsers do*/
    }
}

/* Responsive adjustment */
@media (max-width: 990px) {
    body {
        flex-direction: column;
    }

    #canvas-container {
        width: 100%;
        height: 50vh;
        min-height: 300px;
        order: -1; /* Keeps 3D viewport on top on mobile screens */
    }

    #sidebar {
        width: 100%;
        height: 45%;
    }
}