.showing-modal {
    overflow: hidden;
}

/* Full-Screen Modal with Background Overlay */
.design-modal {
    opacity: 1;
    backdrop-filter: blur(10px);
    background-color: rgb(0 0 0 / var(--tw-bg-opacity));
    --tw-bg-opacity: 0.5;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    display: none;
    flex-direction: column;
    padding: 0 20px;
    z-index: 999;
}

.design-modal--active {
    display: block !important;
}

/* Auto-Height Modal Content */
.design-modal-content {
    border-radius: 0;
    max-width: 100%;
    margin: 50px auto;
    display: flex;
    flex-direction: column;
    background-color: rgb(255 255 255 / 1);
    position: relative;
}

.design-modal-content-top {
    background-color: #f3ece5;
    width: 100%;
    height: 420px;
    max-width: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center
}

.design-showcase-image {
    object-fit: cover;
    height: inherit;
    width: 100%;
    position: relative;
    z-index: 1;
}

.design-showcase-text {
    position: absolute;
    font-size: 2rem;
    width: 50%;
    color: rgb(0 0 0 / 0.3);
    font-weight: 600;
    letter-spacing: 0.2rem;
}

.design-modal-file-upload-wrapper {
    position: absolute;
    cursor: pointer;
    bottom: 10px;
    right: 10px;
    z-index: 3;
}

#ring_overlay {
    z-index: 2;
}

.design-modal-file-upload-content {
    position: relative;
    width: 102px;
    height: 38px;
    overflow: hidden;
    cursor: pointer;
    border-radius: 1rem;
}

.design-modal-file-upload-content input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
}

.design-modal-file-upload-content .upload-btn {
    display: flex;
    justify-content: center;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 10px 8px;
    background-color: #fff;
    text-decoration: none;
    cursor: pointer;
    color: #000;
    text-transform: uppercase;
    font-size: 0.9rem;
    gap: 2px;
}

.design-modal-file-upload-content--pulse {
    animation: pulse 1s infinite;
}

.design-modal-file-upload-content:hover {
    opacity: 0.8;
}

.design-modal-upload-svg {
    position: relative;
    top: -3px;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
    }
}

.design-modal-content h2 {
    font-size: 1.5rem;
    line-height: 2rem;
    color: rgb(82 82 82 / 1);
}

#design-image-container .design-text {
    font-size: 1rem;
    line-height: 2rem;
    color: rgb(82 82 82 / 1);
}

.design-modal-content {
    margin: 5% auto;
    width: 100%;
    text-align: center;
}

.design-modal-content--large {
    max-width: 100%;
    width: 100%;
}

.design-close {
    display: flex;
    float: right;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    background: #fff;
    padding: 4px;
    right: 12px;
    top: 12px;
    border-radius: 50%;
    height: 26px;
    width: 26px;
    justify-content: center;
    align-items: center;
    z-index: 3;
}

#design-category-list {
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    list-style: none;
    margin-top: 10px;
    gap: 4px;
}

#design-category-list li {
    background-color: #f3ece5;
    border-radius: 25px;
    box-shadow: none;
    color: #000;
    height: 28px;
    min-width: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
}

#design-category-list li:hover {
    background-color: #000;
    color: #fff;
}

.design-modal-external-url {
    display: flex;
    justify-content: center;
}

.external-url-btn {
    margin: 0 0 10px;
    padding: 0 12px;
    background-color: #000;
    border-radius: 25px;
    box-shadow: none;
    color: #fff;
    height: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
}

.external-url-btn:hover {
    color: #fff;
    opacity: 0.8;
}

.design-category-item {
    cursor: pointer;
}

.is-design-category-active {
    background-color: #000 !important;
    color: #fff !important;
}

.is-design-category-disabled {
    opacity: 0.5;
}

#design-image-container {
    margin: 16px 0 16px;
}

/* Design Images */
#design-images {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 0 12px;
}

.design-thumbnail-wrapper {
    display: flex;
    width: 90px;
    height: 90px;
    position: relative;
    border: 2px solid #f3ece5;
    cursor: pointer;
}

.design-thumbnail-wrapper:hover {
    border: 2px solid #000;
}

.design-thumbnail-wrapper img {
    object-fit: contain;
    height: 100%;
    width: 100%;
}

.design-thumbnail-wrapper--active {
    border-color: #000;
}

.design-image {
    border-radius: 10px;
    transition: transform 0.3s;
}

#hand-image-container {
    position: relative;
    margin-top: 20px;
}

#design-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#prev-image, #next-image {
    margin: 10px;
    padding: .25rem .5rem;
    text-transform: none;
    cursor: pointer;
    border: none;
    border-radius: 0;
    background-color: rgb(0 0 0 / 1);
    color: #fff;
    font-size: .875rem;
    line-height: 1.25rem;
}

#prev-image:hover, #next-image:hover {
    background-color: rgb(0 0 0 / 0.7);
}

#image-upload-container {
    margin-top: 20px;
}

#hand_image_container {
    max-width: 400px;
    justify-content: center;
    display: flex;
    margin: 20px auto;
}

#hand_image_container #hand_image {
    width: 100%;
    height: 500px;
    max-width: 100%;
    display: none;
}

#hand_image_container #ring_overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    max-width: 12%;
    cursor: move;
}

#image-controls {
    margin-top: -25px;
}

.design-modal-footer {
    display: none;
    gap: 10px;
    justify-content: space-between;
    position: relative;
    margin: 10px 0 0;
    padding:  0 12px 0;
}

.design-modal-footer--active {
    display: flex;
}

.design-modal-footer label {
    color: #000;
    font-size: 0.9rem;
}

.design-modal-actions {
    display: flex;
    flex-direction: row;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 10px;
    padding: 0;
}

.action-design-button {
    padding: .25rem .5rem;
    text-transform: none;
    cursor: pointer;
    border-radius: 0;
    color: #fff;
    font-size: 1rem;
    line-height: 1.45rem;
    background-color: rgb(0 0 0 / 1);
}

.action-design-button:hover {
    background-color: rgb(0 0 0 / 0.7);
    color: #fff;
}

.design-modal-footer input[type=range] {
    -webkit-appearance: none;
    margin: 10px 0;
    width: 100%;
}

.design-modal-footer input[type=range]:focus {
    outline: none;
}

.design-modal-footer input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    cursor: pointer;
    box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
    background: #f3ece5;
    border-radius: 10px;
    border: 0px solid #000101;
}

.design-modal-footer input[type=range]::-webkit-slider-thumb {
    box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
    border: 0px solid #000000;
    height: 16px;
    width: 30px;
    border-radius: 7px;
    background: #000;
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -3.6px;
}

.design-modal-footer input[type=range]:focus::-webkit-slider-runnable-track {
    background: #f3ece5;
}

.design-modal-footer input[type=range]::-moz-range-track {
    width: 100%;
    height: 12.8px;
    cursor: pointer;
    animate: 0.2s;
    box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
    background: #f3ece5;
    border-radius: 10px;
    border: 0px solid #000101;
}

.design-modal-footer input[type=range]::-moz-range-thumb {
    box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
    border: 0px solid #000000;
    height: 20px;
    width: 39px;
    border-radius: 7px;
    background: #000;
    cursor: pointer;
}

.design-modal-footer input[type=range]::-ms-track {
    width: 100%;
    height: 12.8px;
    cursor: pointer;
    animate: 0.2s;
    background: transparent;
    border-color: transparent;
    border-width: 39px 0;
    color: transparent;
}

.design-modal-footer input[type=range]::-ms-fill-lower {
    background: #f3ece5;
    border: 0px solid #000101;
    border-radius: 50px;
    box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
}

.design-modal-footer input[type=range]::-ms-fill-upper {
    background: #f3ece5;
    border: 0px solid #000101;
    border-radius: 50px;
    box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
}

.design-modal-footer input[type=range]::-ms-thumb {
    box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
    border: 0px solid #000000;
    height: 20px;
    width: 39px;
    border-radius: 7px;
    background: #000;
    cursor: pointer;
}

.design-modal-footer input[type=range]:focus::-ms-fill-lower {
    background: #f3ece5;
}

.design-modal-footer input[type=range]:focus::-ms-fill-upper {
    background: #f3ece5;
}

.circle-size-slider-input input[type=range] {
    -webkit-appearance: none;
    margin: 10px 0;
    width: 100%;
}

.circle-size-slider-input input[type=range]:focus {
    outline: none;
}

.circle-size-slider-input input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    cursor: pointer;
    box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
    background: #f3ece5;
    border-radius: 10px;
    border: 0px solid #000101;
}

.circle-size-slider-input input[type=range]::-webkit-slider-thumb {
    box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
    border: 0px solid #000000;
    height: 16px;
    width: 30px;
    border-radius: 7px;
    background: #000;
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -3.6px;
}

.circle-size-slider-input input[type=range]:focus::-webkit-slider-runnable-track {
    background: #f3ece5;
}

.circle-size-slider-input input[type=range]::-moz-range-track {
    width: 100%;
    height: 12.8px;
    cursor: pointer;
    animate: 0.2s;
    box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
    background: #f3ece5;
    border-radius: 10px;
    border: 0px solid #000101;
}

.circle-size-slider-input input[type=range]::-moz-range-thumb {
    box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
    border: 0px solid #000000;
    height: 20px;
    width: 39px;
    border-radius: 7px;
    background: #000;
    cursor: pointer;
}

.circle-size-slider-input input[type=range]::-ms-track {
    width: 100%;
    height: 12.8px;
    cursor: pointer;
    animate: 0.2s;
    background: transparent;
    border-color: transparent;
    border-width: 39px 0;
    color: transparent;
}

.circle-size-slider-input input[type=range]::-ms-fill-lower {
    background: #f3ece5;
    border: 0px solid #000101;
    border-radius: 50px;
    box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
}

.circle-size-slider-input input[type=range]::-ms-fill-upper {
    background: #f3ece5;
    border: 0px solid #000101;
    border-radius: 50px;
    box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
}

.circle-size-slider-input input[type=range]::-ms-thumb {
    box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
    border: 0px solid #000000;
    height: 20px;
    width: 39px;
    border-radius: 7px;
    background: #000;
    cursor: pointer;
}

.circle-size-slider-input input[type=range]:focus::-ms-fill-lower {
    background: #f3ece5;
}

.circle-size-slider-input input[type=range]:focus::-ms-fill-upper {
    background: #f3ece5;
}

.main-sizer-bg {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #F8F8F8;
    border-radius: 0;
    overflow: hidden;
}

.paper-bg {
    width: 100%;
    height: 100%;
    background-image: linear-gradient(to right, rgba(212, 175, 55, 0.1) 1px, transparent 1px), linear-gradient(to bottom, rgba(212, 175, 55, 0.1) 1px, transparent 1px);
    background-size: 15px 15px;
}

.ring-sizer-wrapper {
    padding: 26px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    color: #999;
}

.diameter-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 120px;
}

#ringCircle {
    border: 3px dashed #444;
    border-radius: 50%;
    background-color: #f3ece5;
    width: 16mm;
    height: 16mm;
    transition: all 0.2s ease;
}

.diameter-label {
    margin-top: 10px;
    font-size: 16px;
    font-weight: bold;
    color: #222;
    text-align: center;
}

.ruler {
    display: flex;
    gap: 2px;
    justify-content: center;
    margin: 10px 0;
    border-top: 2px solid #000;
    position: relative;
}

.ruler .cm {
    width: 1cm;
    height: 10px;
    border-left: 1px solid #000;
    font-size: 10px;
    position: relative;
    top: -10px;
    text-align: center;
}

#circleArea {
    margin: 10px auto;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 80px;
}

.ball-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 10px 0;
}

.ball {
    border: 1px solid #000;
    border-radius: 50%;
    background: #f5f5f5;
}

.design-modal {
    overscroll-behavior: contain;
}
body.showing-modal {
    overflow: hidden; /* prevent background scroll on mobile */
}

/* Keep your existing styles ... */

.calibration {
    padding: 16px 26px 0;
    color: #666;
}
.calibration-row {
    display: flex;
    justify-content: center;
    margin: 10px 0 6px;
}
.calibration-card {
    /* This rectangle is defined in real millimeters BEFORE scaling.
       We then apply a calibration "scale" to the entire measurement area. */
    width: 85.6mm;  /* Standard credit card width */
    height: 53.98mm; /* Standard credit card height */
    border: 2px dashed #999;
    border-radius: 6px;
    background: #f3ece5;
    );
}
.calibration-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    padding-bottom: 10px;
}
.calibration-controls input[type="range"] {
    width: 300px;
    max-width: 90vw;
}
.calibration-meta {
    font-size: 12px;
}
.btn-link {
    background: none;
    border: none;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    color: #333;
}

/* SCALE AREA: everything inside is scaled by the calibration factor */
#ringSizerScaleArea {
    transform-origin: top center;
    /* transform: scale(var(--ring-scale, 1)); applied via JS inline style for broader support */
}

/* Your original styles kept (with a tiny tweak) */
.diameter-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 170px; /* a bit taller to make room for larger rings */
}

.calibration-vert {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6px 0 10px;
}

.calib-arrows {
    position: relative;
    width: 40px;                /* fixed width; height is set via JS */
    display: flex;
    flex-direction: column;
    align-items: center;
}

#calibLine {
    width: 2px;
    background: #999;
    height: 100px;              /* placeholder; real height set by JS */
    position: relative;
}

.arrow {
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
}
.arrow-top {
    border-bottom: 12px solid #666;   /* triangle pointing down */
    margin-bottom: 6px;
}
.arrow-bottom {
    border-top: 12px solid #666;      /* triangle pointing up */
    margin-top: 6px;
}

/* Optional tick marks every ~5 mm */
#calibLine::before {
    content: "";
    position: absolute;
    left: -4px;
    top: 0;
    bottom: 0;
    background:
            repeating-linear-gradient(
                    to bottom,
                    transparent 0,
                    transparent calc(5mm),
                    currentColor calc(5mm),
                    currentColor calc(5mm + 1px)
            );
    width: 10px;
    color: rgba(0,0,0,0.15);
}

#ringCircle.ring-circle {
    border: 3px dashed #444;
    border-radius: 50%;
    background-color: #f3ece5;
    width: 16mm;  /* defined in mm; calibration will scale this whole area */
    height: 16mm;
    transition: width 0.2s ease, height 0.2s ease, transform 0.2s ease;
}

/* Optional: improve slider tap targets on mobile */
.circle-size-slider-input input[type="range"] {
    width: 100%;
    touch-action: pan-y;
}

.ring-sizer-table {
    padding: 20px;
    font-size: 14px;
}

.ring-sizer-table h3 {
    margin-bottom: 10px;
}

.ring-sizer-table {
    flex: 1;
    min-width: 250px;
}

.ring-sizer-table table {
    width: 100%;
    border-collapse: collapse;
}

.ring-sizer-table tr {
    cursor: pointer;
}

.ring-sizer-table thead {
    background-color: #f3ece5;
}

.ring-sizer-table tr:hover {
    background-color: #f3ece5;
}

.ring-sizer-table th, .ring-sizer-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: center;
}

.ring-circles {
    flex: 2;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 20px;
    justify-items: center;
}

.ring-config-button {
    padding-bottom: 0 !important;
    display: flex !important;
    justify-content: center;
    text-align: center;
    color: #000;
    align-items: center;
    text-transform: uppercase;
    font-size: 14px;
}

.ring-configurator-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 10px;
    align-items: center;
    gap: 14px;
    border-top: 1px solid #f1f1f1;
    padding-top: 10px;
}

.thumbnail_image-model-view {
    height: auto !important;
    display: flex !important;
    justify-content:center !important;
    align-items:center !important;
    cursor:pointer;
}

.thumbnail_image-model-view img {
    height: 64px !important;
}

.ring-configuration-button-wrapper {
    position: relative;
    display: flex;
    gap: 14px;
    align-items: center;
    height: auto !important;
}

.ring-configurator-thumb {
    position: relative;
    text-align: center;
    width: 100px;
    height: 76px !important;
    cursor: pointer;
    background-color: #FFE4EA;
}

.ring-configurator-thumb img {
    height: 100% !important;
}

.ring-model-viewer-button {
    width: 100px;
    height: 100px;
    position: relative;
    background-color: transparent;
    border: 1px solid #000;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.ring-model-viewer-button img {
    width: 90px !important;
    height: 90px !important;
}

.ring-configuration-info {
    display: none;
    position: relative;
    color: #000;
    background: #FFE4EA;
    font-weight: bold;
    padding: 7px 8px;
    top: 0;
    font-size: 11px;
    height: min-content;
}

.ring-configuration-info::before {
    content: "";
    position: absolute;
    /* top: 100%; */
    left: -14px;
    transform: rotate(90deg);
    border: 7px solid transparent;
    border-top: 9px solid #FFE4EA;
}

.ring-configuration-text {
    width: 100%;
    position: absolute;
    display: flex;
    top: 45%;
    justify-content: center;
    align-items: center;
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 700;
    text-align: center;
}

.nivoda-3d-icon-wrapper {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 99;
}

.woocommerce-product-gallery {
    position: relative;
}

.model-view-container {
    width:100%;
    height: 300px;
    background: white;
}

.ring-size-modal-attribute-btn {
    display: flex;
    align-items: center;
    background-color: #fff;
    -webkit-box-shadow: 0 0 0 1px #a8a8a8;
    box-shadow: 0 0 0 1px #a8a8a8;
    color: #000;
    cursor: pointer;
    height: 30px;
    justify-content: center;
    margin: 4px;
    position: relative;
    width: auto;
    border-radius: 2px;
    padding: 0 10px;
    text-transform: capitalize;
    font-size: 0.8rem;
}

.ring-size-guide {
    padding: 10px 0;
}

.ring-size-guide a {
    color: #000;
    font-weight: 700;
    text-decoration: underline;
}

.ring-size-quide a:hover {
    color: rgba(0, 0, 0, 0.84);
}

@media (max-width: 768px), (min-height: 428px) {
    .thumbnail_image-model-view {
        height: auto !important;
    }

    .thumbnail_image-model-view img {
        height: auto !important;
    }
}

@media (min-width: 768px) {
    .design-modal-content {
        max-width: 520px;
        width: 520px;
    }

    .design-modal-content-top {
        background-color: #f3ece5;
        max-width: 520px;
    }

    .design-modal-content--large {
        max-width: 720px;
        width: 720px;
    }

    .main-sizer-bg {
        flex-direction: column;
    }

    .ring-configuration-info {
        display: block;
    }

    .model-view-container {
        width:100%;
        height: 400px;
        background: white;
    }

    .thumbnail_image-model-view {
        height: 104px !important;
        display: flex !important;
        justify-content:center !important;
        align-items:center !important;
        cursor:pointer;
    }

    .thumbnail_image-model-view img {
        height: auto !important;
    }

    .ring-configurator-thumb {
        height: 104px !important;
    }

    .ring-configurator-thumb img {
        height: auto !important;
    }
}