* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

/* Utility class for hiding elements */
.hidden {
    display: none !important;
}

.container {
    width: 100vw;
    height: 100vh;
    margin: 0;
    background: white;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 15px 30px;
    border-bottom: 3px solid #3498db;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1003;
    min-height: 60px; /* Fix #1: Prevent height jumping on mobile */
}

.header h1 {
    font-size: 28px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}

/* Project Info Display */
.project-info {
    display: flex !important;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 1;
    min-width: 0; /* Allow flex shrinking */
    overflow: hidden; /* Prevent overflow */
    flex-wrap: wrap; /* Allow wrapping on mobile */
}

/* User Menu */
.user-menu {
    position: relative;
    flex-shrink: 0;
    margin-left: 8px;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 6px 12px;
    color: white;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.user-menu-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #3498db;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.user-email {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-arrow {
    font-size: 10px;
    opacity: 0.7;
}

.user-menu-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: #2c3e50;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    overflow: hidden;
}

.user-menu-dropdown.open {
    display: block;
}

.user-menu-info {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    word-break: break-all;
}

.user-menu-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    color: white;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.user-menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Auto-Save Status Indicator */
.auto-save-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    margin-right: 0;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: all 0.3s ease;
    white-space: nowrap;
    cursor: default;
    font-size: 11px;
    font-weight: 500;
    backdrop-filter: blur(4px);
    flex-shrink: 0; /* Don't shrink auto-save status */
}

/* Show when disabled but make it clickable */
.auto-save-status.disabled {
    display: inline-flex;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.auto-save-status.disabled:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

.auto-save-status.disabled .auto-save-text {
    color: rgba(255, 255, 255, 0.8);
    font-style: italic;
}

/* Status Light Indicator */
.auto-save-light {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: all 0.3s ease;
    position: relative;
    cursor: help;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

/* Light states */
.auto-save-light.light-disabled {
    background: rgba(255, 255, 255, 0.3);
    box-shadow: none;
    border-color: rgba(255, 255, 255, 0.2);
}

/* No changes = grey (initial state, no changes made) */
.auto-save-light.light-no-changes {
    background: #9ca3af;
    box-shadow: 0 0 4px rgba(156, 163, 175, 0.4);
    border-color: rgba(156, 163, 175, 0.5);
}

/* Synced = steady green (everything saved) */
.auto-save-light.light-synced {
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.6), inset 0 0 4px rgba(34, 197, 94, 0.3);
    border-color: rgba(34, 197, 94, 0.5);
}

/* Pending = orange/yellow pulse (unsaved changes) */
.auto-save-light.light-pending {
    background: #f59e0b;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.7);
    border-color: rgba(245, 158, 11, 0.6);
    animation: pulse-pending 1.5s ease-in-out infinite;
}

/* Saving = yellow pulse */
.auto-save-light.light-yellow {
    background: #fbbf24;
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.8);
    border-color: rgba(251, 191, 36, 0.7);
    animation: pulse-yellow 1s ease-in-out infinite;
}

/* Just saved = bright green flash */
.auto-save-light.light-green-flash {
    background: #22c55e;
    box-shadow: 0 0 16px rgba(34, 197, 94, 1);
    border-color: rgba(34, 197, 94, 0.8);
    animation: pulse-green-flash 0.4s ease-out;
}

/* Error = red pulse */
.auto-save-light.light-red {
    background: #ef4444;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.8);
    border-color: rgba(239, 68, 68, 0.7);
    animation: pulse-red 1s ease-in-out infinite;
}

/* Text label */
.auto-save-text {
    color: rgba(255, 255, 255, 0.95);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.4px;
    white-space: nowrap;
    text-transform: none;
}

/* Text colors based on status */
.auto-save-status.synced .auto-save-text,
.auto-save-status.saved .auto-save-text {
    color: #86efac;
    text-shadow: 0 0 4px rgba(134, 239, 172, 0.3);
}

.auto-save-status.no-changes .auto-save-text {
    color: rgba(255, 255, 255, 0.6);
    text-shadow: none;
}

.auto-save-status.pending .auto-save-text {
    color: #fcd34d;
    text-shadow: 0 0 4px rgba(252, 211, 77, 0.3);
}

.auto-save-status.saving .auto-save-text {
    color: #fcd34d;
    text-shadow: 0 0 4px rgba(252, 211, 77, 0.3);
}

.auto-save-status.error .auto-save-text {
    color: #fca5a5;
    text-shadow: 0 0 4px rgba(252, 165, 165, 0.3);
}

/* Animations */
@keyframes pulse-pending {
    0%, 100% {
        opacity: 0.8;
        transform: scale(1);
        box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
        box-shadow: 0 0 14px rgba(245, 158, 11, 0.8);
    }
}

@keyframes pulse-yellow {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.85;
        transform: scale(1.1);
    }
}

@keyframes pulse-green-flash {
    0% {
        transform: scale(1);
        box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
    }
    50% {
        transform: scale(1.5);
        box-shadow: 0 0 16px rgba(34, 197, 94, 1);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 8px rgba(34, 197, 94, 0.7);
    }
}

@keyframes pulse-red {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.15);
    }
}

/* Auto-save error toast notification */
.auto-save-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #fff;
    padding: 14px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    z-index: 100000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    max-width: 400px;
}

.auto-save-toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.auto-save-toast-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.auto-save-toast-icon {
    font-size: 18px;
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .auto-save-toast {
        bottom: 20px;
        right: 20px;
        left: 20px;
        max-width: calc(100% - 40px);
    }
}

.project-info-content {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0; /* Allow text truncation */
}

.project-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
    white-space: nowrap;
}

.project-name-display {
    font-size: 14px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0; /* Allow flex shrinking */
    flex: 1 1 auto; /* Allow shrinking */
    max-width: 180px; /* Limit project name width */
}

.btn-switch-project {
    padding: 6px 12px;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-switch-project:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

.header-icon {
    width: 36px;
    height: 36px;
    background: #3498db;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 320px;
    flex: 1;
    height: 0; /* This allows flex to work properly */
    transition: grid-template-columns 0.3s ease;
    position: relative;
}

/* Collapsed states */
.main-content.right-collapsed {
    grid-template-columns: 1fr 0;
}

/* Left sidebar as overlay (doesn't push content) */
.sidebar {
    position: fixed;
    left: 0;
    top: 69px; /* Below header (15px padding + 28px h1 + 15px padding + 3px border) */
    bottom: 0;
    width: 350px;
    z-index: 1002;
    background: #f8f9fa;
    border-right: 1px solid #e0e0e0;
    padding: 25px;
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateX(0);
    transition: transform 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

/* Properties panel pushes content */
.properties-panel {
    position: relative;
    z-index: 1002;
    background: #f8f9fa;
    border-left: 1px solid #e0e0e0;
    padding: 25px;
    overflow-y: auto;
    overflow-x: hidden;
    transition: all 0.3s ease;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.hamburger-btn {
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hamburger-btn:hover {
    background: #2980b9;
    transform: scale(1.05);
}

.hamburger-btn:active {
    transform: scale(0.95);
}

/* Collapsed properties panel styles */
.properties-panel.collapsed {
    width: 0;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    border: none;
    visibility: hidden;
}

.properties-panel.collapsed .sidebar-header {
    display: none;
}

.properties-panel.collapsed > *:not(.sidebar-header) {
    display: none;
}

.sidebar h2 {
    font-size: 18px;
    color: #2c3e50;
    margin: 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
}

.component-details-title {
    margin-top: 50px;
}

.component-name-group {
    margin-top: 25px;
}


/* Canvas Zoom Section */
.canvas-zoom-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

.canvas-zoom-label {
    display: block;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 14px;
}

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

.zoom-btn {
    width: 40px;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-level-input {
    font-weight: 600;
    color: #2c3e50;
    width: 70px;
    text-align: center;
    padding: 8px 6px;
    border: 2px solid #d1d5db;
    margin-bottom: 10px;
    border-radius: 6px;
    background: white;
    font-size: 14px;
    transition: all 0.2s ease;
    height: 38px; /* Match button height */
    box-sizing: border-box;
    line-height: 1.2;
}

.zoom-level-input:hover {
    border-color: #3498db;
}

.zoom-level-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.zoom-reset {
    flex: 1;
    padding: 8px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-fit-screen {
    width: 100%;
    margin-top: 10px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-fit-screen:hover {
    background: linear-gradient(135deg, #2980b9 0%, #2471a3 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.btn-fit-screen:active {
    transform: translateY(0);
}

/* Toggle Info Boxes Button */
.btn-toggle-info {
    width: 100%;
    margin-top: 10px;
    padding: 12px 24px;
    background: #95a5a6;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-toggle-info .info-icon {
    font-size: 14px;
    margin-right: 6px;
}

.btn-toggle-info.active {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
}

.btn-toggle-info.active:hover {
    background: linear-gradient(135deg, #2980b9 0%, #2471a3 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.btn-toggle-info:not(.active):hover {
    background: #7f8c8d;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(149, 165, 166, 0.4);
}

.btn-toggle-info:active {
    transform: translateY(0);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    width: 100%;
    margin-bottom: 10px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
    width: 100%;
    margin-bottom: 10px;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-export {
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
    color: white;
    width: 100%;
}

.btn-export:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(39, 174, 96, 0.4);
}


.btn-new {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    width: 100%;
    margin-bottom: 10px;
}

.btn-new:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.btn-load {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    width: 100%;
    margin-bottom: 10px;
}

.btn-load:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

/* File Actions Section */
.file-actions-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: #000000;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.current-diagram-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #27ae60;
}

.diagram-info-label {
    font-size: 11px;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.diagram-name-display {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    word-break: break-word;
    line-height: 1.4;
}

.canvas-area {
    background: #e5e5e5; /* Gray background for non-active area (outside the white box) */
    position: relative;
    overflow: hidden;
    padding: 0;
    cursor: grab;
}

/* Floating toggle buttons */
.floating-toggle-btn {
    position: absolute;
    top: 20px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
    transition: all 0.3s ease;
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    justify-content: center;
}

.floating-toggle-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(52, 152, 219, 0.4);
}

.floating-toggle-btn:active {
    transform: translateY(0);
}

.left-floating {
    left: 30px;
}

.right-floating {
    right: 20px;
}

/* When both panels are collapsed, keep Properties button on the right side */
.main-content.both-collapsed .right-floating {
    right: 30px;
    left: auto;
    top: 20px; /* Keep it at the same level as Components button */
}

.floating-btn-text {
    font-size: 12px;
    font-weight: 600;
}

.floating-btn-icon {
    font-size: 16px;
    font-weight: bold;
}

.canvas-area.dragging {
    cursor: grabbing;
}


.btn-delete {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white !important;
    width: 100%;
    margin-top: 10px;
    border: none;
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-delete:hover {
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    color: #c0392b !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

.btn-delete:active {
    background: linear-gradient(135deg, #ffcdd2 0%, #ef9a9a 100%);
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
}



@media (max-width: 1400px) {
    .main-content {
        grid-template-columns: 1fr 280px;
    }
    
    .sidebar {
        width: 300px;
    }
}

/* Mobile Landscape & Tablet Responsive Adjustments */
@media (max-width: 1366px) and (orientation: landscape),
       (max-width: 1024px),
       (hover: none) and (pointer: coarse) {
    
    /* Header adjustments for narrow screens */
    .header {
        gap: 10px;
        flex-wrap: wrap; /* Allow wrapping on very small screens */
        height: auto;
        min-height: 60px;
    }
    
    .header h1 {
        font-size: 18px;
        flex-shrink: 1;
        min-width: 0;
        margin-right: auto; /* Push other elements to right */
    }
    
    .header-icon {
        font-size: 18px;
        width: 32px;
        height: 32px;
    }
    
    .user-email {
        display: none;
    }
    
    .user-menu-arrow {
        display: none;
    }
    
    .header .project-info {
        max-width: 100%; /* Allow full width when wrapped */
        flex-shrink: 1;
        padding: 4px 8px;
        order: 3; /* Move to new line if needed */
        margin-top: 5px;
        /* Keep horizontal layout for tablet/desktop */
    }
    
    .project-name-display {
        max-width: 150px;
        font-size: 12px;
    }
    
    .current-diagram-info {
        padding: 8px;
        margin-bottom: 10px;
    }
    
    .diagram-info-label {
        font-size: 10px;
    }
    
    .diagram-name-display {
        font-size: 13px;
    }
    
    .btn-switch-project {
        font-size: 11px;
        padding: 4px 8px;
    }
    
    /* Auto-save status on tablet */
    .auto-save-status {
        padding: 4px 8px;
        margin-right: 8px;
        gap: 6px;
        font-size: 11px;
    }
    
    .auto-save-light {
        width: 8px;
        height: 8px;
    }
    
    .auto-save-text {
        font-size: 10px;
    }
    
    /* Ensure header h1 wraps properly on mobile */
    .header h1 {
        flex-wrap: wrap;
    }
    
    /* Properties panel - ensure inputs fit */
    .property-item .property-select,
    .property-item select,
    .property-item .property-input,
    .property-item input[type="text"]:not(.zoom-level-input),
    .property-item input[type="number"]:not(.zoom-level-input),
    .property-item .form-control {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }
    
    .property-item {
        max-width: 100%;
        overflow: hidden;
    }
    
    /* Button groups wrap on small screens */
    .property-actions,
    .action-buttons {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .property-actions .btn,
    .action-buttons .btn {
        flex: 1 1 100%;
        min-width: 0;
        margin-bottom: 0; /* Remove default margin since we use gap */
    }
    
    .property-actions .btn:only-child,
    .action-buttons .btn:only-child {
        flex: 1 1 100%;
    }
    
    /* Zoom controls sizing */
    .zoom-btn {
        width: 36px;
        flex-shrink: 0;
    }
    
    .zoom-level-input {
        width: 60px;
        flex-shrink: 0;
    }
    
    .zoom-reset {
        flex: 1;
        min-width: 60px;
    }
    
    /* Radio button groups - wrap to 2 rows (2+1 layout) */
    .radio-group {
        flex-wrap: wrap;
        gap: 8px;
        max-width: 100%;
    }
    
    .radio-label {
        flex: 0 1 calc(50% - 4px);
        font-size: 13px;
    }
    
    .radio-label:nth-child(3) {
        flex: 0 1 calc(50% - 4px);
    }

    /* Main layout responsiveness */
    .main-content {
        grid-template-columns: 1fr; /* Stack columns on smaller tablets/mobiles */
        display: flex;
        flex-direction: column;
    }

    /* Sidebar and Properties Panel as Overlays/Drawers on Tablet/Mobile */
    .sidebar,
    .properties-panel {
        position: fixed;
        top: 60px; /* Adjust based on header height */
        bottom: 0;
        background: white;
        box-shadow: 0 0 15px rgba(0,0,0,0.2);
        transition: transform 0.3s ease;
        width: 300px;
        max-width: 80vw;
        /* Scroll handling */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        /* Bottom padding to ensure content (like delete button) clears browser navbars */
        padding-bottom: 100px !important;
    }

    /* Left Sidebar - hidden when .collapsed, visible otherwise */
    .sidebar {
        left: 0;
        transform: translateX(0); /* Visible by default (when not collapsed) */
        border-right: 1px solid #e0e0e0;
    }

    .sidebar.collapsed {
        transform: translateX(-100%); /* Hidden when collapsed */
    }
    
    /* Right Properties Panel - hidden when .collapsed, visible otherwise */
    .properties-panel {
        right: 0;
        transform: translateX(0); /* Visible by default (when not collapsed) */
        border-left: 1px solid #e0e0e0;
    }

    .properties-panel.collapsed {
        transform: translateX(100%); /* Hidden when collapsed */
    }
}

/* Extra padding for landscape mode on touch devices (browser chrome takes vertical space) */
@media (orientation: landscape) and (hover: none) and (pointer: coarse) {
    .properties-panel,
    .sidebar {
        padding-bottom: 120px !important;
    }
}

/* Even more padding for very short landscape screens (phones rotated) */
@media (orientation: landscape) and (max-height: 500px) {
    .properties-panel,
    .sidebar {
        padding-bottom: 150px !important;
    }
}