:root {
    /* System Colors */
    --sys-bg: #ece9d8;
    --sys-text: #000000;
    --sys-highlight: #316ac5;
    --sys-highlight-text: #ffffff;

    /* Blender-esque Accents */
    --blender-orange: #eb7d00; 
    --blender-grey: #727272;
    --viewport-bg: #bfbfbf;

    /* 3D Borders */
    --border-light: #ffffff;
    --border-shadow: #aca899;
    --border-dark: #404040;
    
    /* Layout Dimensions */
    --sidebar-width: 250px;
    --header-height: 36px;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--sys-bg);
    color: var(--sys-text);
    font-family: "Segoe UI", "Tahoma", sans-serif;
    height: 100vh;
    overflow: hidden;
    font-size: 11px;
}

/* --- GRID LAYOUT --- */
.app-container {
    display: grid;
    /* Sidebar is adjustable via class, default is open */
    grid-template-columns: var(--sidebar-width) 1fr; 
    height: 100%;
    padding: 4px;
    gap: 4px;
    transition: grid-template-columns 0.3s ease;
}

/* Collapsed State */
.app-container.collapsed {
    grid-template-columns: 0px 1fr;
    gap: 0;
}

/* --- GENERIC PANELS --- */
.panel-3d {
    background: var(--sys-bg);
    border: 1px solid var(--border-shadow);
    display: flex;
    flex-direction: column;
    box-shadow: 
        inset 1px 1px 0 var(--border-light),
        1px 1px 0 var(--border-dark);
    overflow: hidden;
}

.sunked-panel {
    border: 1px solid;
    border-color: var(--border-shadow) var(--border-light) var(--border-light) var(--border-shadow);
    background: #ffffff;
}

/* --- SIDEBAR --- */
.sidebar { 
    padding: 2px; 
    min-width: var(--sidebar-width); /* Prevent content squishing during transition */
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.panel-header {
    background: linear-gradient(to right, #808080, #b0b0b0);
    padding: 4px 6px;
    color: #fff;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.panel-header h3 { margin: 0; font-size: 11px; letter-spacing: 1px; }

/* Settings Area */
.settings-group {
    padding: 4px;
    border: 1px solid var(--border-shadow);
    margin-bottom: 4px;
}
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.setting-row select {
    width: 100px;
    font-size: 10px;
}

.file-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1;
    overflow-y: auto;
    background-color: #fff;
}

.file-list li {
    padding: 4px 6px; /* Larger hit area */
    cursor: pointer;
    border-bottom: 1px dotted #ddd;
    display: flex;
    align-items: center;
}
.file-list li:hover { background-color: #e0e0e0; }
.file-list li.active {
    background-color: var(--blender-orange);
    color: white;
}

.btn-sys {
    display: block;
    text-align: center;
    background: var(--sys-bg);
    border: 2px outset var(--sys-bg);
    padding: 6px;
    cursor: pointer;
    color: #000;
    font-size: 11px;
}
.btn-sys:active { border-style: inset; }
input[type="file"] { display: none; }

/* --- VIEWPORT --- */
.viewport {
    position: relative;
    background-color: var(--viewport-bg);
    background: radial-gradient(circle at center, #d0d0d0 0%, #a0a0a0 100%);
}

.viewport-overlay-header {
    position: absolute;
    top: 8px; left: 8px; right: 8px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none; 
    z-index: 10;
}

.header-left, .header-right {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Sidebar Toggle Button */
.btn-toggle-sidebar {
    background: var(--sys-bg);
    border: 1px outset var(--border-light);
    width: 28px; 
    height: 28px;
    display: flex; 
    align-items: center; 
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    margin-bottom: 4px;
    box-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}
.btn-toggle-sidebar:active { border-style: inset; }

.label-text {
    display: block;
    font-weight: bold;
    color: #333;
    font-size: 14px;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.5);
}

.meta-tag {
    background: rgba(0,0,0,0.5);
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    align-self: flex-end;
}

.btn-action {
    display: inline-block;
    background: var(--blender-orange);
    color: #fff;
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 2px;
    font-size: 10px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    border: none;
    cursor: pointer;
    text-align: center;
}
.btn-action:hover { background: #ff951c; }
.btn-action.secondary {
    background: #666;
    margin-top: 2px;
}

.canvas-wrapper {
    width: 100%;
    height: 100%;
    cursor: grab;
}
.canvas-wrapper:active { cursor: grabbing; }

.viewport-footer {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: var(--sys-bg);
    border-top: 1px solid var(--border-shadow);
    padding: 2px 6px;
    font-size: 10px;
    color: #555;
}

/* --- SECURITY MODAL --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000; /* Above everything */
    backdrop-filter: grayscale(100%) blur(2px);
}

.modal-window {
    width: 320px;
    max-width: 90%;
    background: var(--sys-bg);
    padding: 3px;
}

.modal-window .panel-header {
    background: linear-gradient(to right, #0a246a, #a6caf0); /* Win98 Active Title Bar */
}

.btn-close {
    background: #d4d0c8;
    border: 1px outset #fff;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    width: 16px; height: 16px;
    display: flex; justify-content: center; align-items: center;
    padding: 0;
}
.btn-close:active { border-style: inset; }

.modal-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-text {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 11px;
}

.icon-warning {
    font-size: 24px;
    color: #ffcc00;
    text-shadow: 1px 1px 0 #000;
}

/* Captcha Styling */
.captcha-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    background: #fff;
}

.captcha-display {
    font-family: "Courier New", monospace;
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 4px;
    color: #000;
    background: repeating-linear-gradient(
        45deg,
        #fff,
        #fff 2px,
        #eee 2px,
        #eee 4px
    ); /* Noise texture */
    padding: 4px 12px;
    border: 1px solid #ccc;
    user-select: none;
    transform: skewX(-5deg);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
}

.input-group input[type="text"] {
    padding: 4px;
    border: 1px inset #fff;
    font-family: "Courier New", monospace;
    text-transform: uppercase;
}

.error-msg {
    color: red;
    font-weight: bold;
    text-align: center;
    background: #ffebeb;
    border: 1px solid red;
    padding: 2px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 8px;
    border-top: 1px solid var(--border-shadow);
}

.modal-footer button {
    min-width: 70px;
}

/* --- MOBILE OPTIMIZATION --- */
@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr; 
    }

    .app-container.collapsed {
        grid-template-columns: 1fr; 
    }

    .sidebar {
        position: absolute;
        top: 0; left: 0; bottom: 0;
        width: 80%;
        max-width: 300px;
        z-index: 100;
        box-shadow: 4px 0 10px rgba(0,0,0,0.5);
        transform: translateX(0);
        transition: transform 0.3s ease;
    }

    .app-container.collapsed .sidebar {
        transform: translateX(-100%);
    }
    
    .viewport-overlay-header {
        top: 10px; left: 10px; right: 10px;
    }
    
    .btn-toggle-sidebar {
        width: 36px; height: 36px; font-size: 18px;
    }
}