/* 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 and Tablet Responsive Styles */
/* Add this to your responsive.css file or create a new ipad.css file */

/* 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;
        overflow: hidden;
    }
    
    /* 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;
    }
    
    /* 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;
    }
    
    /* 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 - MUCH NARROWER SIDEBAR FOR MORE 3D VIEWER SPACE */
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: landscape) {
    /* Two-column layout with NARROW sidebar */
    .app-container {
        display: grid;
        grid-template-columns: 240px 1fr; /* REDUCED from 350px to 240px - 110px more space for viewer! */
        height: 100vh;
    }
    
    /* Sidebar adjustments - much more compact */
    .sidebar {
        width: 100%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* VERY compact logo */
    .logo {
        padding: 8px 12px; /* Much smaller padding */
        gap: 8px;
    }
    
    .logo-icon {
        width: 32px; /* Smaller icon */
        height: 32px;
    }
    
    .logo-text h1 {
        font-size: 11px; /* Smaller text */
    }
    
    .logo-text p {
        font-size: 9px; /* Tiny subtitle */
        display: none; /* Hide subtitle to save space */
    }
    
    /* Much more compact sections */
    .upload-section {
        padding: 10px; /* Reduced from 16px */
    }
    
    .section-title {
        font-size: 11px; /* Smaller titles */
        margin-bottom: 8px;
    }
    
    .upload-area {
        min-height: 60px; /* Much smaller upload area */
        padding: 8px;
    }
    
    .upload-text {
        font-size: 11px; /* Smaller text */
    }
    
    .upload-subtext {
        font-size: 9px;
        display: none; /* Hide subtext to save space */
    }
    
    .upload-icon {
        font-size: 16px; /* Smaller icon */
    }
    
    .setting-group {
        padding: 8px; /* Much more compact */
        margin-bottom: 8px;
    }
    
    .setting-label {
        font-size: 11px; /* Smaller labels */
        margin-bottom: 4px;
    }
    
    /* Compact sliders but still touch-friendly */
    .slider {
        height: 28px; /* Slightly smaller */
    }
    
    .slider-input-row {
        gap: 6px; /* Smaller gaps */
    }
    
    .slider-value-input {
        font-size: 11px; /* Smaller font */
        padding: 4px 6px;
        width: 50px; /* Fixed smaller width */
    }
    
    /* Compact buttons but still usable */
    .btn {
        min-height: 32px; /* Smaller but still touchable */
        font-size: 11px;
        padding: 6px 10px;
    }
    
    /* Very compact top bar */
    .top-bar {
        padding: 6px 12px; /* Much smaller */
    }
    
    .tab {
        padding: 4px 8px; /* Tiny tabs */
        font-size: 10px;
    }
    
    /* Hide non-essential elements to save space */
    .section-header i {
        display: none; /* Hide section icons */
    }
    
    .topology-label {
        display: none; /* Hide topology labels */
    }
    
    .license-key-btn > div > div:first-child {
        display: none; /* Hide "License Key" text */
    }
    
    /* Compact section headers */
    .section-header {
        padding: 8px 10px;
        font-size: 11px;
        min-height: 32px;
    }
    
    /* Compact mesh stats */
    .mesh-stats-compact {
        padding: 6px;
        font-size: 10px;
    }
    
    .mesh-stats-compact .stat-item {
        margin-bottom: 2px;
    }
    
    /* Model tree more compact */
    .model-tree {
        max-height: 120px;
        font-size: 10px;
    }
    
    .tree-item {
        padding: 2px 4px;
    }
    
    /* Hide model explorer icons to save space */
    .model-explorer-header i {
        display: none;
    }
    
    .model-explorer-title {
        font-size: 10px;
    }
}


/* iPad Pro - Keep it reasonable but still compact */
@media only screen and (min-device-width: 1024px) and (max-device-width: 1366px) {
    .app-container {
        grid-template-columns: 280px 1fr; /* REDUCED from 380px to 280px */
    }
    
    /* Slightly larger touch targets for iPad Pro */
    .btn {
        min-height: 40px;
        font-size: 13px;
    }
    
    .slider {
        height: 32px;
    }
    
    .logo-icon {
        width: 40px;
        height: 40px;
    }
    
    .logo-text h1 {
        font-size: 13px;
    }
}

/* 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 */
    .app-container {
        height: 100vh;
        height: -webkit-fill-available;
    }
    
    /* 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 */
    input, select, textarea {
        font-size: 16px !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; /* Hide "License Key" text */
    }
    
    /* Simplify topology controls */
    .topology-label {
        display: none;
    }
    
    .topology-controls {
        gap: 8px;
    }
}

/* 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 (for systems that support it) */
@media (prefers-color-scheme: dark) {
    /* Already using dark theme, no changes needed */
}

/* Light mode fallback (if user forces light mode) */
@media (prefers-color-scheme: light) {
    /* Keep dark theme for professional 3D application */
    /* No changes - maintain dark theme regardless */
}

.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;
    }
}

/* iOS Bottom Gap Fix - More Targeted Approach */

/* Fix only the dark bottom area without breaking viewer */
@supports (-webkit-touch-callout: none) {
    /* Only fix viewport height, don't mess with viewer */
    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;
        
        /* Only remove bottom padding that causes dark area */
        padding-bottom: 0 !important;
    }
}

/* iPad specific - fix dark bottom area only */
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
    .app-container {
        /* Fix the bottom gap but keep other positioning */
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
        
        /* Ensure we use full available height */
        height: 100vh !important;
        height: -webkit-fill-available !important;
        min-height: 100vh !important;
        min-height: -webkit-fill-available !important;
    }
    
    /* Make sure main content fills properly but don't override viewer internals */
    .main-content {
        flex: 1;
        min-height: 0;
        
        /* Fix any bottom gaps */
        margin-bottom: 0;
        padding-bottom: 0;
    }
    
    /* Don't override viewer-container positioning - let Three.js handle it */
    .viewer-container {
        /* Only ensure it fills its parent properly */
        width: 100%;
        height: 100%;
        
        /* Remove any bottom spacing that creates dark area */
        margin-bottom: 0;
        padding-bottom: 0;
        
        /* Don't override canvas positioning! */
    }
    
    /* Ensure consistent background to hide any small gaps */
    body, .app-container, .main-content {
        background-color: #1a1a1a;
    }
}

/* iPad Landscape - minimal fixes */
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: landscape) {
    .app-container {
        /* Keep grid layout but fix bottom gap */
        display: grid;
        grid-template-columns: 240px 1fr;
        height: 100vh !important;
        height: -webkit-fill-available !important;
        
        /* Remove bottom gap */
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
    }
    
    .main-content {
        display: flex;
        flex-direction: column;
        height: 100%;
        
        /* Fix bottom spacing */
        margin-bottom: 0;
        padding-bottom: 0;
    }
    
    .top-bar {
        flex-shrink: 0;
    }
    
    .viewer-container {
        flex: 1;
        /* Don't mess with Three.js canvas positioning */
    }
}

/* iPad Portrait - minimal fixes */
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: portrait) {
    .app-container {
        flex-direction: column;
        height: 100vh !important;
        height: -webkit-fill-available !important;
        
        /* Remove bottom gap */
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
    }
    
    .main-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        
        /* Fix bottom spacing */
        margin-bottom: 0;
        padding-bottom: 0;
    }
    
    .viewer-container {
        flex: 1;
        /* Let Three.js handle the rest */
    }
}

/* iPad Landscape - Better Balance with Tighter Left Alignment */
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: landscape) {
    /* Two-column layout with better sidebar width */
    .app-container {
        display: grid;
        grid-template-columns: 270px 1fr; /* Keep 270px width */
        height: 100vh;
        
        /* Fix bottom gap */
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
    }
    
    /* Sidebar adjustments - tighter to left edge */
    .sidebar {
        width: 100%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Tighter logo - closer to left edge */
    .logo {
        padding: 10px 8px 10px 12px; /* Less right padding, normal left */
        gap: 8px;
    }
    
    .logo-icon {
        width: 36px;
        height: 36px;
    }
    
    .logo-text h1 {
        font-size: 12px;
    }
    
    .logo-text p {
        font-size: 10px;
        display: block;
    }
    
    /* Tighter sections - closer to left edge */
    .upload-section {
        padding: 12px 8px 12px 12px; /* Less right padding */
    }
    
    .section-title {
        font-size: 12px;
        margin-bottom: 10px;
    }
    
    .upload-area {
        min-height: 70px;
        padding: 10px;
    }
    
    .upload-text {
        font-size: 12px;
    }
    
    .upload-subtext {
        font-size: 10px;
        display: block;
    }
    
    .upload-icon {
        font-size: 18px;
    }
    
    /* Tighter setting groups */
    .setting-group {
        padding: 10px 6px 10px 12px; /* Tight right, normal left */
        margin-bottom: 10px;
    }
    
    .setting-label {
        font-size: 12px;
        margin-bottom: 6px;
    }
    
    /* Sliders closer to left */
    .slider {
        height: 30px;
        margin-right: 6px; /* Add small right margin instead of padding */
    }
    
    .slider-input-row {
        gap: 6px; /* Smaller gap */
        padding-right: 6px; /* Small right padding */
    }
    
    .slider-value-input {
        font-size: 12px;
        padding: 5px 6px;
        width: 55px; /* Slightly smaller to fit better */
    }
    
    /* Buttons tighter */
    .btn {
        min-height: 36px;
        font-size: 12px;
        padding: 8px 10px; /* Less horizontal padding */
        margin-right: 8px; /* Small right margin instead */
    }
    
    /* Tighter top bar */
    .top-bar {
        padding: 8px 10px 8px 14px; /* Less right padding */
    }
    
    .tab {
        padding: 6px 8px; /* Tighter padding */
        font-size: 11px;
    }
    
    /* Section headers tighter */
    .section-header {
        padding: 10px 8px 10px 12px; /* Tight right, normal left */
        font-size: 12px;
        min-height: 36px;
    }
    
    .section-header i {
        display: inline;
        font-size: 12px;
    }
    
    /* Collapsible content tighter */
    .section-content {
        padding-left: 12px; /* Normal left padding */
        padding-right: 6px; /* Tight right padding */
    }
    
    /* Mesh stats tighter */
    .mesh-stats-compact {
        padding: 8px 6px 8px 12px; /* Tight right, normal left */
        font-size: 11px;
    }
    
    .mesh-stats-compact .stat-item {
        margin-bottom: 4px;
    }
    
    /* Model tree tighter */
    .model-tree {
        max-height: 140px;
        font-size: 11px;
        padding-right: 6px; /* Tight scrolling area */
    }
    
    .tree-item {
        padding: 4px 4px 4px 8px; /* Tight right, normal left */
    }
    
    /* Model explorer tighter */
    .model-explorer-header {
        padding: 8px 6px 8px 12px; /* Tight right, normal left */
    }
    
    .model-explorer-header i {
        display: inline;
        font-size: 12px;
    }
    
    .model-explorer-title {
        font-size: 11px;
    }
    
    /* Hide elements that still take too much space */
    .topology-label {
        display: none;
    }
    
    .license-key-btn > div > div:first-child {
        display: none; /* Hide "License Key" text */
    }
    
    /* Fix main content */
    .main-content {
        display: flex;
        flex-direction: column;
        height: 100%;
        margin-bottom: 0;
        padding-bottom: 0;
    }
    
    .viewer-container {
        flex: 1;
    }
}

/* iPad Pro - Keep good spacing since it has more room */
@media only screen and (min-device-width: 1024px) and (max-device-width: 1366px) {
    .app-container {
        grid-template-columns: 280px 1fr; /* Keep at 280px for iPad Pro */
    }
    
    /* iPad Pro keeps normal padding throughout */
    .logo {
        padding: 12px 16px;
    }
    
    .upload-section {
        padding: 14px 16px;
    }
    
    .setting-group {
        padding: 12px 16px;
    }
    
    .section-header {
        padding: 12px 16px;
    }
    
    /* iPad Pro can handle larger elements */
    .btn {
        min-height: 40px;
        font-size: 13px;
        padding: 10px 16px;
    }
    
    .slider {
        height: 32px;
    }
    
    .logo-icon {
        width: 40px;
        height: 40px;
    }
    
    .logo-text h1 {
        font-size: 14px;
    }
    
    .setting-label {
        font-size: 13px;
    }
}

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

/* iPad Remesh Settings - Better Space Without Breaking Functionality */
@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;
    }
    
    /* Keep section structure intact, just optimize individual setting groups */
    .setting-group {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 16px;
        padding: 0;
        overflow-x: hidden;
        width: 100%;
    }
    
    .setting-label {
        font-size: 13px;
        margin-bottom: 0;
        margin-right: 12px;
        min-width: 120px;
        flex-shrink: 0;
    }
    
    .slider-container {
        flex: 1;
        max-width: 200px;
        overflow: hidden;
        touch-action: pan-y;
    }
    
    .slider-input-row {
        gap: 8px;
        margin-bottom: 0;
    }
    
    .slider {
        transform: translateZ(0);
        backface-visibility: hidden;
        touch-action: pan-y;
    }
    
    .slider-value-input {
        width: 60px;
        font-size: 14px;
        touch-action: pan-y;
    }
    
    /* Target count still gets full width since it's important */
    .setting-group:has(#target_count) {
        flex-direction: column;
        align-items: stretch;
    }
    
    .setting-group:has(#target_count) .setting-label {
        margin-bottom: 8px;
        margin-right: 0;
        min-width: auto;
    }
    
    .setting-group:has(#target_count) .slider-container {
        max-width: none;
    }
    
    /* Disable zoom on the 3D viewer too */
    .viewer-container,
    .main-content {
        touch-action: pan-y;
    }
 }
 
 /* iPad Export Format - Stack vertically */
@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%;
        max-width: none;
    }
}