* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Arial, sans-serif;
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 22px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-info {
    font-size: 14px;
    color: #666;
    background: #f8f9fa;
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid #e9ecef;
}

.container {
    display: flex;
    flex: 1;
    padding: 20px;
    gap: 20px;
    height: calc(100vh - 70px);
}

.viewer-container {
    flex: 3;
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    position: relative;
}

#viewer {
    width: 100%;
    height: 100%;
    outline: none;
}

.controls-panel {
    flex: 1;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 320px;
    overflow-y: auto;
}

.panel-section {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 15px;
    border: 1px solid #e9ecef;
}

.section-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 8px;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.2);
}

.button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.3);
}

.button:active {
    transform: translateY(0);
}

.file-input-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: 6px;
}

.file-input-wrapper input[type=file] {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.control-btn {
    background: #e9ecef;
    color: #495057;
    border: 2px solid #dee2e6;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    font-size: 12px;
    font-weight: 500;
}

.control-btn:hover {
    background: #dee2e6;
    border-color: #adb5bd;
}

.control-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.3);
}

.explosion-slider {
    margin-top: 10px;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.slider-container input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #dee2e6;
    outline: none;
    -webkit-appearance: none;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.slider-value {
    min-width: 30px;
    text-align: center;
    font-weight: 600;
    color: #667eea;
}

.parts-list-container {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 5px;
    background: white;
}

.parts-list {
    list-style: none;
}

.parts-list li {
    padding: 10px 12px;
    background: white;
    margin-bottom: 4px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.parts-list li:hover {
    background: #f8f9fa;
    border-color: #e9ecef;
    transform: translateX(2px);
}

.parts-list li.selected {
    background: rgba(102, 126, 234, 0.1);
    border-color: rgba(102, 126, 234, 0.3);
}

.parts-list li.hidden {
    opacity: 0.5;
    background: rgba(220, 53, 69, 0.1);
    border-color: rgba(220, 53, 69, 0.3);
}

.part-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.part-name {
    font-size: 13px;
    color: #495057;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.part-visibility {
    color: #667eea;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.part-visibility:hover {
    background: rgba(102, 126, 234, 0.1);
}

.file-info {
    background: white;
    padding: 12px;
    border-radius: 6px;
    margin-top: 10px;
    font-size: 13px;
    border: 1px solid #e9ecef;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    display: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid #e9ecef;
    border-radius: 50%;
    border-top-color: #667eea;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

.drop-zone {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 3px dashed #667eea;
    background: rgba(102, 126, 234, 0.05);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.drop-zone.active {
    opacity: 1;
    pointer-events: all;
}

.drop-zone-content {
    text-align: center;
    padding: 30px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.drop-zone i {
    font-size: 48px;
    color: #667eea;
    margin-bottom: 15px;
}

.error-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(220, 53, 69, 0.95);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    z-index: 90;
    display: none;
    max-width: 400px;
    color: white;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.model-stats {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    color: #495057;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: none;
}

.instructions {
    position: absolute;
    bottom: 15px;
    left: 15px;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 15px;
    border-radius: 6px;
    font-size: 12px;
    max-width: 300px;
    color: #495057;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.model-image {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    border: 2px solid #dee2e6;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-10px); }
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.part-info {
    position: relative;
}

.part-info .tooltip {
    visibility: hidden;
    width: max-content;
    max-width: 200px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px 10px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 12px;
    white-space: normal;
}

.part-info:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    animation: fadeIn 0.3s ease;
    color: white;
    font-weight: 500;
}

.notification.success {
    background: #28a745;
}

.notification.error {
    background: #dc3545;
}

.notification.info {
    background: #17a2b8;
}

.screenshot-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 250px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.2);
    z-index: 1000;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 2px solid #667eea;
    animation: slideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
}

.screenshot-notification img {
    width: 100%;
    height: 120px;
    object-fit: contain;
    border-radius: 6px;
    margin-bottom: 10px;
    border: 1px solid #dee2e6;
}

.screenshot-notification div {
    font-size: 14px;
    color: #495057;
    text-align: center;
    font-weight: 500;
    margin-bottom: 10px;
}

.screenshot-notification button {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.screenshot-notification button:hover {
    background: #764ba2;
    transform: translateY(-1px);
}

#screenshotDialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

#screenshotDialog .dialog-content {
    background: white;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: scaleIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#screenshotDialog input[type="radio"] {
    accent-color: #667eea;
}

#screenshotDialog select:focus,
#screenshotDialog input[type="range"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#screenshotDialog label {
    cursor: pointer;
}

#screenshotDialog .button {
    transition: all 0.2s;
}

#screenshotDialog .button:hover {
    transform: translateY(-2px);
}

.zoom-control {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    margin-top: 10px;
    border: 1px solid #e9ecef;
}

.zoom-control .section-title {
    margin-bottom: 8px;
}

.zoom-slider {
    display: flex;
    align-items: center;
    gap: 10px;
}

.zoom-slider input[type="range"] {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #667eea, #764ba2);
    outline: none;
    -webkit-appearance: none;
}

.zoom-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    border: 2px solid #667eea;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.zoom-value {
    min-width: 40px;
    text-align: center;
    font-weight: 600;
    color: #667eea;
    font-size: 14px;
}

#screenshotBtn {
    position: relative;
    overflow: hidden;
}

#screenshotBtn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.2));
    opacity: 0;
    transition: opacity 0.3s;
}

#screenshotBtn:hover::after {
    opacity: 1;
}

.parts-list li.selected::before {
    content: '→';
    color: #667eea;
    font-weight: bold;
    margin-right: 8px;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.performance-chart {
    position: absolute;
    top: 15px;
    left: 15px;
    width: 180px;
    height: 60px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 6px;
    padding: 8px;
    z-index: 90;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    font-family: 'Segoe UI', monospace;
    color: white;
}

.performance-chart:hover {
    width: 250px;
    height: 120px;
    background: rgba(0, 0, 0, 0.85);
}

.performance-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: #a0a0a0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 4px;
}

.performance-chart canvas {
    width: 100%;
    height: 30px;
    border-radius: 3px;
}

.performance-info {
    display: none;
    margin-top: 8px;
    font-size: 10px;
}

.performance-chart:hover .performance-info {
    display: block;
}

.performance-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
    padding: 2px 4px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.05);
}

.performance-metric.cpu {
    border-left: 3px solid #4CAF50;
}

.performance-metric.gpu {
    border-left: 3px solid #2196F3;
}

.performance-metric.fps {
    border-left: 3px solid #FF9800;
}

.performance-metric.memory {
    border-left: 3px solid #9C27B0;
}

.metric-label {
    color: #ccc;
    font-weight: 500;
}

.metric-value {
    color: white;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.performance-warning {
    background: rgba(255, 193, 7, 0.2);
    border-left: 3px solid #FFC107;
    animation: pulse 2s infinite;
}

.performance-critical {
    background: rgba(244, 67, 54, 0.2);
    border-left: 3px solid #F44336;
    animation: pulse 1s infinite;
}

.performance-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 11px;
    pointer-events: none;
    z-index: 1000;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    max-width: 200px;
    white-space: nowrap;
    display: none;
}

.performance-tooltip::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid rgba(0, 0, 0, 0.9);
}

@media (max-width: 1024px) {
    .container {
        flex-direction: column;
        height: auto;
    }

    .controls-panel {
        max-width: 100%;
    }

    .viewer-container {
        height: 500px;
    }

    .instructions {
        display: none;
    }

    .model-stats {
        top: 10px;
        right: 10px;
        font-size: 10px;
        padding: 6px 10px;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        padding: 15px;
    }

    .header h1 {
        font-size: 18px;
    }

    .header-info {
        font-size: 12px;
        width: 100%;
    }

    .container {
        padding: 10px;
        gap: 15px;
    }

    .controls-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .button {
        padding: 10px 14px;
        font-size: 14px;
    }

    .section-title {
        font-size: 14px;
    }

    .parts-list li {
        padding: 8px 10px;
    }
    
    .performance-chart {
        width: 140px;
        height: 50px;
        padding: 6px;
    }
    
    .performance-chart:hover {
        width: 200px;
        height: 100px;
    }
    
    .performance-chart-header {
        font-size: 9px;
    }
    
    .performance-info {
        font-size: 9px;
    }
}

@media (max-width: 480px) {
    .controls-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .control-btn {
        padding: 8px;
        font-size: 10px;
    }

    .control-btn i {
        font-size: 14px;
    }

    .panel-section {
        padding: 12px;
    }

    .button-group {
        gap: 8px;
    }
    
    .performance-chart {
        width: 120px;
        height: 45px;
        top: 10px;
        left: 10px;
    }
    
    .performance-chart:hover {
        width: 180px;
        height: 90px;
    }
}

.parts-list-container::-webkit-scrollbar {
    width: 8px;
}

.parts-list-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.parts-list-container::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.parts-list-container::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

.viewer-container {
    transition: all 0.3s ease;
}

.controls-panel, .viewer-container, .panel-section {
    transition: box-shadow 0.3s ease;
}

.controls-panel:hover, .viewer-container:hover, .panel-section:hover {
    box-shadow: 0 12px 24px rgba(0,0,0,0.15);
}

.loading-overlay.alternative .loading-spinner {
    border: 3px solid rgba(102, 126, 234, 0.2);
    border-top-color: #667eea;
    border-right-color: #764ba2;
    animation: spin 1s linear infinite;
}

.progress-bar {
    width: 200px;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    margin-top: 15px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 0%;
}

.button.important {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    box-shadow: 0 4px 6px rgba(231, 76, 60, 0.2);
}

.button.important:hover {
    box-shadow: 0 6px 12px rgba(231, 76, 60, 0.3);
}

.button.success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    box-shadow: 0 4px 6px rgba(40, 167, 69, 0.2);
}

.button.success:hover {
    box-shadow: 0 6px 12px rgba(40, 167, 69, 0.3);
}

.button[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 10;
    margin-bottom: 5px;
}

.button[title]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
    z-index: 10;
    margin-bottom: -5px;
}
