/* Global Texture Resolution Dropdown Styling - Dark Theme with Enhanced Interactivity */
#texture_resolution,
#texture_resolution_setting select,
.format-select {
    background: linear-gradient(135deg, #222222, #252525) !important; /* Subtle gradient for depth */
    color: #ffffff !important; /* White text like rest of app */
    border: 1px solid #333333 !important; /* Match app's border style */
    border-radius: 8px !important;
    padding: 10px 12px !important;
    font-size: 14px !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important; /* Smooth interactive transition */
    -webkit-appearance: none !important;
    appearance: none !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.1) !important; /* Depth shadow + inner highlight */
    position: relative !important;
    min-height: 44px !important; /* Touch-friendly minimum height */
    width: 100% !important; /* Always respect container width */
    max-width: 100% !important; /* Never exceed container boundaries */
    min-width: 0 !important; /* Allow shrinking if container is small */
    box-sizing: border-box !important; /* Include padding and border in width calculation */
}

/* Add dropdown arrow for clarity */
#texture_resolution::after,
#texture_resolution_setting select::after,
.format-select::after {
    content: '▼' !important;
    position: absolute !important;
    right: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    color: #888888 !important;
    font-size: 10px !important;
    pointer-events: none !important;
    transition: all 0.2s ease !important;
}

/* Hover state - more prominent feedback */
#texture_resolution:hover:not(:disabled),
#texture_resolution_setting select:hover:not(:disabled),
.format-select:hover:not(:disabled) {
    background: linear-gradient(135deg, #252525, #2a2a2a) !important;
    border-color: #00d4aa !important; /* Show accent color on hover */
    transform: translateY(-1px) !important; /* Subtle lift effect */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 212, 170, 0.2) !important; /* Enhanced shadow + accent glow */
}

/* Active/pressed state for touch feedback */
#texture_resolution:active,
#texture_resolution_setting select:active,
.format-select:active {
    transform: translateY(0px) !important; /* Remove lift on press */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), inset 0 2px 4px rgba(0, 0, 0, 0.1) !important; /* Pressed-in effect */
    background: linear-gradient(135deg, #1a1a1a, #222222) !important; /* Darker when pressed */
}

/* Focus state - clear interactive feedback */
#texture_resolution:focus,
#texture_resolution_setting select:focus,
.format-select:focus {
    outline: none !important;
    border-color: #00d4aa !important; /* App's teal accent color */
    background: linear-gradient(135deg, #252525, #2a2a2a) !important;
    box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.3), 0 4px 8px rgba(0, 0, 0, 0.15) !important; /* Prominent focus ring */
    transform: translateY(-1px) !important;
}

/* Option styling for dark theme */
#texture_resolution option,
#texture_resolution_setting select option,
.format-select option {
    background: #222222 !important;
    color: #ffffff !important;
    border: none !important;
    padding: 8px 12px !important;
}

/* Disabled state */
#texture_resolution:disabled,
#texture_resolution_setting select:disabled,
.format-select:disabled {
    background: #2a2a2a !important;
    color: #555555 !important;
    border-color: #333333 !important;
    cursor: not-allowed !important;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        width: 260px;
    }
    
    .loading-card {
        min-width: 280px;
        padding: 30px;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 50vh;
        overflow-y: auto;
    }
    
    .top-bar {
        height: 40px;
        padding: 0 12px;
    }
    
    .tab {
        padding: 0 12px;
        font-size: 11px;
    }
    
    .loading-card {
        min-width: 250px;
        padding: 24px;
        margin: 20px;
    }
    
    .main-loading-spinner {
        width: 40px;
        height: 40px;
    }
    
    .loading-title {
        font-size: 16px;
    }
    
    /* Mobile modal adjustments */
    .modal {
        margin: 20px;
        padding: 24px;
        max-width: none;
    }
    
    .triangle-limit-modal {
        margin: 20px;
        padding: 24px;
        max-width: none;
    }
    
    .triangle-limit-header {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .modal-btn {
        margin-bottom: 8px;
    }
    
    .modal-btn:last-child {
        margin-bottom: 0;
    }
    
    /* Mobile viewer adjustments */
    .viewer-container {
        min-height: 300px;
    }
    
    .placeholder-icon {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
    
    .placeholder-text {
        font-size: 13px;
    }
    
    .placeholder-subtext {
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .logo {
        padding: 16px;
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }
    
    .logo-text h1 {
        font-size: 16px;
    }
    
    .upload-section {
        padding: 16px;
    }

    .upload-area {
        padding: 24px 16px;
    }
    
    .upload-icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .upload-text {
        font-size: 13px;
    }
    
    .upload-subtext {
        font-size: 11px;
    }
    
    .section-header {
        padding: 16px;
    }
    
    .section-content {
        padding: 0 16px 16px 16px;
    }
    
    .setting-group {
        margin-bottom: 20px;
    }
    
    .slider-input-row {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }
    
    .slider-value-input {
        width: 100%;
    }
    
    .btn {
        padding: 14px 16px;
        font-size: 14px;
    }
    
    .view-controls {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .license-key-btn {
        padding: 4px 8px;
        font-size: 10px;
    }
    
    .view-btn {
        padding: 4px 8px;
        font-size: 10px;
    }
    
    .topology-controls {
        padding: 4px 8px;
    }
    
    .topology-label {
        font-size: 10px;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .top-bar,
    .modal-overlay {
        display: none !important;
    }
    
    .main-content {
        width: 100% !important;
        height: 100vh !important;
    }
    
    .viewer-container {
        border: 1px solid #ccc;
    }
}

/* High DPI / Retina displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .upload-icon,
    .placeholder-icon,
    .logo-icon {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .loading-progress-fill::after {
        animation: none;
    }
    
    .main-loading-spinner {
        animation: none;
        border-top-color: #00d4aa;
    }
}

/* iPad Portrait (768px width) */
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: portrait) {
    /* Main container adjustments */
    .app-container {
        flex-direction: column;
        height: 100vh;
        height: -webkit-fill-available;
        overflow: hidden;
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
    }
    
    /* Sidebar becomes horizontal top bar */
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 50vh;
        flex-shrink: 0;
        border-right: none;
        border-bottom: 1px solid #333;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Adjust logo for horizontal layout */
    .logo {
        padding: 12px 20px;
        border-bottom: 1px solid #333;
    }
    
    .logo-icon {
        width: 40px;
        height: 40px;
    }
    
    .logo-text h1 {
        font-size: 20px;
    }
    
    /* Upload section more compact */
    .upload-section {
        padding: 16px;
    }
    
    .upload-area {
        min-height: 100px;
        padding: 16px;
    }
    
    .upload-icon {
        font-size: 32px;
    }
    
    .upload-text {
        font-size: 16px;
        margin-top: 8px;
    }
    
    .upload-subtext {
        font-size: 13px;
    }
    
    /* Sidebar sections in grid layout */
    .sidebar-scroll {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        padding: 16px;
        max-height: none;
    }
    
    /* Collapsible sections span full width when expanded */
    .collapsible-section.expanded {
        grid-column: 1 / -1;
    }
    
    /* Main content takes remaining space */
    .main-content {
        flex: 1;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        margin-bottom: 0;
        padding-bottom: 0;
    }
    
    /* Top bar adjustments */
    .top-bar {
        padding: 12px 16px;
        flex-shrink: 0;
    }
    
    .view-tabs {
        gap: 8px;
    }
    
    .tab {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    .view-controls {
        gap: 12px;
    }
    
    .license-key-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .topology-controls {
        font-size: 12px;
    }
    
    /* Viewer container takes remaining space */
    .viewer-container {
        flex: 1;
        min-height: 0;
        margin-bottom: 0;
        padding-bottom: 0;
    }
    
    /* Loading overlay adjustments */
    .loading-card {
        width: 90%;
        max-width: 400px;
        padding: 24px;
    }
    
    /* Settings sections more compact */
    .setting-group {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .setting-label {
        font-size: 13px;
    }
    
    /* Sliders touch-friendly */
    .slider {
        height: 32px;
    }
    
    .slider-value-input {
        font-size: 14px;
        padding: 6px;
    }
    
    /* Buttons touch-friendly */
    .btn {
        min-height: 44px;
        font-size: 14px;
        padding: 10px 20px;
    }
    
    /* Model explorer adjustments */
    .model-tree {
        max-height: 200px;
    }
    
    /* Stats more compact */
    .mesh-stats-compact {
        padding: 12px;
    }
    
    /* Hide less important elements on small screens */
    .setting-group-header i {
        display: none;
    }
    
    /* Viewport stats repositioned */
    .viewport-stats {
        top: auto;
        bottom: 20px;
        left: 20px;
        max-width: 200px;
    }
}

/* iPad Landscape - FIXED VERSION WITH TEXTURE RESOLUTION FIX */
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: landscape) {
    /* Two-column layout with proper sidebar width */
    .app-container {
        display: grid;
        grid-template-columns: 320px 1fr !important;
        height: 100vh;
        height: -webkit-fill-available;
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
    }
    
    /* Sidebar adjustments - readable and functional */
    .sidebar {
        width: 100%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overflow-x: hidden;
    }
    
    /* Normal readable logo */
    .logo {
        padding: 12px 16px;
        gap: 10px;
    }
    
    .logo-icon {
        width: 40px;
        height: 40px;
    }
    
    .logo-text h1 {
        font-size: 16px;
    }
    
    .logo-text p {
        font-size: 12px;
        display: block;
    }
    
    /* Normal sections */
    .upload-section {
        padding: 16px;
    }
    
    .section-title {
        font-size: 14px;
        margin-bottom: 10px;
    }
    
    .upload-area {
        min-height: 80px;
        padding: 12px;
    }
    
    .upload-text {
        font-size: 14px;
    }
    
    .upload-subtext {
        font-size: 12px;
        display: block;
    }
    
    .upload-icon {
        font-size: 20px;
    }
    
    /* Normal setting groups */
    .setting-group {
        padding: 12px 16px;
        margin-bottom: 12px;
        width: 100%;
        box-sizing: border-box;
        overflow: visible;
    }
    
    .setting-label {
        font-size: 14px;
        margin-bottom: 6px;
    }
    
    /* Touch-friendly sliders */
    .slider {
        height: 32px;
    }
    
    .slider-input-row {
        gap: 8px;
    }
    
    .slider-value-input {
        font-size: 14px;
        padding: 8px 10px;
        width: 65px;
        min-height: 32px;
    }
    
    /* Touch-friendly buttons */
    .btn {
        min-height: 44px;
        font-size: 14px;
        padding: 12px 16px;
    }
    
    /* Normal top bar */
    .top-bar {
        padding: 10px 16px;
    }
    
    .tab {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    /* Section headers - normal size */
    .section-header {
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px;
    }
    
    .section-header i {
        display: inline;
        font-size: 14px;
    }
    
    /* TEXTURE RESOLUTION FIX - Dark theme styling to match app */
    #texture_resolution,
    #texture_resolution_setting select,
    .format-select {
        width: 100% !important;
        max-width: 260px !important;
        min-width: 0 !important; /* KEY FIX: Remove forced wide width */
        padding: 10px 12px !important;
        font-size: 14px !important;
        box-sizing: border-box !important;
        background: #222222 !important; /* Match app's dark background */
        color: #ffffff !important; /* White text like rest of app */
        border: 1px solid #333333 !important; /* Match app's border style */
        border-radius: 8px !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        -webkit-appearance: none !important;
        appearance: none !important;
        overflow: hidden !important;
    }
    
    /* Focus state - use app's accent color */
    #texture_resolution:focus,
    #texture_resolution_setting select:focus,
    .format-select:focus {
        outline: none !important;
        border-color: #00d4aa !important; /* App's teal accent color */
        background: #252525 !important; /* Slightly lighter on focus */
        box-shadow: 0 0 0 1px rgba(0, 212, 170, 0.2) !important; /* Subtle glow */
    }
    
    /* Hover state - match app's hover styling */
    #texture_resolution:hover:not(:disabled),
    #texture_resolution_setting select:hover:not(:disabled),
    .format-select:hover:not(:disabled) {
        background: #252525 !important;
        border-color: #444444 !important;
    }
    
    /* Option styling for dark theme */
    #texture_resolution option,
    #texture_resolution_setting select option,
    .format-select option {
        background: #222222 !important;
        color: #ffffff !important;
        border: none !important;
        padding: 8px 12px !important;
    }
    
    /* Remove dropdown arrow styling */
    #texture_resolution,
    #texture_resolution_setting select,
    .format-select {
        background-image: none !important;
    }
    
    /* Fix all setting containers to prevent overflow */
    #texture_resolution_setting,
    #ray_distance_setting,
    #cage_extrusion_setting,
    #normal_intensity_setting,
    .setting-group {
        width: 100% !important;
        max-width: 100% !important;
        overflow: visible !important;
        box-sizing: border-box !important;
    }
    
    /* Ensure sections show properly */
    .section-content {
        max-height: none !important;
        overflow: visible !important;
        padding: 16px;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .collapsible-section .section-content {
        display: block !important;
        width: 100% !important;
    }
    
    .collapsible-section.expanded .section-content {
        max-height: none !important;
        opacity: 1 !important;
        overflow: visible !important;
    }
    
    /* Normal mesh stats */
    .mesh-stats-compact {
        padding: 12px 16px;
        font-size: 12px;
    }
    
    .mesh-stats-compact .stat-item {
        margin-bottom: 4px;
    }
    
    /* Normal model tree */
    .model-tree {
        max-height: 180px;
        font-size: 12px;
    }
    
    .tree-item {
        padding: 6px 8px;
        min-height: 32px;
    }
    
    /* Model explorer normal */
    .model-explorer-header {
        padding: 10px 16px;
    }
    
    .model-explorer-header i {
        display: inline;
        font-size: 14px;
    }
    
    .model-explorer-title {
        font-size: 12px;
    }
    
    /* Show important labels */
    .topology-label {
        display: inline;
        font-size: 12px;
    }
    
    /* Fix main content */
    .main-content {
        display: flex;
        flex-direction: column;
        height: 100%;
        margin-bottom: 0;
        padding-bottom: 0;
    }
    
    .viewer-container {
        flex: 1;
        margin-bottom: 0;
        padding-bottom: 0;
    }
}

/* iPad Pro - Normal sizing */
@media only screen and (min-device-width: 1024px) and (max-device-width: 1366px) {
    .app-container {
        grid-template-columns: 320px 1fr;
    }
    
    .btn {
        min-height: 44px;
        font-size: 14px;
    }
    
    .slider {
        height: 36px;
    }
    
    .logo-icon {
        width: 44px;
        height: 44px;
    }
    
    .logo-text h1 {
        font-size: 16px;
    }
    
    .setting-label {
        font-size: 14px;
    }
    
    .form-select, select {
        font-size: 15px !important;
        padding: 12px 16px !important;
        min-width: 0 !important; /* Remove wide min-width on iPad Pro too */
        max-width: 100% !important;
    }
}

/* General tablet improvements */
@media (pointer: coarse) and (min-width: 768px) {
    /* Scrollbar styling for touch */
    ::-webkit-scrollbar {
        width: 12px;
        height: 12px;
    }
    
    ::-webkit-scrollbar-thumb {
        background: #555;
        border-radius: 6px;
    }
    
    /* Touch-friendly hover states */
    .upload-area:active {
        background: #2a2a2a;
        transform: scale(0.98);
    }
    
    .btn:active {
        transform: scale(0.98);
    }
    
    /* Prevent text selection on interactive elements */
    .btn, .tab, .upload-area, .tree-item {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Smooth scrolling */
    * {
        scroll-behavior: smooth;
    }
    
    /* Better focus states for touch */
    input:focus, select:focus, button:focus {
        outline: 2px solid #00d4aa;
        outline-offset: 2px;
    }
}

/* Specific iOS Safari fixes */
@supports (-webkit-touch-callout: none) {
    /* Fix for iOS Safari viewport height */
    html, body {
        height: 100vh;
        height: -webkit-fill-available;
        margin: 0;
        padding: 0;
    }
    
    .app-container {
        height: 100vh;
        height: -webkit-fill-available;
        min-height: 100vh;
        min-height: -webkit-fill-available;
        padding-bottom: 0 !important;
    }
    
    /* Fix for iOS momentum scrolling */
    .sidebar-scroll, .model-tree, .section-content {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Fix iOS tap highlight */
    * {
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Prevent iOS zoom on inputs - but ensure dropdowns fit properly */
    input, select, textarea {
        font-size: 16px !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }
}

/* Hide elements that don't work well on tablets */
@media (max-width: 1024px) and (pointer: coarse) {
    /* Simplify the license button on tablets */
    .license-key-btn {
        flex-direction: row;
        gap: 8px;
    }
    
    .license-key-btn > div {
        display: flex;
        flex-direction: row;
        gap: 8px;
        align-items: center;
    }
    
    .license-key-btn > div > div:first-child {
        display: none;
    }
    
    /* Simplify topology controls */
    .topology-label {
        display: none;
    }
    
    .topology-controls {
        gap: 8px;
    }
    
    /* Force dropdowns to be reasonable width */
    select, .format-select {
        min-width: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }
}

/* Collapsible sections behavior on tablets */
@media (max-width: 1024px) {
    /* Start with sections collapsed on tablets */
    .collapsible-section:not(.expanded) .section-content {
        display: none;
    }
    
    .section-header {
        padding: 12px 16px;
        background: #2a2a2a;
        border-radius: 8px;
        margin-bottom: 8px;
    }
    
    .section-header:active {
        background: #333;
    }
    
    /* Larger touch target for section headers */
    .section-header {
        min-height: 48px;
        display: flex;
        align-items: center;
    }
}

/* Modal adjustments for tablets */
@media (max-width: 1024px) {
    .modal {
        width: 90%;
        max-width: 600px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-header {
        position: sticky;
        top: 0;
        background: #252525;
        z-index: 10;
    }
    
    .modal-buttons {
        position: sticky;
        bottom: 0;
        background: #252525;
        padding-top: 16px;
        margin-top: 16px;
        border-top: 1px solid #333;
    }
}

/* Loading overlay adjustments */
@media (max-width: 1024px) {
    .main-loading-overlay {
        padding: 20px;
    }
    
    .loading-card {
        width: 100%;
        max-width: 500px;
    }
    
    .loading-title {
        font-size: 20px;
    }
    
    .loading-subtitle {
        font-size: 14px;
    }
}

/* Touch-friendly adjustments */
@media (pointer: coarse) {
    /* Increase touch targets */
    button, .btn, input[type="file"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Disable hover effects on touch devices */
    .upload-area:hover {
        background: #222222;
    }
    
    /* Make sliders easier to use on touch */
    input[type="range"] {
        height: 40px;
        -webkit-appearance: none;
    }
    
    input[type="range"]::-webkit-slider-thumb {
        width: 30px;
        height: 30px;
        -webkit-appearance: none;
    }
    
    /* Make download button more prominent on iOS */
    #downloadBtn {
        background: linear-gradient(135deg, #00d4aa, #0078d4) !important;
        color: #000 !important;
        font-weight: 600 !important;
        box-shadow: 0 4px 12px rgba(0, 212, 170, 0.3) !important;
    }
    
    #downloadBtn:disabled {
        background: #333333 !important;
        color: #666666 !important;
        box-shadow: none !important;
    }
}

/* Dark mode specific adjustments */
@media (prefers-color-scheme: dark) {
    /* Already using dark theme, no changes needed */
}

/* Light mode fallback */
@media (prefers-color-scheme: light) {
    /* Keep dark theme for professional 3D application */
}

.retopology-tip {
    background: rgba(0, 212, 170, 0.1);
    border: 1px solid rgba(0, 212, 170, 0.3);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    line-height: 1.5;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 212, 170, 0.1);
    position: relative;
    overflow: hidden;
}

.retopology-tip::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: #00d4aa;
    opacity: 0.8;
}

.retopology-tip.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    display: none;
}

.tip-icon {
    color: #00d4aa;
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

.tip-content {
    color: #c0c8d0;
}

.tip-content strong {
    color: #00d4aa;
    font-weight: 600;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .retopology-tip {
        font-size: 12px;
        padding: 10px;
    }
    
    .tip-icon {
        font-size: 14px;
    }
}

/* Ensure consistent background to hide any small gaps */
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
    body, .app-container, .main-content {
        background-color: #1a1a1a;
    }
}

/* Hide worker monitor on iPad app */
.ipad-webview #server-monitor {
    display: none !important;
}

/* iPad specific fixes for consistent behavior */
@media only screen and (min-device-width: 768px) and (max-device-width: 1366px) {
    /* Disable pinch-to-zoom and touch gestures */
    html {
        touch-action: pan-y;
        -ms-touch-action: pan-y;
        -webkit-user-select: none;
        user-select: none;
    }
    
    body {
        touch-action: pan-y;
        -ms-touch-action: pan-y;
        zoom: 1;
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
    
    /* Prevent any horizontal movement or layout shifts */
    .sidebar {
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
    }
    
    .sidebar-scroll {
        overflow-x: hidden;
        overflow-y: auto;
        touch-action: pan-y;
    }
    
    /* Lock sections to prevent horizontal drift */
    .upload-section,
    .collapsible-section,
    .section-content {
        overflow-x: hidden;
        width: 100%;
        box-sizing: border-box;
        touch-action: pan-y;
    }
    
    /* Disable zoom on the 3D viewer too */
    .viewer-container,
    .main-content {
        touch-action: pan-y;
    }
}

/* iPad Export Format - Stack vertically and fix width */
@media only screen and (min-device-width: 768px) and (max-device-width: 1366px) {
    .setting-group:has(#exportFormat) {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }
    
    .setting-group:has(#exportFormat) .setting-label {
        margin-bottom: 8px;
        margin-right: 0;
        min-width: auto;
    }
    
    .format-select {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important; /* CRITICAL: Remove forced wide width */
        font-size: 14px !important;
        padding: 10px 12px !important;
        box-sizing: border-box !important;
    }
}