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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.app-header {
    text-align: center;
    margin-bottom: 30px;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-header h1 {
    color: #2c3e50;
    font-size: 28px;
    margin-bottom: 5px;
}

.app-header p {
    color: #7f8c8d;
    font-size: 14px;
}

.main-content {
    max-width: 1270px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 650px 600px;
    gap: 20px;
}

/* Canvas Area */
.canvas-area {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.canvas-container {
    position: relative;
    max-width: 100%;
    margin: 0 auto;
    background: #fff;
    border: 1px solid #ddd;
    overflow: hidden;
    padding: 4px;
}

/* Constrain editing canvas to fit in viewport - scale proportionally */
.canvas-container.editing-canvas {
    max-width: 579px; /* 750px / 1.294 (aspect ratio) = 579px max width */
    max-height: 750px;
}

/* For horizontal image mode, constrain width so height doesn't exceed viewport */
.canvas-container.editing-canvas:has(.image-mode-horizontal) {
    max-width: 396px; /* Match the export canvas width (~396.5px) */
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 129.4%; /* 8.5:11 aspect ratio for letter size */
}

.canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Card cover: top-left, matching template positioning */
.card-cover-quadrant {
    position: absolute;
    top: 1.9%;
    left: 7.4%;
    width: 47%;
    height: 47%;
    overflow: hidden;
    padding: 2px;
    z-index: 5;
}

/* Inside message: bottom-right, matching template positioning */
.card-inside-quadrant {
    position: absolute;
    bottom: 3%;
    right: 2.5%;
    width: 47%;
    height: 47%;
    overflow: hidden;
    padding: 2px;
    z-index: 5;
}

.card-background {
    width: 92%;
    height: 100%;
    display: block;
}

/* Envelope Background - full canvas */
.envelope-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    z-index: 1;
}

/* Envelope Decorated Image - sits above background/cutlines/foldlines */
.envelope-image {
    position: absolute;
    top: 6.25%;
    left: 16.3%;
    width: 67.2%;
    height: 67.25%;
    object-fit: contain;
    display: block;
    z-index: 4;
}

/* Text Element Styles */
.text-element {
    position: absolute;
    cursor: default;
    padding: 0;
    z-index: 100;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Hover effect - blue border when hovering over unselected elements */
.text-element:not(.selected):hover textarea {
    border-color: #3498db;
}

/* Disable hover on ALL text elements when ANY element is selected */
.canvas:has(.text-element.selected) .text-element:not(.selected):hover textarea {
    border-color: transparent;
}

.text-element.selected textarea {
    border-color: #e74c3c;
}

.text-element textarea {
    width: 100%;
    border: 2px solid transparent;
    background: transparent;
    resize: none;
    box-sizing: border-box;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    text-align: inherit;
    outline: none;
    overflow: hidden;
    padding: 4px;
    transition: border-color 0.2s;
    cursor: default;
}

/* When editing, allow text cursor */
.text-element.editing textarea {
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

/* Top controls bar - drag handle left, delete right */
.text-controls-bar {
    position: absolute;
    top: -28px;
    left: 0;
    right: 0;
    height: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}

/* Show controls bar on hover OR when selected */
.text-element:hover .text-controls-bar,
.text-element.selected .text-controls-bar {
    opacity: 0.5;
}

/* Full opacity on direct hover of controls */
.text-element .text-controls-bar:hover {
    opacity: 1;
}

.text-controls-bar > * {
    pointer-events: auto;
}

/* Drag handle - top left */
.drag-handle {
    width: 24px;
    height: 24px;
    background: #3498db;
    border-radius: 4px;
    cursor: move;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: -1px;
}

.drag-handle:hover {
    background: #2980b9;
}

.drag-handle span {
    line-height: 0.5;
    font-weight: bold;
    letter-spacing: -2px;
}

/* Delete button - top right */
.delete-btn {
    width: 24px;
    height: 24px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.delete-btn:hover {
    background: #c0392b;
}

/* Resize handles - bottom corners */
.resize-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    background: #3498db;
    border-radius: 3px;
    z-index: 10;
    opacity: 0.5;
    transition: opacity 0.15s;
}

.resize-handle:hover {
    background: #2980b9;
    opacity: 1;
}

.resize-handle-bl {
    bottom: -8px;
    left: -8px;
    cursor: nesw-resize;
}

.resize-handle-br {
    bottom: -8px;
    right: -8px;
    cursor: nwse-resize;
}

/* Resize handle diagonal lines */
.resize-handle::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    border-right: 2px solid white;
    border-bottom: 2px solid white;
    top: 3px;
    left: 3px;
}

/* Mirror the bottom-left handle */
.resize-handle-bl::after {
    transform: scaleX(-1);
    left: auto;
    right: 3px;
}

/* Options Panel */
.options-panel {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    height: fit-content;
}

.option-section {
    margin-bottom: 25px;
}

.option-section h3 {
    font-size: 14px;
    color: #2c3e50;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.edit-hint {
    font-size: 13px;
    color: #7f8c8d;
    margin-bottom: 15px;
    font-style: italic;
}

.button-group {
    display: flex;
    gap: 8px;
}

.btn {
    padding: 10px 20px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    flex: 1;
}

.btn:hover {
    border-color: #3498db;
    background: #f8f9fa;
}

.btn.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.btn-primary {
    background: #27ae60;
    color: white;
    border-color: #27ae60;
    width: 100%;
}

.btn-primary:hover {
    background: #229954;
    border-color: #229954;
}

.nav-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.nav-btn {
    padding: 8px 16px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.nav-btn:hover:not(:disabled) {
    border-color: #3498db;
    background: #f8f9fa;
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.card-number {
    flex: 1;
    text-align: center;
    font-size: 14px;
    color: #7f8c8d;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: #555;
    font-weight: 500;
}

/* Font size row with slider and style buttons */
.font-size-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.font-size-slider {
    width: 100%;
}

.text-style-buttons {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.style-btn {
    width: 32px;
    height: 32px;
    border: 2px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
}

.style-btn:hover:not(:disabled) {
    border-color: #3498db;
    background: #f0f7fc;
}

.style-btn.active {
    background: #3498db;
    border-color: #3498db;
    color: white;
}

.style-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.form-group select,
.form-group input[type="number"],
.form-group input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: #3498db;
}

.color-picker-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.color-picker {
    width: 50px !important;
    height: 50px !important;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.color-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    flex: 1;
    max-width: 200px;
}

.color-preset {
    width: 38px !important;
    height: 38px !important;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
    min-width: 38px;
    min-height: 38px;
    display: block;
}

.color-preset:hover:not(:disabled) {
    border-color: #3498db;
    transform: scale(1.1);
}

.color-preset:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.color-value {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    font-family: monospace;
}

.align-buttons {
    display: flex;
    gap: 8px;
}

.align-btn {
    padding: 8px 0;
    border: 2px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    flex: 1;
    transition: all 0.2s;
}

.align-btn:hover {
    border-color: #3498db;
    background: #f8f9fa;
}

.align-btn.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.add-text-section {
    display: flex;
    gap: 8px;
}

.add-text-input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.add-text-btn {
    padding: 8px 20px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.add-text-btn:hover {
    background: #2980b9;
}

/* Template layer images - stack on top of each other */
.template-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* Logo positioning in bottom-right corner of inside quadrant */
.card-logo {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 80px;
    height: auto;
    pointer-events: none;
    z-index: 10;
}

/* Checkbox group styling */
.checkbox-group {
    display: flex;
    flex-direction: row;
    gap: 20px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.checkbox-label span {
    user-select: none;
}

/* Logo in top-right quadrant, rotated 180 degrees */
.logo-top-right-quadrant {
    position: absolute;
    top: 3%;
    right: 2.5%;
    width: 46%;
    height: 47%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 20px;
    z-index: 5;
    pointer-events: none;
}

/* Horizontal card orientation - logo vertically centered at guide position */
.logo-top-right-quadrant.horizontal {
    top: 25.4%;
    transform: translateY(-50%);
    align-items: center;
    justify-content: flex-end;
    padding-top: 0;
    padding-right: 20px;
}

.logo-top-right-quadrant.horizontal .logo-top-right {
    transform: rotate(-90deg);
}

.logo-top-right {
    width: 32%;
    height: auto;
    transform: rotate(180deg);
}

/* Rotation buttons */
.rotation-buttons {
    display: flex;
    gap: 5px;
    margin-bottom: 8px;
}

.rotate-btn {
    flex: 1;
    padding: 8px 4px;
    background: #ecf0f1;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.rotation-slider {
    width: 100%;
    margin-top: 5px;
}

.rotate-btn:hover:not(:disabled) {
    background: #3498db;
    color: white;
    border-color: #2980b9;
}

.rotate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* COMPREHENSIVE COLOR BUTTON FIX */
.color-preset,
button.color-preset,
.color-presets button {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    min-height: 38px !important;
    max-width: 38px !important;
    max-height: 38px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 2px solid #ddd !important;
    border-radius: 4px !important;
    box-sizing: border-box !important;
    display: inline-block !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
    flex-shrink: 0 !important;
}

.color-preset:disabled,
button.color-preset:disabled {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
}

.color-preset:hover:not(:disabled),
button.color-preset:hover:not(:disabled) {
    border-color: #3498db !important;
    transform: scale(1.1) !important;
}

/* Force color inputs to not inherit form-group width */
.form-group input[type="color"].color-picker {
    width: 50px !important;
    height: 50px !important;
    max-width: 50px !important;
    max-height: 50px !important;
}

/* Print Canvas - hidden on screen, shown only when printing */
.print-canvas {
    display: none;
}

/* Print Styles */
@media print {
    /* Remove ALL page margins */
    @page {
        margin: 0;
        size: letter portrait;
    }
    
    body {
        background: white;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .app-header,
    .controls-wrapper {
        display: none !important;
    }
    
    .main-content {
        display: block;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .app-container {
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .canvas-area {
        box-shadow: none;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* Hide editing canvas when printing */
    .editing-canvas {
        display: none !important;
    }
    
    /* Show print canvas when printing */
    .print-canvas {
        display: block !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .print-canvas .canvas-wrapper {
        padding-bottom: 0 !important;
    }
    
    .print-canvas .canvas {
        position: relative !important;
        width: 8.5in !important;
        height: 11in !important;
        transform: scale(0.98);
        transform-origin: center center;
    }
    
    .print-text-element {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    /* Canvas area first, options panel below */
    .canvas-area {
        order: 1;
    }
    
    .options-panel {
        order: 2;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 10px;
    }
    
    .app-header h1 {
        font-size: 24px;
    }
    
    .canvas-area,
    .options-panel {
        padding: 15px;
    }
    
    .edit-hint {
        display: none;
    }
}
/* Image Element Styles */
.image-element {
    position: absolute;
    cursor: default;
    padding: 0;
    z-index: 100;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.image-element:not(.selected):hover img {
    border-color: #3498db !important;
}

.canvas:has(.image-element.selected) .image-element:not(.selected):hover img,
.canvas:has(.text-element.selected) .image-element:not(.selected):hover img {
    border-color: transparent !important;
}

.image-element.selected img {
    border-color: #e74c3c !important;
}

.image-element img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    transition: border-color 0.2s;
}

.image-controls-bar {
    position: absolute;
    top: -28px;
    left: 0;
    right: 0;
    height: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}

.image-element:hover .image-controls-bar,
.image-element.selected .image-controls-bar {
    opacity: 0.5;
}

.image-element .image-controls-bar:hover {
    opacity: 1;
}

.image-controls-bar > * {
    pointer-events: auto;
}

/* Crop Overlay Styles */
.crop-overlay-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    pointer-events: all;
}

.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
    z-index: 10001;
}

.crop-rectangle {
    position: absolute;
    border: 2px dashed #fff;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    cursor: move;
    z-index: 10002;
}

.crop-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    background: #fff;
    border: 2px solid #3498db;
    border-radius: 50%;
    z-index: 10003;
    cursor: pointer;
}

.crop-handle-tl {
    top: -8px;
    left: -8px;
    cursor: nwse-resize;
}

.crop-handle-tr {
    top: -8px;
    right: -8px;
    cursor: nesw-resize;
}

.crop-handle-bl {
    bottom: -8px;
    left: -8px;
    cursor: nesw-resize;
}

.crop-handle-br {
    bottom: -8px;
    right: -8px;
    cursor: nwse-resize;
}

.crop-actions {
    position: absolute;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    white-space: nowrap;
    z-index: 10004;
}

.crop-btn {
    padding: 12px 32px;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    opacity: 1;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.crop-apply {
    background: #27ae60;
    color: white;
}

.crop-apply:hover {
    background: #229954;
    transform: scale(1.05);
}

.crop-cancel {
    background: #e74c3c;
    color: white;
}

.crop-cancel:hover {
    background: #c0392b;
    transform: scale(1.05);
}

/* Crop Shape Selector */
.crop-shape-selector {
    position: absolute;
    top: -45px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    background: rgba(0, 0, 0, 0.8);
    padding: 6px 12px;
    border-radius: 8px;
    z-index: 10005;
}

.shape-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    white-space: nowrap;
}

.shape-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.shape-btn.active {
    background: #3498db;
    border-color: #3498db;
    transform: scale(1.15);
}

/* Shape-specific crop outlines */
.crop-shape-rectangle {
    border: 2px dashed #fff;
    border-radius: 0;
}

.crop-shape-circle {
    border: 2px dashed #fff;
    border-radius: 50%;
}
/* Snap Guide Lines */
.snap-guide {
    position: absolute;
    background: #00BCD4;
    pointer-events: none;
    z-index: 10000;
    transition: opacity 0.15s ease;
}

.snap-guide-vertical {
    width: 2px;
    height: 100%;
    top: 0;
    border-left: 2px dashed #00BCD4;
    background: none;
}

.snap-guide-horizontal {
    height: 2px;
    width: 100%;
    left: 0;
    border-top: 2px dashed #00BCD4;
    background: none;
}
/* Card Picker Modal */
.card-picker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    padding: 20px;
}

.card-picker-modal {
    background: white;
    border-radius: 12px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.card-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.card-picker-header h2 {
    margin: 0;
    font-size: 24px;
    color: #2c3e50;
}

.card-picker-close {
    background: none;
    border: none;
    color: #e74c3c;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.card-picker-close:hover {
    background-color: #fee;
}

.card-picker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding: 24px;
}

.card-picker-item {
    width: 100%;
    border: 3px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    background: #f9f9f9;
}

.card-picker-item:hover {
    border-color: #3498db;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.card-picker-item.selected {
    border-color: #2ecc71;
    border-width: 4px;
}

.card-picker-item img {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
}

/* Responsive card picker */
@media (max-width: 768px) {
    .card-picker-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 16px;
    }
    
    .card-picker-header {
        padding: 16px;
    }
    
    .card-picker-header h2 {
        font-size: 20px;
    }
}

/* Half-fold card cover - add this to your style.css */
.card-cover-halffold {
    position: absolute;
    top: 5.3%;
    left: 10.3%;
    width: 83.4%;
    height: 43.8%;
    overflow: hidden;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-cover-halffold .card-background {
    transform: rotate(90deg);
    width: 147%;      /* Fill container */
    height: 147%;     /* Fill container */
    object-fit: contain;  /* Maintain aspect ratio */
    overflow: hidden;
    padding: 2px;
}

/* Half-fold logo - add this to your style.css */
.logo-halffold {
    position: absolute;
    bottom: 11.5%;
    left: 52%;
    transform: translate(-50%, 50%) rotate(90deg);
    width: 60%;
    height: 60%;
    z-index: 10;
}

/* Horizontal card variant for half-fold logo */
.logo-halffold.horizontal {
    bottom: 7.4%;           /* Move to bottom */
    left: 32%;            /* Center horizontally */
    transform: translate(-50%, 0) rotate(180deg);  /* Additional 90?? = 180?? total */
}

/* Centering guides for half-fold mode */
.center-guide-vertical {
    position: absolute;
    left: 53%;
    top: 0;
    width: 1px;
    height: 100%;
    background-color: rgba(0, 123, 255, 0.3);
    pointer-events: none;
    z-index: 1000;
}

.center-guide-horizontal-top {
    position: absolute;
    left: 0;
    top: 27%;  /* Top card boundary - adjust as needed */
    width: 100%;
    height: 1px;
    background-color: rgba(0, 123, 255, 0.3);
    pointer-events: none;
    z-index: 1000;
}

.center-guide-horizontal-bottom {
    position: absolute;
    left: 0;
    top: 72.5%;  /* Bottom card boundary (fold line) - adjust as needed */
    width: 100%;
    height: 1px;
    background-color: rgba(0, 123, 255, 0.3);
    pointer-events: none;
    z-index: 1000;
}

/* Half-fold envelope image - larger size and adjusted position */
.envelope-image-halffold {
    position: absolute;
    top: 14.5%;
    left: 6.4%;
    width: 87.2%;
    height: 47%;
    object-fit: fill;
    display: block;
    z-index: 4;
}
/* Panels Container - holds both panels side-by-side with equal height */
.panels-container {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    align-items: stretch;
}

.panels-container .options-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: auto;
}

/* Print Button Section */
.print-section {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Mobile layout for new structure */
@media (max-width: 1024px) {
    .mode-toggle-bar {
        max-width: none;
    }

    .main-content {
        order: 1;
        grid-template-columns: 1fr;
    }
    
    .controls-wrapper {
        order: 3;
        display: flex;
        flex-direction: column;
    }
    
    .print-section {
        order: 2;
        margin-bottom: 20px;
    }
    
    .panels-container {
        flex-direction: column;
        order: 4;
    }
}

/* Image mode: landscape aspect ratio for side-by-side layout */
.canvas-wrapper.image-mode {
    padding-bottom: 71.5%;
}

/* Image mode horizontal: portrait aspect ratio for stacked layout */
.canvas-wrapper.image-mode-horizontal {
    padding-bottom: 140%;
    min-height: 555px; /* Ensure minimum height matches export dimensions */
}
/* Save/Share Container - appears below canvas in image mode */
.save-share-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

/* Save Image Button - Green */
.save-image-btn {
    padding: 16px 24px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.save-image-btn:hover {
    background: #229954;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(39, 174, 96, 0.3);
}

/* Share Image Button - Pink/Magenta */
.share-image-btn {
    padding: 16px 24px;
    background: #e91e63;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.share-image-btn:hover {
    background: #c2185b;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(233, 30, 99, 0.3);
}

/* Social Share Panel - 2x3 grid */
.social-share-panel {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

/* Copy Image Button - white background to differentiate from social buttons */
.copy-btn {
    background: white;
    color: #333 !important;
    border: 2px solid #ddd;
}

.copy-btn:hover {
    background: #f8f9fa;
    border-color: #3498db;
}

/* Share button active state - light gray when panel is open */
.share-image-btn.active {
    background: #95a5a6;
}

.share-image-btn.active:hover {
    background: #7f8c8d;
}

/* Social Buttons Container - REMOVED, no longer needed */

/* Base Social Button Styles */
.social-btn {
    padding: 12px 16px;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.social-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}

/* Individual Social Platform Colors */
.facebook-btn {
    background: #1877F2;
}

.facebook-btn:hover {
    background: #145dbf;
}

.instagram-btn {
    background: #E4405F;
}

.instagram-btn:hover {
    background: #c13352;
}

.twitter-btn {
    background: #000000;
}

.twitter-btn:hover {
    background: #333333;
}

.pinterest-btn {
    background: #E60023;
}

.pinterest-btn:hover {
    background: #bd001e;
}

.line-btn {
    background: #00B900;
}

.line-btn:hover {
    background: #009600;
}

/* Mode Toggle Bar - Full width at top of app */
.mode-toggle-bar {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    max-width: 1270px; /* 650px canvas + 600px sidebar + 20px gap */
    margin-left: auto;
    margin-right: auto;
}

.mode-toggle-btn {
    flex: 1;
    padding: 14px 24px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s;
    text-align: center;
}

.mode-toggle-btn:hover {
    border-color: #3498db;
    background: #f8f9fa;
}

.mode-toggle-btn.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

/* Remove old mode-toggle-group styles */

/* Copy button success state */
.copy-btn.success {
    background: #27ae60;
    color: white;
    border-color: #27ae60;
}

/* Hide UI elements when printing */
@media print {
    .mode-toggle-bar,
    .save-share-container,
    .controls-wrapper,
    .text-controls-bar,
    .resize-handle {
        display: none !important;
    }
    
    /* Ensure canvas prints at full width */
    .canvas-wrapper {
        max-width: 100% !important;
        margin: 0 !important;
    }
    
    .main-content {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
}