* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #0f0f1a;
    color: #e0e0e0;
    overflow: hidden;
}

#app {
    display: flex;
    height: 100vh;
}

#sidebar {
    width: 320px;
    background: #1a1a2e;
    padding: 20px;
    overflow-y: auto;
    border-right: 1px solid #2d2d44;
}

#sidebar h1 {
    font-size: 1.5rem;
    margin-bottom: 4px;
    color: #fff;
}

.subtitle {
    color: #888;
    font-size: 0.85rem;
    margin-bottom: 20px;
}

.site-logo {
    display: inline-block;
    margin-bottom: 12px;
}

.site-logo img {
    height: 24px;
    width: auto;
}

.drop-zone {
    border: 2px dashed #4a4a6a;
    border-radius: 12px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
    position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: #00ff88;
    background: rgba(0, 255, 136, 0.1);
}

.drop-zone-content {
    pointer-events: none;
}

.drop-zone svg {
    color: #00ff88;
    margin-bottom: 12px;
}

.drop-zone p {
    margin-bottom: 4px;
}

.drop-zone .hint {
    font-size: 0.8rem;
    color: #666;
}

.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-list {
    margin-bottom: 20px;
}

.file-list h3 {
    font-size: 0.9rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.file-list ul {
    list-style: none;
}

.file-list li {
    padding: 8px 12px;
    background: #252540;
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-list li:hover {
    background: #2d2d50;
}

.file-list li.active {
    background: #00ff88;
    color: #000;
}

.file-list li .file-size {
    font-size: 0.75rem;
    color: #888;
}

.file-list li.active .file-size {
    color: rgba(0, 0, 0, 0.6);
}

.info-panel {
    background: #252540;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.info-panel h3 {
    font-size: 0.9rem;
    margin-bottom: 12px;
    color: #fff;
}

#info-content {
    font-size: 0.85rem;
    line-height: 1.6;
}

#info-content .info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

#info-content .info-label {
    color: #888;
}

/* Surface Materials Panel */
#surface-materials {
    overflow: hidden;
}

.surface-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.surface-header h3 {
    margin: 0;
    font-size: 0.9rem;
    color: #fff;
}

.surface-actions {
    display: flex;
    gap: 4px;
}

.btn-small {
    padding: 4px 8px;
    font-size: 0.7rem;
    background: #3d3d5c;
    color: #ccc;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-small:hover {
    background: #4d4d6c;
}

#surface-list {
    list-style: none;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 220px;
    margin: 0;
    padding: 0;
    padding-right: 4px;
}

#surface-list li {
    margin-bottom: 2px;
}

#surface-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: #1a1a2e;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.8rem;
}

#surface-list label:hover {
    background: #252540;
}

#surface-list input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #00ff88;
    flex-shrink: 0;
}

.surface-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.surface-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.surface-group {
    color: #888;
    font-size: 0.65rem;
    flex-shrink: 0;
    padding: 1px 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    margin-right: 4px;
}

.surface-count {
    color: #666;
    font-size: 0.7rem;
    flex-shrink: 0;
    min-width: 20px;
    text-align: right;
}

#surface-list::-webkit-scrollbar {
    width: 6px;
}

#surface-list::-webkit-scrollbar-track {
    background: #1a1a2e;
    border-radius: 3px;
}

#surface-list::-webkit-scrollbar-thumb {
    background: #3d3d5c;
    border-radius: 3px;
}

#surface-list::-webkit-scrollbar-thumb:hover {
    background: #4d4d6c;
}

#controls h3 {
    font-size: 0.9rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    margin-top: 16px;
}

#controls h3:first-child {
    margin-top: 0;
}

.control-group {
    margin-bottom: 12px;
}

.control-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    cursor: pointer;
}

.control-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #00ff88;
}

.control-group input[type="color"] {
    width: 100%;
    height: 32px;
    border: 1px solid #3d3d5c;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 4px;
    background: #252540;
    padding: 4px;
}

.control-group input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.control-group input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.color-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
}

.color-box.green { background: #00ff88; }
.color-box.cyan { background: #00ffff; }
.color-box.yellow { background: #ffff00; }
.color-box.purple { background: #ff00ff; }

.btn {
    width: 100%;
    padding: 10px 16px;
    background: #00ff88;
    color: #000;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    margin-top: 12px;
}

.btn:hover {
    background: #00dd77;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:disabled:hover {
    background: #00ff88;
}

.btn-primary {
    background: #00ff88;
    color: #000;
}

.btn-primary:hover {
    background: #00dd77;
}

.btn-secondary {
    background: #3d3d5c;
    color: #e0e0e0;
}

.btn-secondary:hover {
    background: #4d4d6c;
}

.btn-danger {
    background: #ff4444;
    color: #fff;
}

.btn-danger:hover {
    background: #dd3333;
}

.model-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.model-actions .btn {
    flex: 1;
    margin-top: 0;
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #888;
    margin-top: 8px;
    cursor: pointer;
}

.checkbox-inline input {
    width: 14px;
    height: 14px;
    accent-color: #00ff88;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #1a1a2e;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid #2d2d44;
}

.modal-content h3 {
    margin-bottom: 8px;
    color: #fff;
}

.modal-content p {
    color: #888;
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.modal-content ul {
    list-style: none;
    margin-bottom: 16px;
}

.modal-content li {
    padding: 10px 12px;
    background: #252540;
    border-radius: 6px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-content li:hover {
    background: #3d3d5c;
}

.modal-content li .version-tag {
    font-size: 0.7rem;
    color: #888;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
}

.modal-actions .btn {
    width: auto;
    padding: 8px 16px;
}

#viewport {
    flex: 1;
    position: relative;
    background: #1a1a2e;
}

#canvas {
    width: 100%;
    height: 100%;
    display: block;
}

#loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 15, 26, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #2d2d44;
    border-top-color: #00ff88;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#stats {
    position: absolute;
    bottom: 16px;
    left: 16px;
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: #888;
    background: rgba(26, 26, 46, 0.9);
    padding: 8px 12px;
    border-radius: 6px;
}

.credits {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #2d2d44;
    font-size: 0.75rem;
    color: #666;
    text-align: center;
}

.credits a {
    color: #888;
    text-decoration: none;
    transition: color 0.2s;
}

.credits a:hover {
    color: #00ff88;
}

.credits a.author {
    color: #00ff88;
    font-weight: 500;
}

.credits a.author:hover {
    text-decoration: underline;
}

#sidebar::-webkit-scrollbar {
    width: 8px;
}

#sidebar::-webkit-scrollbar-track {
    background: #1a1a2e;
}

#sidebar::-webkit-scrollbar-thumb {
    background: #3d3d5c;
    border-radius: 4px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
    background: #4d4d6c;
}

/* Responsive - Tablet */
@media (max-width: 900px) {
    body {
        overflow: auto;
    }

    #app {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    #sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #2d2d44;
        padding: 16px;
    }

    #sidebar h1 {
        font-size: 1.25rem;
    }

    #viewport {
        min-height: 50vh;
        height: 50vh;
    }

    .credits {
        display: none;
    }
}

/* Responsive - Mobile */
@media (max-width: 640px) {
    #sidebar {
        padding: 12px;
    }

    #sidebar h1 {
        font-size: 1.1rem;
    }

    .subtitle {
        font-size: 0.8rem;
        margin-bottom: 12px;
    }

    .drop-zone {
        padding: 20px 16px;
        margin-bottom: 12px;
    }

    .drop-zone svg {
        width: 36px;
        height: 36px;
    }

    .file-list li {
        padding: 12px;
    }

    .info-panel {
        padding: 12px;
        margin-bottom: 12px;
    }

    .control-group label {
        font-size: 0.8rem;
    }

    .control-group input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }

    .control-group input[type="color"] {
        height: 40px;
    }

    .btn {
        padding: 14px 16px;
        font-size: 0.85rem;
    }

    #viewport {
        min-height: 45vh;
        height: 45vh;
    }

    #stats {
        bottom: 12px;
        left: 12px;
        font-size: 0.7rem;
        padding: 6px 10px;
        gap: 12px;
    }
}

/* Very small phones */
@media (max-width: 380px) {
    #sidebar {
        padding: 10px;
    }

    .site-logo img {
        height: 20px;
    }

    .drop-zone {
        padding: 16px 12px;
    }

    .file-list li {
        padding: 10px;
        font-size: 0.8rem;
    }

    .file-list li .file-size {
        display: none;
    }
}
