.customizer-page {
    padding: 2rem 0;
}

@media (max-width: 768px) {
    .customizer-page {
        padding: 1rem 0;
    }
}

.customizer-container {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
    width: 100%;
    /* Don't stretch columns to equal height, so the sticky preview
       has room to scroll within its (taller) options column. */
    align-items: start;
}

/* Let both columns shrink below their content size. Without this,
   grid items default to min-width:auto and a single wide child can
   force the track wider than the screen, overflowing to the right
   (which the site's global overflow-x:hidden then clips off). */
.customizer-container > * {
    min-width: 0;
    max-width: 100%;
}

@media (max-width: 1200px) {
    .customizer-container {
        grid-template-columns: 1fr 380px;
        gap: 1.5rem;
    }
}

@media (max-width: 960px) {
    .customizer-container {
        grid-template-columns: minmax(0, 1fr);
        gap: 1.5rem;
    }
    
    .preview-section {
        position: relative !important;
        top: 0 !important;
        order: -1;
    }

    /* Hard guard: nothing in the customizer may exceed the screen width */
    .customizer-page,
    .customizer-container,
    .preview-section,
    .customizer-panel {
        max-width: 100%;
        overflow-x: hidden;
    }
}

.collection-restricted-banner {
    background: linear-gradient(135deg, #fffdf9 0%, var(--ivory-silk, #F5F0E1) 100%);
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--accent-color, #B87C6F);
    border-radius: 12px;
    padding: 0.9rem 1.15rem;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--text-secondary);
    box-shadow: var(--box-shadow);
}
.collection-restricted-banner strong {
    display: block;
    margin-bottom: 0.15rem;
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

.preview-section {
    background: linear-gradient(135deg, #F5F0E1 0%, #E8D0B1 100%);
    padding: 2rem;
    border-radius: 12px;
    position: sticky;
    top: 100px;
    align-self: start;
    height: fit-content;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(58, 61, 72, 0.08);
    border: 1px solid rgba(184, 124, 111, 0.2);
}

@media (max-width: 960px) {
    .preview-section {
        padding: 1.5rem;
        position: relative !important;
        top: 0 !important;
        max-height: none;
        overflow-y: visible;
    }
}

@media (max-width: 480px) {
    .preview-section {
        padding: 1rem;
    }
}

.preview-canvas {
    position: relative;
    background: #fff;
    border-radius: var(--border-radius);
    overflow: hidden;
    /* Portrait flats (SanMar / dealer) read better taller than square */
    aspect-ratio: 3 / 4;
    width: 100%;
    max-width: 100%;
}

/* Fallback for browsers that don't support aspect-ratio (older mobile)
   so the preview never collapses to zero height and disappears. */
@supports not (aspect-ratio: 1) {
    .preview-canvas { min-height: 380px; }
}

/* On phones/tablets keep the preview from filling the whole
   screen, so the color/size/design controls below stay visible. */
@media (max-width: 960px) {
    .preview-canvas {
        max-width: min(100%, 70vh);
        margin-left: auto;
        margin-right: auto;
    }
}

.mockup-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    transition: opacity 0.3s ease;
    position: relative;
    z-index: 1;
}

#mockupImage {
    transition: opacity 0.3s ease;
}

/* Spinner shown while the mockup image is fetching */
.preview-canvas.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(0,0,0,0.1);
    border-top-color: var(--terra-cotta, #c0634b);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    z-index: 10;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.design-layer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: transform 0.3s ease;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}
.design-layer.is-fitting {
    opacity: 0;
}

.design-layer.visible {
    /* visibility is controlled in JS so Center Back can hide the front overlay */
}

.design-layer.visible.draggable {
    cursor: move;
    pointer-events: auto;
    user-select: none;
}
.design-layer.dragging {
    transition: none !important;
}

.design-image:not([src]),
.design-image[src=""],
.design-image[hidden] {
    display: none !important;
}
.design-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

/* Placement-specific sizing - preview only (print inches are unchanged).
   Width is driven by applyDesignFit from ordered print inches → mockup %.
   These CSS defaults are the adult-M center fallback before JS runs. */
.design-layer[data-placement="center_chest"] {
    width: 38%;
    max-width: 54%;
    max-height: 44%;
    min-height: 44px;
    top: 38%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Left chest = appears on RIGHT side of mockup (wearer's left when wearing).
   JS applyDesignPosition hangs this from the measured garment, not the card. */
.design-layer[data-placement="left_chest"] {
    width: 14%;
    max-width: none;
    max-height: 20%;
    top: 26%;
    left: 61%;
    transform: translate(-50%, -50%);
}

/* Right chest = appears on LEFT side of mockup (wearer's right when wearing) */
.design-layer[data-placement="right_chest"] {
    width: 14%;
    max-width: none;
    max-height: 20%;
    top: 26%;
    left: 39%;
    transform: translate(-50%, -50%);
}

/* Tanks have no sleeves, so the tee card-% looks like a neckline stamp.
   These are the first-paint fallback; JS still sizes from the garment. */
.preview-section.is-tank .design-layer[data-placement="left_chest"] {
    width: 12%;
    max-height: 16%;
    top: 32%;
    left: 62%;
}
.preview-section.is-tank .design-layer[data-placement="right_chest"] {
    width: 12%;
    max-height: 16%;
    top: 32%;
    left: 38%;
}

.design-layer[data-placement="center_back"] {
    width: 38%;
    max-width: 54%;
    max-height: 44%;
    top: 38%;
    left: 50%;
    transform: translate(-50%, -50%);
}
/* Back name/number: same visual size on every shirt. Width grows on one line. */
.design-layer-back {
    flex-direction: column;
    width: auto;
    max-width: 58%;
    top: 34%;
    left: 50%;
    transform: translate(-50%, -50%);
    cursor: grab;
    pointer-events: auto;  /* override base .design-layer pointer-events:none */
    user-select: none;
    -webkit-user-select: none;
}
/* Uploaded back art uses the same 38% garment target as center-front.
   Name/number keep the auto-width rules above. */
.design-layer-back.is-upload {
    width: 38%;
    max-width: none;
    max-height: 46%;
    height: auto;
}
.design-layer-back.is-upload .design-image {
    width: 100%;
    height: auto;
}
.design-layer-back.dragging { cursor: grabbing; transition: none !important; }
.back-design-text-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #fff;
    /* Most jersey fonts are drawn bold; Varsity Regular overrides to 400 in JS
       because College has no true bold and faux-bold wrecks large digits. */
    font-weight: 700;
    width: auto;
    max-width: none;
    text-shadow: none;
}
/* Name stays on one horizontal line. Width grows; height never shrinks. */
.back-design-name {
    line-height: 1;
    text-align: center;
    display: block;
    width: auto;
    max-width: none;
    white-space: nowrap;
    overflow: visible;
    transform-origin: center center;
}
.back-design-number {
    line-height: 1;
    text-align: center;
    display: block;
    width: auto;
    white-space: nowrap;
}

/* Offer to soften a picture's right edge */
.back-fade-offer { margin: 0.75rem 0; padding: 0.85rem 1rem; border: 1px solid var(--border-color, #e3d6c6); border-radius: 12px; background: #fffaf3; }
.back-fade-offer p { margin: 0 0 0.6rem; font-size: 0.9rem; line-height: 1.45; }
.back-fade-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.back-fade-done { margin: 0 !important; }
.back-fade-undo { background: none; border: 0; padding: 0; color: var(--btn-rose, #a1574d); text-decoration: underline; cursor: pointer; font: inherit; }
/* Back design colour & outline controls */
.bd-color-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.bd-color-input {
    width: 46px;
    height: 38px;
    padding: 2px;
    border: 1px solid var(--border-color, #e8d0b1);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    flex-shrink: 0;
}
.bd-swatches { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.bd-swatch {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,0.15);
    cursor: pointer;
    padding: 0;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.bd-swatch:hover { transform: scale(1.12); }
.bd-swatch.active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--terra-cotta); }
.bd-check { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-weight: 500; }
.bd-check input { width: 18px; height: 18px; flex-shrink: 0; cursor: pointer; }
.coll-style-locked-notice {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.55rem 0.85rem; border-radius: 8px;
    background: rgba(184,124,111,0.1); border: 1px solid rgba(184,124,111,0.3);
    color: var(--text-secondary); font-size: 0.82rem; margin-bottom: 0.75rem;
}

.preview-controls {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.preview-controls button {
    flex: 1;
    font-weight: 600;
    transition: all 0.3s ease;
}

.preview-controls button.active {
    background: var(--terra-cotta);
    color: #fff;
    border-color: var(--terra-cotta);
}

.customizer-panel {
    background: #fff;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(58, 61, 72, 0.08);
    border: 1px solid rgba(232, 208, 177, 0.3);
}

@media (max-width: 768px) {
    .customizer-panel {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .customizer-panel {
        padding: 1rem;
        border-radius: 0;
        box-shadow: none;
        border-top: 1px solid var(--border-color);
    }
}

.panel-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.panel-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .panel-section {
        margin-bottom: 1.5rem;
        padding-bottom: 1.5rem;
    }
    
    .panel-section h3 {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .panel-section {
        margin-bottom: 1.25rem;
        padding-bottom: 1.25rem;
    }
}

/* The page heading. It is an h1 for document structure, sized as the h2 it
   used to be because the customizer panel is narrow. */
.customize-product-title {
    font-size: clamp(1.7rem, 2.6vw, 2.2rem);
    line-height: 1.2;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: manual;
}

@media (max-width: 768px) {
    .customize-product-title { font-size: 1.6rem; }
}

.product-feel {
    margin: 0.35rem 0 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.product-feel-softness {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--terra-cotta, #b87c6f);
    letter-spacing: 0.02em;
}
.product-feel-fabric {
    font-size: 0.875rem;
    color: var(--text-secondary, #6b6b6b);
    line-height: 1.4;
}

.panel-section h3 {
    font-size: 1.25rem;
    margin-bottom: 1.25rem;
    color: #1a1a1a;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.panel-section h3::after {
    content: '';
    display: block;
    width: 40px;
    height: 3px;
    background: linear-gradient(90deg, var(--terra-cotta), transparent);
    margin-top: 0.5rem;
}

.color-grid-professional {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
    max-height: none;
    min-height: 8rem;
    overflow: visible;
    padding: 1rem;
    background: rgba(245, 240, 225, 0.3);
    border-radius: 12px;
    border: 1px solid rgba(232, 208, 177, 0.3);
}

.color-grid-professional::-webkit-scrollbar {
    width: 8px;
}

.color-grid-professional::-webkit-scrollbar-track {
    background: rgba(232, 208, 177, 0.2);
    border-radius: 4px;
}

.color-grid-professional::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--terra-cotta) 0%, var(--aged-bronze) 100%);
    border-radius: 4px;
}

.color-grid-professional::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--aged-bronze) 0%, var(--terra-cotta) 100%);
}

@media (max-width: 768px) {
    .color-grid-professional {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .color-grid-professional {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
        gap: 0.5rem;
        max-height: none;
        overflow: visible;
    }
}

/* Color Filter Tabs */
.color-filter-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-tab {
    padding: 0.625rem 1.25rem;
    background: #fff;
    border: 2px solid #E8D0B1;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    white-space: nowrap;
    min-height: 44px;
    touch-action: manipulation;
}

.filter-tab:hover {
    border-color: var(--terra-cotta);
    background: rgba(184, 124, 111, 0.05);
    transform: translateY(-2px);
}

.filter-tab.active {
    background: linear-gradient(135deg, var(--terra-cotta) 0%, var(--aged-bronze) 100%);
    border-color: var(--terra-cotta);
    color: #fff;
    box-shadow: 0 4px 12px rgba(184, 124, 111, 0.3);
}
.back-design-tab { line-height: 1.2; }
.back-design-tab .tab-sub { display: block; margin-top: 0.15rem; font-size: 0.68rem; font-weight: 500; letter-spacing: 0.02em; text-transform: none; opacity: 0.85; }
.back-design-tab[hidden] { display: none; }
.back-design-tab.active {
    background: linear-gradient(135deg, var(--terra-cotta) 0%, var(--aged-bronze) 100%);
    color: #fff;
    border-color: var(--terra-cotta);
}

@media (max-width: 768px) {
    .filter-tab {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }

    /* Do NOT re-cap height here. A later max-height with overflow:visible
       lets color cards paint over Size / Upload sections on phones. */
    .color-grid-professional {
        max-height: none;
        overflow: visible;
    }
    
    .color-search-input {
        padding: 0.75rem 1rem 0.75rem 2.75rem;
        font-size: 0.9rem;
    }
    
    .search-icon {
        width: 16px;
        height: 16px;
        left: 0.875rem;
    }
}

@media (max-width: 480px) {
    .color-filter-tabs {
        gap: 0.375rem;
    }
    
    .filter-tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        flex: 1 1 auto;
        min-width: 70px;
    }
}

/* Step sections - simple, organized flow */
.step-section {
    position: relative;
    padding-left: 3rem;
}

@media (max-width: 480px) {
    .logo-gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .step-section {
        padding-left: 2.5rem;
    }
    .position-btn, .position-btn-reset {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }
}
.step-badge {
    position: absolute;
    left: 0;
    top: 0;
    width: 2rem;
    height: 2rem;
    background: var(--accent-color);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}
.step-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: -0.25rem 0 0.75rem 0;
}
.color-filter-tabs-simple {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

/* Logo gallery inline */
.logo-gallery-inline {
    margin-bottom: 1rem;
}
.logo-gallery-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
.logo-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 0.5rem;
}
.logo-gallery-item {
    cursor: pointer;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    text-align: center;
    transition: var(--transition);
    background: #fff;
}
.logo-gallery-item:hover {
    border-color: var(--accent-color);
}
.logo-gallery-item.selected {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(184, 124, 111, 0.25);
}
.logo-gallery-item img {
    width: 100%;
    height: 70px;
    object-fit: contain;
    display: block;
    margin: 0 auto 0.35rem;
}
.logo-gallery-item span,
.logo-gallery-item-label {
    display: block;
    font-size: 0.7rem;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gallery-design-picker {
    margin-bottom: 1rem;
}
.gallery-design-select {
    width: 100%;
    min-height: 44px;
}
.gallery-design-selected {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.6rem;
    padding: 0.5rem 0.65rem;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}
.gallery-design-selected img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    flex-shrink: 0;
}
.gallery-design-selected span {
    font-size: 0.85rem;
    color: var(--text-primary);
}
.jersey-logo-locked {
    display:flex; align-items:center; gap:.85rem;
    padding:.75rem; border:1px solid var(--border-color); border-radius:12px; background:#fff;
}
.jersey-logo-locked img { width:72px; height:72px; object-fit:contain; }
.jersey-logo-locked p { margin:0; font-weight:600; }

.cust-group-header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.85rem 0 0.15rem;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--terra-cotta, #b87c6f);
}
.cust-group-header::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color, #e0d8cc);
}
.cust-group-header:first-child { margin-top: 0; }

.gallery-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 0.65rem;
    margin-top: 0.5rem;
}
.gallery-image-grid .logo-gallery-item {
    aspect-ratio: 1;
    margin: 0;
    padding: 0.35rem;
}
.gallery-image-grid .logo-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.gallery-image-grid .logo-gallery-item-label {
    display: none;
}
.logo-gallery-item {
    position: relative;
}
.logo-gallery-color-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 1.15rem;
    height: 1.15rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    background: var(--terra-cotta, #b87c6f);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1.15rem;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
}
.logo-color-chooser {
    margin-top: 0.75rem;
    padding: 0.85rem 0.9rem;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
}
.logo-color-chooser[hidden] {
    display: none !important;
}
.logo-color-chooser-label {
    margin: 0 0 0.65rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.logo-color-chooser-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 0.55rem;
}
.logo-color-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: #fafafa;
    cursor: pointer;
    font: inherit;
    color: inherit;
}
.logo-color-option:hover {
    border-color: var(--terra-cotta, #b87c6f);
}
.logo-color-option.selected {
    border-color: var(--terra-cotta, #b87c6f);
    box-shadow: 0 0 0 2px rgba(184, 124, 111, 0.22);
    background: #fff;
}
.logo-color-option img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    display: block;
}
.logo-color-option span {
    font-size: 0.72rem;
    line-height: 1.2;
    text-align: center;
    word-break: break-word;
}
.upload-rights-note {
    margin-top: 0.75rem;
    padding: 0.75rem 0.85rem;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--text-secondary);
}
.production-timeline-note {
    margin: 0.75rem 0 0;
    padding: 0.85rem 1rem;
    background: rgba(184, 124, 111, 0.08);
    border-left: 3px solid var(--terra-cotta, #b87c6f);
    border-radius: 0 8px 8px 0;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.back-design-offer-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.back-design-fee-amount {
    flex-shrink: 0;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-size: 1.25rem;
    color: var(--terra-cotta-text, #9A5F52);
}
@media (max-width: 420px) {
    .back-design-offer-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }
}
.or-divider {
    text-align: center;
    color: var(--text-light);
    font-size: 0.85rem;
    margin: 1rem 0;
}

/* Color Search Box */
.color-search-box {
    position: relative;
    margin-bottom: 1rem;
}

.color-search-input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem;
    border: 2px solid #E8D0B1;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: #fff;
}

.color-search-input:focus {
    outline: none;
    border-color: var(--terra-cotta);
    box-shadow: 0 0 0 3px rgba(184, 124, 111, 0.15);
    background: #F5F0E1;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    pointer-events: none;
}

.color-card {
    cursor: pointer;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #fff;
    border: 3px solid #e8e8e8;
    position: relative;
}

.color-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 24px rgba(184, 124, 111, 0.25);
    border-color: var(--terra-cotta);
}

@media (max-width: 480px) {
    .color-card {
        min-height: 44px;
    }
}

.color-card.hidden {
    display: none !important;
}

.color-card.selected {
    border-color: var(--terra-cotta);
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.25), 0 8px 24px rgba(0, 0, 0, 0.15);
    transform: scale(1.05);
}

.color-image-wrapper {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    background: #f9f9f9;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.color-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.color-placeholder {
    width: 100%;
    height: 100%;
    min-height: 100%;
}
.color-placeholder.color-fallback {
    position: absolute;
    inset: 0;
}

.color-name {
    padding: 0.75rem 0.5rem;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: #333;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    text-transform: capitalize;
}

.color-checkmark {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: var(--terra-cotta);
    color: white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.color-card.selected .color-checkmark {
    display: flex;
}

.size-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 0.5rem;
}

.size-grid-professional {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
    gap: 0.75rem;
    margin-top: 1.5rem;
}

@media (max-width: 768px) {
    .size-grid-professional {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 0.6rem;
    }
}

@media (max-width: 480px) {
    .size-grid-professional {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 0.5rem;
    }
}

.size-card {
    padding: 1.25rem 0.75rem;
    text-align: center;
    border: 3px solid #e8e8e8;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #fff;
    position: relative;
    min-height: 48px;
    touch-action: manipulation;
}

@media (max-width: 480px) {
    .size-card {
        padding: 1rem 0.5rem;
    }
    
    .size-label {
        font-size: 1.1rem;
    }
    
    .stock-badge {
        font-size: 0.65rem;
    }
}

.size-card:hover {
    border-color: var(--terra-cotta);
    background: rgba(212, 175, 55, 0.05);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.size-card.selected {
    background: linear-gradient(135deg, var(--terra-cotta), var(--aged-bronze));
    color: #fff;
    border-color: var(--terra-cotta);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
}

.size-card.out-of-stock {
    opacity: 0.35;
    cursor: not-allowed;
    background: #f9f9f9;
}

.size-card.out-of-stock:hover {
    transform: none;
    box-shadow: none;
    border-color: #e8e8e8;
}

/* Spec Sheet Link (anchor or button) */
.spec-sheet-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 1rem;
    padding: 0.25rem 0.75rem;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    transition: var(--transition);
    white-space: nowrap;
    cursor: pointer;
    font-family: inherit;
    line-height: inherit;
}

.spec-sheet-link:hover {
    color: var(--terra-cotta-text, #9A5F52);
    border-color: var(--accent-color);
    transform: translateY(-1px);
}

.spec-sheet-link:active {
    transform: translateY(0);
}

/* Responsive spec sheet link */
@media (max-width: 768px) {
    .spec-sheet-link {
        display: block;
        margin: 0.5rem 0 0 0;
        text-align: center;
        width: fit-content;
    }
}

.size-label {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stock-badge {
    font-size: 0.7rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.size-card.selected .size-label,
.size-card.selected .stock-badge {
    color: #fff;
}

.size-upcharge-badge {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--terra-cotta, #b56c4c);
    margin-top: 0.15rem;
    margin-bottom: 0.15rem;
    letter-spacing: 0.01em;
}

.size-card.selected .size-upcharge-badge {
    color: rgba(255, 255, 255, 0.9);
}

@media (max-width: 480px) {
    .size-upcharge-badge {
        font-size: 0.6rem;
    }
}

.placement-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.scale-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; margin-top: 1rem; }
.scale-grid .scale-option { padding: 0.9rem 0.5rem; }
.scale-grid .scale-option small { display: block; margin-top: 0.2rem; }
.scale-grid .scale-option .scale-price { font-weight: 600; color: var(--terra-cotta-text, #9A5F52); }
@media (max-width: 480px) {
    .scale-grid { grid-template-columns: 1fr; }
    .placement-grid {
        grid-template-columns: 1fr;
        gap: 0.6rem;
    }
    
    .placement-option, .scale-option {
        padding: 1rem;
    }
}

.placement-option, .scale-option {
    padding: 1.25rem 1rem;
    text-align: center;
    border: 3px solid #e8e8e8;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #fff;
    position: relative;
}

.placement-option strong, .scale-option strong {
    font-size: 1rem;
    color: #333;
}

.placement-option small, .scale-option small {
    font-size: 0.75rem;
    color: #666;
}

.placement-option:hover, .scale-option:hover {
    border-color: var(--terra-cotta);
    background: rgba(212, 175, 55, 0.05);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.placement-option.selected, .scale-option.selected {
    border-color: var(--terra-cotta);
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), rgba(212, 175, 55, 0.05));
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.3);
    transform: scale(1.03);
}

.placement-option.selected strong, .scale-option.selected strong {
    color: var(--terra-cotta-text, #9A5F52);
}

.placement-option.selected::after, .scale-option.selected::after {
    content: '✓';
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 24px;
    height: 24px;
    background: var(--terra-cotta);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.875rem;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    min-height: 48px;
    touch-action: manipulation;
}

@media (max-width: 768px) {
    .upload-area {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .upload-area {
        padding: 1.25rem;
    }
    
    .upload-area svg {
        width: 36px !important;
        height: 36px !important;
    }
    
    .upload-area p {
        font-size: 0.9rem;
    }
}

.upload-area:hover {
    border-color: var(--accent-color);
    background: rgba(212, 175, 55, 0.05);
}

.upload-area.dragover {
    border-color: var(--accent-color);
    background: rgba(212, 175, 55, 0.1);
}

.design-preview {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--secondary-color);
    border-radius: var(--border-radius);
    display: none;
}

.design-preview.active {
    display: block;
}

.design-preview img {
    max-width: 100%;
    max-height: 150px;
    object-fit: contain;
}

.design-warnings {
    margin-top: 1rem;
}

.warning-item {
    padding: 0.75rem;
    background: rgba(245, 158, 11, 0.1);
    border-left: 3px solid var(--warning-color);
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

/* ===== Artwork inspector (background-removal preview) ===== */
.artwork-inspector .ai-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(16, 185, 129, 0.12);
    color: #047857;
    border: 1px solid rgba(16, 185, 129, 0.35);
    border-radius: var(--border-radius);
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
}
.artwork-inspector .ai-status svg { width: 18px; height: 18px; flex-shrink: 0; }
.ai-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    max-height: 280px;
    border-radius: var(--border-radius);
    overflow: hidden;
    background-color: #fff;
}
.ai-stage.bg-checker {
    background-color: #fff;
    background-image:
        linear-gradient(45deg, #d9dde3 25%, transparent 25%),
        linear-gradient(-45deg, #d9dde3 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #d9dde3 75%),
        linear-gradient(-45deg, transparent 75%, #d9dde3 75%);
    background-size: 18px 18px;
    background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}
.ai-stage.bg-light { background-color: #e9ecef; background-image: none; }
.ai-stage.bg-dark { background-color: #2b2f36; background-image: none; }
.ai-stage .ai-img {
    max-width: 100%;
    max-height: 260px;
    object-fit: contain;
    display: block;
}
.ai-stage .ai-img-original { display: none; }          /* needs the .ai-stage prefix: ".ai-stage .ai-img { display:block }" is more specific, and used to show the before AND after pictures side by side, each cut off */
.ai-stage.show-before .ai-img-original { display: block; }
.ai-stage.show-before .ai-img-result { display: none; }
.ai-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.6rem;
}
.ai-toggle, .ai-bg-toggle {
    display: inline-flex;
    border: 1px solid #dcdfe4;
    border-radius: 999px;
    overflow: hidden;
    background: #fff;
}
.ai-toggle-btn, .ai-bg-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0.32rem 0.72rem;
    font-size: 0.78rem;
    color: #555;
}
.ai-toggle-btn.active, .ai-bg-btn.active {
    background: var(--primary-color, #111);
    color: #fff;
}
.ai-zoom-btn {
    margin-left: auto;
    border: 1px solid #dcdfe4;
    background: #fff;
    border-radius: 999px;
    cursor: pointer;
    padding: 0.32rem 0.8rem;
    font-size: 0.78rem;
    color: #555;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.ai-white-note { font-size: 0.8rem; color: #555; margin-top: 0.5rem; }
.ai-more { margin-top: 0.5rem; }
.ai-more > summary { cursor: pointer; font-size: 0.85rem; color: var(--text-secondary); min-height: 44px; display: flex; align-items: center; }
.ai-controls { justify-content: flex-end; }
.ai-more .ai-controls { justify-content: flex-start; margin-top: 0.3rem; }
.ai-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.ai-zoom-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 18, 22, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.ai-zoom-modal[hidden] { display: none; }

.ai-zoom-stage {
    max-width: 92vw;
    max-height: 86vh;
    overflow: auto;
    border-radius: 10px;
    background-color: #fff;
    background-image:
        linear-gradient(45deg, #d9dde3 25%, transparent 25%),
        linear-gradient(-45deg, #d9dde3 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #d9dde3 75%),
        linear-gradient(-45deg, transparent 75%, #d9dde3 75%);
    background-size: 22px 22px;
    background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}
.ai-zoom-stage img { display: block; max-width: none; image-rendering: -webkit-optimize-contrast; }
.ai-zoom-bar { position: fixed; top: 1rem; right: 1rem; display: flex; gap: 0.5rem; }
.ai-zoom-bar button {
    background: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1;
}
.ai-zoom-hint {
    position: fixed;
    bottom: 1rem;
    left: 0;
    right: 0;
    text-align: center;
    color: #cfd3da;
    font-size: 0.8rem;
}

.price-summary {
    background: var(--secondary-color);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
}

.price-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.price-total {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--terra-cotta-text, #9A5F52);
    border-top: 2px solid var(--border-color);
    padding-top: 0.5rem;
    margin-top: 0.5rem;
}

.add-to-cart-hint {
    margin: 0.7rem 0 0;
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-secondary);
    text-align: center;
}
.add-to-cart-hint[hidden] {
    display: none !important;
}

@media (max-width: 1024px) {
    .customizer-container {
        grid-template-columns: minmax(0, 1fr);
    }
    
    .preview-section {
        position: static;
        max-height: none;
        overflow-y: visible;
    }
}

/* Position Control Buttons */
.position-btn, .position-btn-reset {
    padding: 0.6rem 1rem;
    font-size: 0.875rem;
    min-height: 44px;
    min-width: 44px;
    background: #fff;
    border: 1px solid var(--terra-cotta);
    color: var(--terra-cotta-text, #9A5F52);
    border-radius: 4px;
    cursor: pointer;
    touch-action: manipulation;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 600;
}

.position-btn:hover, .position-btn-reset:hover {
    background: var(--terra-cotta);
    color: #fff;
}

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

.position-btn svg {
    width: 14px;
    height: 14px;
}

.pos-controls-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

/* Size Chart Button & Modal */
.size-chart-btn-customize {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--accent-color);
    color: #fff;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.size-chart-btn-customize:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.size-chart-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 1rem;
}

.size-chart-content {
    background: #fff;
    padding: 2rem;
    border-radius: var(--border-radius);
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
}

.size-chart-content h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.size-chart-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.size-chart-table th,
.size-chart-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.size-chart-table th {
    background: var(--secondary-color);
    font-weight: 600;
    color: var(--text-primary);
}

.size-chart-table tbody tr:hover {
    background: var(--secondary-color);
}

.size-chart-table tr:last-child td {
    border-bottom: none;
}

/* ── Tabbed Design Picker ──────────────────────────────────────── */
.design-picker-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.75rem;
}
.design-tab-btn {
    padding: 0.4rem 1rem;
    border-radius: 999px;
    border: 1.5px solid var(--terra-cotta, #b87c6f);
    background: transparent;
    color: var(--terra-cotta, #b87c6f);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
    line-height: 1.3;
    font-family: inherit;
}
.design-tab-btn:hover {
    background: rgba(184,124,111,0.1);
}
.design-tab-btn.active {
    background: var(--terra-cotta, #b87c6f);
    color: #fff;
    box-shadow: 0 2px 6px rgba(184,124,111,0.3);
}
.design-tab-count {
    opacity: 0.75;
    font-weight: 400;
    font-size: 0.72rem;
}
.design-search-wrap {
    position: relative;
    margin-bottom: 0.75rem;
}
.design-search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
    font-size: 0.85rem;
    pointer-events: none;
    line-height: 1;
}
.design-search-input {
    width: 100%;
    border: 1.5px solid #ddd;
    border-radius: 999px;
    padding: 0.5rem 2.4rem 0.5rem 2.2rem;
    font-size: 16px;
    outline: none;
    transition: border-color 0.15s;
    box-sizing: border-box;
    font-family: inherit;
    background: #fff;
}
.design-search-input:focus {
    border-color: var(--terra-cotta, #b87c6f);
}
.design-search-clear {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
    font-size: 1rem;
    line-height: 1;
    padding: 0.2rem;
    display: none;
}
.design-search-clear:hover { color: #555; }
.design-picker-counter {
    font-size: 0.78rem;
    color: var(--text-light, #999);
    text-align: center;
    margin-top: 0.5rem;
    min-height: 1.1em;
}
.design-empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary, #888);
    display: none;
}
.design-empty-icon { font-size: 2rem; margin-bottom: 0.4rem; }
.design-empty-state a {
    color: var(--terra-cotta, #b87c6f);
    cursor: pointer;
    text-decoration: underline;
}
.design-show-more-btn {
    display: none;
    margin: 0.75rem auto 0;
    padding: 0.45rem 1.4rem;
    border-radius: 999px;
    border: 1.5px solid var(--terra-cotta, #b87c6f);
    background: transparent;
    color: var(--terra-cotta, #b87c6f);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
}
.design-show-more-btn:hover {
    background: var(--terra-cotta, #b87c6f);
    color: #fff;
}
.design-browse-prompt {
    font-size: 0.85rem;
    color: var(--text-light, #aaa);
    text-align: center;
    padding: 1.25rem 0 0.5rem;
    font-style: italic;
}

/* ── Viewport-fit mockup layout ─────────────────────────────────────────
   The preview is visual only. Production dimensions remain driven by the
   selected size and server-side print charts. */
.customizer-page {
    padding: 0.75rem 0 2rem;
}
.preview-color-badge {
    position: absolute;
    left: 0.65rem;
    bottom: 0.65rem;
    z-index: 20;
    max-width: calc(100% - 1.3rem);
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.38rem 0.65rem;
    border: 1px solid rgba(184, 124, 111, 0.22);
    border-radius: 999px;
    background: rgba(255, 252, 249, 0.9);
    box-shadow: 0 4px 14px rgba(58, 42, 34, 0.1);
    backdrop-filter: blur(8px);
    color: var(--text-secondary);
    font-size: 0.68rem;
    line-height: 1;
}
.preview-color-badge span {
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.preview-color-badge strong {
    overflow: hidden;
    color: var(--terra-cotta, #b87c6f);
    font-size: 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.preview-note {
    position: static;
    max-width: 100%;
    margin: 0.5rem 0 0;
    padding: 0.4rem 0.75rem;
    color: #5a4a42;
    background: rgba(184,124,111,0.08);
    border: 1px solid rgba(184,124,111,0.2);
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    font-style: italic;
    letter-spacing: 0.01em;
    line-height: 1.4;
    text-align: center;
}
.preview-info {
    margin: 0;
    padding: 0;
    text-align: center;
}
.color-picker-disclosure {
    overflow: hidden;
    border: 1px solid rgba(184, 124, 111, 0.28);
    border-radius: 12px;
    background: #fffcfa;
    box-shadow: 0 5px 16px rgba(58, 42, 34, 0.06);
}
.color-picker-disclosure summary {
    min-height: 58px;
    padding: 0.7rem 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.color-picker-disclosure summary::-webkit-details-marker { display: none; }
.color-picker-summary-value { min-width: 0; display: flex; flex-direction: column; gap: 0.12rem; }
.color-picker-summary-value small { color: var(--text-secondary); font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; }
.color-picker-summary-value strong { overflow: hidden; color: var(--text-primary); font-family: var(--font-heading); font-size: 1rem; text-overflow: ellipsis; white-space: nowrap; }
.color-picker-summary-action { flex: 0 0 auto; color: var(--terra-cotta, #b87c6f); font-size: 0.78rem; font-weight: 700; }
.color-picker-summary-action span { display: inline-block; transition: transform 0.2s ease; }
.color-picker-disclosure[open] .color-picker-summary-action span { transform: rotate(180deg); }
.color-picker-dropdown { padding: 0.65rem; border-top: 1px solid rgba(184, 124, 111, 0.18); background: #fff; }
.color-picker-dropdown .color-grid-professional {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
    max-height: none;
    min-height: 0;
    padding: 0.65rem;
    overflow: visible;                 /* the page scrolls, never a box inside it */
}

@media (min-width: 961px) {
    .customizer-container {
        grid-template-columns: minmax(0, 1fr) clamp(360px, 33vw, 420px);
        gap: 1rem;
        padding: 0 0.75rem;
    }
    .preview-section {
        top: 88px;
        height: calc(100vh - 160px);
        height: calc(100svh - 160px);
        min-height: 390px;
        max-height: none;
        padding: 0.75rem;
        display: grid;
        grid-template-columns: 116px minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) auto;
        gap: 0.55rem 0.7rem;
        overflow: hidden;
    }
    .preview-canvas {
        grid-column: 2;
        grid-row: 1;
        width: 100%;
        min-height: 0;
        aspect-ratio: auto;
    }
    .preview-note {
        grid-column: 2;
        grid-row: 2;
    }
    .mockup-image {
        object-fit: contain;
        object-position: center;
    }
    .preview-controls {
        grid-column: 1;
        grid-row: 1;
        align-self: start;
        flex-direction: column;
        gap: 0.45rem;
        margin: 1.65rem 0 0;
    }
    .preview-controls button {
        width: 100%;
        min-height: 40px;
        padding: 0.45rem 0.3rem;
        border-radius: 9px;
        font-size: 0.72rem;
    }
    .preview-info {
        grid-column: 1;
        grid-row: 1;
        align-self: end;
        min-width: 0;
    }
    .preview-info #dragHint {
        margin: 0 0 0.4rem !important;
        font-size: 0.66rem !important;
        line-height: 1.25;
    }
    .preview-info .pos-controls-row {
        flex-direction: column;
        gap: 0.35rem;
    }
    .preview-info .position-btn,
    .preview-info .position-btn-reset {
        width: 100%;
        min-width: 0;
        min-height: 36px;
        padding: 0.4rem 0.25rem;
        justify-content: center;
        border-radius: 8px;
        font-size: 0.7rem;
    }
}

@media (min-width: 961px) and (max-height: 620px) {
    .preview-section {
        height: calc(100vh - 145px);
        height: calc(100svh - 145px);
        min-height: 330px;
    }
}

@media (max-width: 960px) {
    .customizer-container {
        gap: 1rem;
        padding: 0 0.75rem;
    }
    .preview-section {
        padding: 0.75rem;
        max-height: none;
        overflow: visible;
    }
    .preview-canvas {
        width: 100%;
        height: min(56vh, 560px);
        height: min(56svh, 560px);
        min-height: 330px;
        max-width: none;
        aspect-ratio: auto;
    }
    .mockup-image {
        object-fit: contain;
        object-position: center;
    }
    .preview-controls {
        gap: 0.55rem;
        margin-top: 0.55rem;
    }
    .preview-controls button {
        min-height: 44px;
        border-radius: 9px;
    }
}

@media (max-width: 640px) {
    .customizer-page {
        padding-top: 0.35rem;
    }
    .customizer-container {
        padding: 0 0.4rem;
        gap: 0.65rem;
    }
    .preview-section {
        padding: 0.5rem;
        border-radius: 10px;
    }
    .preview-canvas {
        height: min(48vh, 420px);
        height: min(48svh, 420px);
        min-height: 280px;
        border-radius: 9px;
    }
    .preview-note {
        margin-top: 0.35rem;
        padding: 0 0.35rem;
        font-size: 0.63rem;
    }
    .preview-color-badge {
        left: 0.45rem;
        bottom: 0.45rem;
        max-width: calc(100% - 0.9rem);
    }
}

/* A short note for one shirt: closed until wanted, quiet when open */
.item-note-section { margin-top: 0.25rem; }
.item-note { border: 1px solid #e8dccb; border-radius: 12px; background: #fffdf9; padding: 0.15rem 0.9rem; }
.item-note > summary { cursor: pointer; list-style: none; padding: 0.75rem 0; font-weight: 600; color: #4a3f36; display: flex; align-items: center; gap: 0.4rem; min-height: 44px; }
.item-note > summary::-webkit-details-marker { display: none; }
.item-note > summary::before { content: '+'; display: inline-flex; width: 1.4rem; height: 1.4rem; border-radius: 50%; border: 1px solid #b87c6f; color: #9A5F52; align-items: center; justify-content: center; font-weight: 700; line-height: 1; }
.item-note[open] > summary::before { content: '\2212'; }
.item-note-optional { font-weight: 400; color: #8a7d70; }
.item-note-label { display: block; margin: 0 0 0.4rem; font-size: 0.9rem; color: #5a4e44; }
.item-note textarea { width: 100%; resize: vertical; font-size: 1rem; }
.item-note-help { margin: 0.4rem 0 0.8rem; font-size: 0.8rem; color: #8a7d70; }

.item-note-count { display: block; margin-top: 0.2rem; color: #8a7d70; font-variant-numeric: tabular-nums; }
.item-note-count.near-limit { color: #9A5F52; font-weight: 600; }
