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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.app-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.app-header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.app-header p {
    font-size: 1.1em;
    opacity: 0.9;
}

.main-content {
    display: flex;
    min-height: calc(100vh - 200px);
}

.sidebar {
    width: 280px;
    background: #f8f9fa;
    padding: 25px;
    border-right: 2px solid #e9ecef;
    overflow-y: auto;
}

.sidebar h2 {
    font-size: 1.2em;
    margin-bottom: 15px;
    color: #333;
}

.sidebar h3 {
    font-size: 1em;
    margin-bottom: 10px;
    color: #555;
}

.section-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 30px;
}

.add-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: all 0.2s;
    text-align: left;
}

.add-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

.custom-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    font-weight: 600;
}

.custom-btn:hover {
    background: linear-gradient(135deg, #e082ea 0%, #e4465b 100%);
}

.controls {
    margin-bottom: 30px;
}

.screen-size-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #667eea;
    border-radius: 6px;
    background: white;
    color: #333;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 10px;
}

.screen-size-select:hover {
    border-color: #5568d3;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.screen-size-select:focus {
    outline: none;
    border-color: #5568d3;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.spacing-control {
    margin-bottom: 15px;
}

.spacing-control label {
    display: block;
    font-size: 0.9em;
    color: #333;
    margin-bottom: 8px;
    font-weight: 500;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #dee2e6;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    transition: all 0.2s;
}

.slider::-webkit-slider-thumb:hover {
    background: #5568d3;
    transform: scale(1.2);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.slider::-moz-range-thumb:hover {
    background: #5568d3;
    transform: scale(1.2);
}

.action-btn {
    width: 100%;
    background: #28a745;
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    margin-bottom: 10px;
    transition: all 0.2s;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.export-btn {
    background: #007bff;
}

.export-btn:hover {
    background: #0056b3;
}

.clear-btn {
    background: #dc3545;
}

.clear-btn:hover {
    background: #c82333;
}

.instructions {
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.instructions ul {
    list-style: none;
    padding-left: 0;
}

.instructions li {
    padding: 6px 0;
    color: #666;
    font-size: 0.9em;
}

.instructions li:before {
    content: "→ ";
    color: #667eea;
    font-weight: bold;
}

.canvas-wrapper {
    flex: 1;
    padding: 30px;
    padding-top: 50px;
    overflow-y: auto;
    overflow-x: auto;
    background: #ffffff;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.canvas {
    min-height: 600px;
    background: white;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 20px;
    position: relative;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 15px;
    overflow-x: hidden;
    overflow-y: visible;
    box-sizing: border-box;
    width: 100%;
    max-width: 1440px;
    transition: all 0.3s ease;
    height: auto;
}

.width-indicator {
    position: absolute;
    top: -30px;
    left: 0;
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
    z-index: 100;
    pointer-events: none;
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #adb5bd;
    font-size: 1.1em;
    width: 80%;
}

.wireframe-section {
    background: var(--section-bg, #f8f9fa);
    border: var(--section-border-width, 2px) solid var(--section-border-color, #667eea);
    border-radius: var(--section-border-radius, 8px);
    color: var(--section-text-color, #667eea);
    padding: 15px;
    position: relative;
    cursor: move;
    transition: all 0.2s;
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
}

.wireframe-section.inline-section {
    width: 300px;
    flex-grow: 0;
}

.row-group {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100%;
    flex-wrap: nowrap;
}

.column-stack {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: inherit;
    flex-shrink: 0;
}

.container-section {
    background: #e8eaf6;
    border-color: #764ba2;
    padding: 10px;
    padding-top: 35px;
    align-items: stretch;
    display: flex;
    flex-direction: column;
}

.container-inner {
    width: 100%;
    flex: 1;
    min-height: 150px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 10px;
    border: 2px dashed #9575cd;
    border-radius: 6px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.5);
    transition: all 0.2s;
}

.container-inner.container-drop-active {
    background: rgba(149, 117, 205, 0.2);
    border-color: #764ba2;
    border-style: solid;
}

.container-label {
    font-size: 0.9em;
    font-weight: bold;
    color: #764ba2;
    text-align: left;
    outline: none;
    cursor: text;
    padding: 5px;
    border-radius: 4px;
    transition: background 0.2s;
    position: absolute;
    top: 5px;
    left: 10px;
    z-index: 5;
}

.container-label:hover {
    background: rgba(118, 75, 162, 0.1);
}

.container-label:focus {
    background: rgba(118, 75, 162, 0.2);
}

.child-section {
    width: 100%;
    margin: 0;
    min-height: 40px;
    background: white;
    border-color: #667eea;
    position: relative;
    flex-shrink: 0;
}

.child-section.inline-child {
    width: 200px;
    flex-grow: 0;
}

.child-section .section-label {
    font-size: 1em;
}

.child-section .resize-handle {
    display: block;
}

.row-section {
    background: #e8f5e9;
    border-color: #11998e;
    padding: 10px;
    padding-top: 40px;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.row-label {
    font-size: 0.9em;
    font-weight: bold;
    color: #11998e;
    text-align: left;
    outline: none;
    cursor: text;
    padding: 5px;
    border-radius: 4px;
    transition: background 0.2s;
    position: absolute;
    top: 5px;
    left: 10px;
    z-index: 5;
}

.row-label:hover {
    background: rgba(17, 153, 142, 0.1);
}

.row-label:focus {
    background: rgba(17, 153, 142, 0.2);
}

.add-column-btn {
    position: absolute;
    top: 10px;
    right: 45px;
    background: #11998e;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    transition: all 0.2s;
}

.add-column-btn:hover {
    background: #0e8070;
    transform: scale(1.05);
}

.row-inner {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: row;
    gap: 10px;
    min-height: 150px;
}

.row-column {
    background: white;
    border: 2px solid #11998e;
    border-radius: 6px;
    padding: 10px;
    padding-top: 35px;
    position: relative;
    min-width: 150px;
    display: flex;
    flex-direction: column;
}

.column-label {
    font-size: 0.85em;
    font-weight: bold;
    color: #11998e;
    text-align: left;
    outline: none;
    cursor: text;
    padding: 5px;
    border-radius: 4px;
    transition: background 0.2s;
    position: absolute;
    top: 5px;
    left: 10px;
    z-index: 5;
}

.column-label:hover {
    background: rgba(17, 153, 142, 0.1);
}

.column-label:focus {
    background: rgba(17, 153, 142, 0.2);
}

.column-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border: 2px dashed #4db8ab;
    border-radius: 6px;
    padding: 10px;
    background: rgba(232, 245, 233, 0.3);
    min-height: 80px;
    transition: all 0.2s;
}

.column-child-section {
    width: 100%;
    margin: 0;
    min-height: 40px;
    background: #f8f9fa;
    border-color: #667eea;
}

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

.wireframe-section.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.wireframe-section.drag-over-top {
    border-top: 4px solid #28a745;
}

.wireframe-section.drag-over-bottom {
    border-bottom: 4px solid #28a745;
}

.wireframe-section.drag-over-left {
    border-left: 4px solid #007bff;
    background: rgba(0, 123, 255, 0.1);
}

.wireframe-section.drag-over-right {
    border-right: 4px solid #007bff;
    background: rgba(0, 123, 255, 0.1);
}

.wireframe-section.resizing {
    user-select: none;
}


.wireframe-section.resizing.resize-e {
    cursor: ew-resize;
}

.wireframe-section.resizing.resize-s {
    cursor: ns-resize;
}

.resize-handle {
    position: absolute;
    z-index: 10;
}


/* East (right) resize handle */
.resize-e {
    top: 0;
    right: 0;
    width: 10px;
    height: 100%;
    cursor: ew-resize;
}

.resize-e::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 2px;
    transform: translateY(-50%);
    width: 4px;
    height: 30px;
    background: #667eea;
    opacity: 0;
    transition: opacity 0.2s;
    border-radius: 2px;
}

.wireframe-section:hover .resize-e::after {
    opacity: 0.5;
}

/* South (bottom) resize handle */
.resize-s {
    bottom: 0;
    left: 0;
    width: 100%;
    height: 10px;
    cursor: ns-resize;
}

.resize-s::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 2px;
    transform: translateX(-50%);
    width: 30px;
    height: 4px;
    background: #667eea;
    opacity: 0;
    transition: opacity 0.2s;
    border-radius: 2px;
}

.wireframe-section:hover .resize-s::after {
    opacity: 0.5;
}

/* Export mode: normalize visuals to avoid semi-transparency or overlays in exports */
.exporting .wireframe-section {
    box-shadow: none !important;
    transform: none !important;
    opacity: 1 !important;
}
.exporting .wireframe-section.dragging {
    opacity: 1 !important;
}
.exporting .wireframe-section.drag-over-left,
.exporting .wireframe-section.drag-over-right,
.exporting .wireframe-section.drag-over-top,
.exporting .wireframe-section.drag-over-bottom {
    background: transparent !important;
    border-color: var(--section-border-color, #667eea) !important;
}
.exporting .resize-e::after,
.exporting .resize-s::after {
    opacity: 0 !important;
}
.exporting .resize-handle {
    display: none !important;
}
.exporting.canvas,
.exporting .canvas {
    border: none !important;
    background: #ffffff !important;
}
.exporting .width-indicator,
.exporting .empty-state {
    display: none !important;
}

.section-label {
    font-size: 1.5em;
    font-weight: bold;
    color: inherit;
    text-align: center;
    outline: none;
    cursor: text;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background 0.2s;
    flex: 1;
}

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

.section-label:focus {
    background: rgba(102, 126, 234, 0.2);
}

.remove-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 1.2em;
    line-height: 1;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}

.toggle-inline-btn {
    display: none;
}
/* Toggle inline removed; no styles needed */

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 2px solid #e9ecef;
    }

    .app-header h1 {
        font-size: 1.8em;
    }
}

/* Animation for adding sections */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wireframe-section {
    animation: slideIn 0.3s ease;
}
