.etc-customizer-launch {
    margin: 1.5em 0;
}

.etc-checkout-design-preview {
    display: block;
    width: 180px;
    height: 115px;
    object-fit: contain;
    margin: 8px 0;
    background: #fff;
    border: 1px solid #dcdcde;
}

.etc-cart-design-preview {
    margin-top: 8px;
}

.etc-checkout-block-design-preview {
    display: block;
    width: 180px;
    height: 115px;
    object-fit: contain;
    margin: 8px 0 12px;
    border: 1px solid #dcdcde;
    background: #fff;
}

.etc-checkout-design-line,
.etc-checkout-design-view {
    display: block;
    margin: 4px 0;
}

.etc-checkout-design-line small {
    display: block;
    color: #646970;
}

.etc-open-customizer,
.etc-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.9em 1.25em;
    background: #1a1a1a;
    color: #ffffff;
    border: none;
    border-radius: 999px;
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    max-width: 320px;
}

.etc-customizer-panel {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 999999;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.etc-customizer-panel.active {
    display: block;
}

.etc-customizer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.etc-customizer-content {
    position: absolute;
    inset: 0;
    margin: auto;
    width: min(100%, 1040px);
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    overflow: hidden;
    border-radius: 18px;
    overscroll-behavior: contain;
}

@media (max-width: 900px) {
    .etc-customizer-content {
        height: 100dvh;
        max-height: 100dvh;
    }
}

.etc-customizer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.3rem;
    padding: 0.55rem 0.85rem;
    border-bottom: 1px solid #ebebeb;
    background: #f7f7f7;
    min-height: auto;
    flex-wrap: nowrap;
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.02);
}

.etc-header-title-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    flex-wrap: nowrap;
    min-width: 0;
}

.etc-customizer-header h2 {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.15rem 0;
    letter-spacing: 0.01em;
}

.etc-header-actions {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: nowrap;
    justify-content: flex-end;
    overflow-x: visible;
    white-space: nowrap;
}

.etc-close-customizer {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 0.25rem;
    flex-shrink: 0;
}

.etc-tab-nav {
    display: flex;
    background: #f0f0f0;
    border-bottom: 1px solid #e0e0e0;
    padding: 0 1rem;
    gap: 0.25rem;
    flex-shrink: 0;
}

.etc-tab-btn {
    padding: 0.65rem 1.25rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: #666;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
}

.etc-tab-btn-inline {
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid #d9d9d9;
    font-size: 0.75rem;
    line-height: 1.1;
    white-space: nowrap;
    color: #333333;
    transition: all 0.2s ease;
}

.etc-tab-btn.active {
    color: #ffffff;
    border-color: #1a1a1a;
    background: #1a1a1a;
    font-weight: 600;
}

.etc-view-button.active {
    background: #1a1a1a;
    color: #ffffff;
    border-color: #1a1a1a;
}

.etc-customizer-preview,
.etc-customizer-controls {
    padding: 0.9rem;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    overscroll-behavior: contain;
}

.etc-customizer-preview {
    position: relative;
    align-self: start;
    max-width: 100%;
    width: 100%;
    overflow: visible;
    min-height: 0;
    z-index: 3;
}

.etc-flat-preview {
    position: sticky;
    top: 0;
    z-index: 3;
    max-width: 520px;
    width: 100%;
    margin: 0 auto;
    min-height: 220px;
}

.etc-flat-preview canvas {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    min-height: 140px;
}

.etc-customizer-body {
    display: grid;
    grid-template-columns: minmax(320px, 1.08fr) minmax(320px, 0.92fr);
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    align-items: start;
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 900px) {
    .etc-customizer-body {
        grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr) !important;
        gap: 2rem !important;
    }

    .etc-customizer-preview {
        padding-right: 0.75rem;
    }

    .etc-customizer-controls {
        width: 100%;
        padding-left: 0.75rem;
    }
}

.etc-customizer-preview,
.etc-customizer-controls {
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.etc-customizer-preview {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    order: 0;
    min-width: 0;
    max-width: 100%;
    min-height: 0;
}

.etc-customizer-controls {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 100%;
    width: min(100%, 420px);
    margin: 0 auto;
    padding-bottom: 1rem;
    position: relative;
    z-index: 1;
}

.etc-customizer-controls {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 100%;
    position: relative;
    z-index: 1;
}

.etc-customizer-body {
    gap: 1rem;
    min-height: 0;
}

.etc-preview-canvas canvas {
    width: 100% !important;
    height: 100% !important;
}

.etc-preview-canvas {
    width: 100%;
    min-height: 260px;
    height: min(48vh, 340px);
    background: #ffffff;
    border: 1px solid #d8dadd;
    border-radius: 16px;
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.etc-flat-preview {
    width: 100%;
    padding: 0.5rem 0.8rem 0.8rem;
    background: linear-gradient(180deg, #fbfbfb 0%, #f4f4f4 100%);
    border: 1px solid #ddd;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    margin: 0 auto;
    flex-shrink: 0;
}

.etc-flat-preview-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 0.75rem;
}

/* Ensure the label appears above decorative boundary lines */
.etc-flat-preview-label {
    position: relative;
    display: block;
    margin: 0 0 0.45rem 0;
    padding: 0.45rem 0.8rem;
    background: #fafafa;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #1a1a1a;
}

/* label moved out of preview so no pseudo-element mask needed */

.etc-drag-hint {
    font-size: 0.8rem;
    font-weight: 400;
    color: #888;
}

.etc-boundary-line {
    display: none !important;
}

.etc-3d-wrapper {
    display: none;
    flex-direction: column;
    flex: 1;
    gap: 0.75rem;
    min-height: 280px;
}

.etc-customizer-controls .etc-layer-section,
.etc-customizer-controls > .etc-step:last-child {
    display: none;
}

.etc-tab-3d-active .etc-flat-preview {
    display: none;
}

.etc-tab-3d-active .etc-customizer-controls {
    display: flex;
    width: min(100%, 420px);
    margin: 0;
    padding-top: 0.5rem;
    flex-direction: column;
    gap: 1rem;
}

.etc-tab-3d-active .etc-customizer-preview {
    overflow: visible;
    max-height: none;
}

.etc-tab-3d-active .etc-toggle-bar,
.etc-tab-3d-active .etc-step[data-section="text"],
.etc-tab-3d-active .etc-step[data-section="image"] {
    display: none !important;
}

.etc-tab-3d-active .etc-layer-section {
    display: flex !important;
    flex-direction: column;
    margin: 0;
}

.etc-tab-3d-active .etc-step:last-child {
    display: flex !important;
    margin: 20px;
}

.etc-tab-3d-active .etc-customizer-body {
    grid-template-columns: minmax(0, 1.15fr) minmax(260px, 420px);
}

.etc-tab-3d-active .etc-3d-wrapper {
    display: flex;
    flex: 1 1 auto;
    min-height: 320px;
    width: 100%;
}

.etc-tab-3d-active .etc-preview-controls {
    display: flex !important;
    width: 100%;
    flex-wrap: wrap;
    align-items: center;
    visibility: visible;
    opacity: 1;
}

#etc-texture-preview-canvas {
    width: 100%;
    height: auto;
    min-height: 140px;
    max-height: min(48vh, 260px);
    aspect-ratio: 2 / 1;
    object-fit: contain;
    display: block;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #ccc;
    box-shadow: inset 0 0 0 1px #d8d8d8;
    cursor: grab;
}

/* Allow vertical touch/trackpad panning on the preview canvas so two-finger
   scroll gestures reach the modal instead of being captured by the canvas */
#etc-texture-preview-canvas, .etc-preview-canvas {
    touch-action: pan-y;
}

@media (max-width: 900px) {
    .etc-customizer-content {
        width: 100%;
        height: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        box-shadow: none;
    }
    .etc-customizer-header {
        padding: 0.55rem 0.8rem;
        flex-shrink: 0;
    }
    .etc-header-title-group {
        flex-wrap: nowrap;
        gap: 0.45rem;
    }
    .etc-header-actions {
        gap: 0.2rem;
        width: auto;
        justify-content: flex-end;
        flex-wrap: nowrap;
        min-width: 0;
        flex-shrink: 0;
    }
    .etc-customizer-body {
        display: block;
        flex: 1 1 auto;
        overflow-y: auto;
        overflow-x: hidden;
        width: 100%;
        min-height: 0;
        height: 100%;
        -webkit-overflow-scrolling: touch;
    }
    .etc-customizer-preview,
    .etc-customizer-controls {
        display: block;
        width: 100%;
        max-width: 100%;
        padding: 0.85rem 0.8rem 1rem;
        overflow: visible;
        z-index: auto;
    }
    .etc-customizer-preview {
        position: relative;
        z-index: 3;
        order: 0;
        flex: none;
        max-height: none;
        min-height: 0;
        border-bottom: 1px solid #ececec;
    }
    .etc-customizer-controls {
        position: relative;
        z-index: 1;
        flex: none;
        max-height: none;
        border-top: none;
        width: 100%;
        max-width: 100%;
        padding-top: 0.9rem;
    }
    .etc-tab-3d-active .etc-customizer-body,
    .etc-tab-3d-active .etc-customizer-preview,
    .etc-tab-3d-active .etc-customizer-controls {
        display: block;
    }
    .etc-tab-3d-active .etc-customizer-preview {
        max-height: none;
        min-height: 0;
        overflow: visible;
    }
    .etc-tab-3d-active .etc-customizer-controls {
        max-height: none;
    }
    .etc-tab-3d-active .etc-3d-wrapper {
        display: flex;
        min-height: 300px;
        width: 100%;
    }
    .etc-preview-canvas {
        min-height: 220px;
        height: min(34vh, 260px);
    }
    .etc-flat-preview {
        padding: 1rem 0.7rem 0.8rem;
        width: 100%;
        max-width: 520px;
        margin: 0 auto;
    }
    .etc-step {
        margin-bottom: 0.8rem;
    }
    .etc-toggle-bar {
        margin-bottom: 0.65rem;
    }
    .etc-header-title-group {
        justify-content: space-between;
    }
    .etc-header-actions {
        flex-wrap: nowrap;
    }
    .etc-customizer-header h2 {
        font-size: 0.95rem;
    }
    .etc-tab-btn-inline {
        padding: 0.35rem 0.7rem;
        font-size: 0.8rem;
    }
    .etc-toggle-bar {
        margin-top: 0.5rem;
    }
    .etc-flat-preview {
        padding: 1rem 0.75rem 1.25rem;
        max-width: 100%;
    }
    .etc-field {
        padding: 0.75rem 0.85rem;
    }
    .etc-image-action-row {
        gap: 0.45rem;
    }
    #etc-texture-preview-canvas {
        min-height: 140px;
        max-height: 200px;
    }
    .etc-preview-controls {
        position: static;
        background: transparent;
        border-radius: 0;
        padding: 0.5rem 0;
        margin-top: 0.5rem;
    }
    .etc-view-button {
        min-width: 60px;
        padding: 0.55rem 0.8rem;
    }
}

@media (max-width: 640px) {
    .etc-customizer-header {
        padding: 0.25rem 0.75rem 0.4rem;
    }
    .etc-header-title-group {
        flex-wrap: wrap;
        justify-content: space-between;
    }
    .etc-header-actions {
        width: auto;
        justify-content: flex-end;
        flex-wrap: nowrap;
        min-width: 0;
    }
    .etc-customizer-preview,
    .etc-customizer-controls {
        padding: 0.75rem;
    }
    .etc-flat-preview {

        padding: 0.5rem 0.75rem 1.2rem;
        max-width: 310px;
    }
    .etc-preview-canvas {
        min-height: 220px;
        height: 240px;
    }
    #etc-texture-preview-canvas {
        min-height: 120px;
        max-height: 200px;
    }
    .etc-preview-controls {
        max-width: 330px !important;
        padding: 0.4rem 0.5rem;
        gap: 0.45rem;
    }
    .etc-view-button {
        min-width: 58px;
        padding: 0.55rem 0.7rem;
    }
    .etc-layer-item {
        grid-template-columns: 1fr;
    }
}
.etc-model-selector {
    width: 100%;
    border-radius: 16px;
    border: 1px solid #ddd;
    background: #fafafa;
    padding: 0.85rem;
}

.etc-model-selector label {
    display: block;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.etc-model-selector select {
    width: 100%;
}

.etc-preview-controls {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.25rem;
    max-width: 503px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    position: sticky;
    bottom: 0;
    background: linear-gradient(#ffffff, rgba(255,255,255,0.95));
    padding: 0.5rem 0.75rem 0.5rem 0.75rem;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-right: 28px;
}

.etc-zoom-panel {
    flex: 1 1 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: #333;
    touch-action: manipulation;
}

.etc-zoom-panel label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.etc-zoom-panel input[type="range"] {
    flex: 1;
}

.etc-view-button {
    flex: 1 1 auto;
    min-width: 70px;
    padding: 0.65rem 0.9rem;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
    border-radius: 999px;
    box-sizing: border-box;
    text-align: center;
}

.etc-step {
    margin-bottom: 1.25rem;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 1rem;
}

.etc-step.etc-layer-section {
    border: 1px solid #e5e5e5;
    padding-top: 1rem;
    margin-top: 1rem;
}

.etc-toggle-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.etc-toggle-section {
    flex: 1 1 auto;
    min-width: 140px;
    border-radius: 999px;
    border: 1px solid #d9d9d9;
    background: #fff;
    color: #1a1a1a;
    cursor: pointer;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
}

.etc-toggle-section.active {
    background: #1a1a1a;
    color: #fff;
    border-color: #1a1a1a;
}

.etc-step-hidden {
    display: none;
}

.etc-step h3 {
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.etc-step label {
    display: block;
    margin-bottom: 0.85rem;
    font-weight: 500;
    color: #1a1a1a;
    font-size: 20px;
    line-height: 1.4;
}

.etc-step label .etc-field {
    margin-top: 0.4rem;
}

.etc-field {
    width: 100%;
    padding: 0.85rem;
    margin-bottom: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 10px;
    box-sizing: border-box;
}

.etc-font-preview {
    margin: 0.75rem 0;
    padding: 0.9rem 1rem;
    border: 1px solid #ddd;
    border-radius: 12px;
    background: #fafafa;
    color: #1a1a1a;
    min-height: 3.2rem;
    line-height: 1.4;
    white-space: pre-wrap;
}

.etc-note {
    margin: 0 0 0.75rem;
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
    background: #f2f7ff;
    border: 1px solid #dfe7fb;
    color: #1f3d7a;
    font-size: 0.95rem;
}

.full-width {
    width: 100%;
}

.etc-layer-list {
    display: grid;
    gap: 0.75rem;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
    
}

.etc-layer-item {
    background: #f8f8f8;
    border: 1px solid #ddd;
    border-radius: 14px;
    padding: 0.85rem;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
    align-items: start;
    cursor: pointer;
}

.etc-layer-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.etc-layer-content strong {
    word-break: break-word;
}

.etc-layer-move-controls,
.etc-layer-resize-controls {
    display: flex;
    gap: 0.3rem;
    font-size: 0.85rem;
.etc-image-layer-controls {
    margin-top: 0.75rem;
    padding: 0.75rem;
    border: 1px solid #e2e2e2;
    border-radius: 10px;
    background: #fafafa;
}
.etc-image-layer-controls[hidden] {
    display: none;
}
.etc-image-position-controls {
    display: grid;
    grid-template-columns: repeat(4, 2.25rem);
    gap: 0.4rem;
    justify-content: start;
    margin-top: 0.6rem;
}
.etc-image-position-controls .etc-move-btn {
    width: 2.25rem;
    height: 2.25rem;
}
}

.etc-layer-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.etc-layer-font-select {
    min-width: 120px;
    border-radius: 8px;
}

.etc-move-btn,
.etc-resize-btn {
    min-width: 32px;
    min-height: 32px;
    padding: 0.3rem 0.5rem;
    background: #e0e0e0;
    border: 1px solid #999;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.etc-move-btn:hover,
.etc-resize-btn:hover {
    background: #d0d0d0;
}

.etc-layer-item strong {
    word-break: break-word;
}

.etc-layer-editing {
    background: #e8f5e9;
    border-color: #4caf50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
}

.etc-layer-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.etc-small-button {
    max-width: 90px;
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
}

.etc-image-action-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.etc-image-action-row .etc-button {
    flex: 1;
    max-width: none;
    min-width: 120px;
}

.etc-outline-button {
    background: transparent !important;
    color: #1a1a1a !important;
    border: 2px solid #1a1a1a !important;
}

.etc-outline-button:hover {
    background: #f5f5f5 !important;
}

.etc-outline-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.etc-editing-mode {
    background: #4caf50;
}

.etc-editing-mode:hover {
    background: #45a049;
}

.etc-layer-section {
    padding: 1rem;
    border-radius: 12px;
    text-align: center;
    margin-top: 0.5rem;
}

.etc-section-info {
    background: #f0f0f0;
    border: 2px dashed #999;
    color: #666;
    font-size: 0.9rem;
}

.etc-section-label {
    font-weight: 500;
}

.etc-no-layers {
    color: #999;
    text-align: center;
    padding: 1rem 0;
    font-size: 0.95rem;
}

@media (max-width: 900px) {
    .etc-layer-item {
        grid-template-columns: 1fr;
    }
    
    .etc-layer-controls {
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .etc-customizer-body {
        grid-template-columns: 1fr !important;
    }
    
    .etc-customizer-preview {
        order: -1;
        max-width: 350px;
        
    }
    
    .etc-preview-canvas {
        max-width: 350px!important;
        min-height: 300px !important;
        flex: 0 0 200px !important;
    }
    
    #etc-texture-preview-canvas {
        min-height: 180px !important;
    }
    
    .etc-customizer-controls {
        max-width: 350px;
    }
    
    .etc-customizer-header {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.3rem 0.75rem;
    }
    
    .etc-customizer-header h2 {
        font-size: 0.79rem;
        font-weight: bold;
        margin: 0;
    }
     .etc-tab-btn-inline {
        padding: 0.2rem 0.5rem !important;
        font-size: 0.7rem !important;
    }
}

@media (min-width: 768px) {
    .etc-tab-nav {
        display: none;
    }

    .etc-customizer-body {
        grid-template-columns: 1.4fr 0.9fr;
    }

    .etc-preview-canvas {
        min-height: 300px;
        flex: 0 0 300px;
    }
    .etc-tab-btn-inline {
        padding: 0.2rem 0.5rem;
        font-size: 0.8rem;
    }
}

@media (min-width: 1100px) {
    .etc-customizer-body {
        grid-template-columns: 1.3fr 1fr;
    }

    .etc-preview-canvas {
        min-height: 400px;
        flex: 1 1 auto;
    }
}

/* Responsive styles for mug template preview */
@media (max-width: 768px) {
    .etc-flat-preview {
        padding: 1rem 0.5rem 0.8rem;
    }
    
    .etc-flat-preview-label {
        margin-bottom: 0.5rem;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .etc-flat-preview {
        padding: 0.8rem 0.4rem 0.6rem;
    }
    
    #etc-texture-preview-canvas {
        min-height: 100px;
    }
    
    .etc-flat-preview-label {
        font-size: 0.8rem;
        margin-bottom: 0.4rem;
    }
}