/* Visibility */
#product-modal.hidden {
    display: none !important
}

#img-lightbox.hidden {
    display: none !important
}

/* Modal Root */
#product-modal {
    position: fixed;
    inset: 0;
    z-index: 999997;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px;
    background: rgba(0, 0, 0, .6);
    backdrop-filter: blur(2px);
    overflow: auto;
    /* erlaubt Scrollen falls Modal größer als Screen */
}

/* Modal Box */
#product-modal .modal-content {
    display: grid;
    gap: 12px;
    grid-template-rows: auto auto auto auto 1fr auto;
    /* close | title | stage | thumbs | info | cta */
    background: var(--pm-bg, #1f1f1f);
    color: var(--text-color, #fff);
    border-radius: 14px;
    box-shadow: 0 20px 80px rgba(0, 0, 0, .6);

    /* Größe begrenzen */
    max-width: 95vw;
    max-height: 95vh;
    width: auto;

    padding: 12px;
    overflow-y: auto;
    /* erlaubt vertikales Scrollen im Modal */
}

/* Close */
#product-modal .close-btn {
    position: sticky;
    top: 0;
    margin-left: auto;
    z-index: 999997;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    font-size: 22px;
    cursor: pointer
}

#product-modal .close-btn:hover {
    filter: brightness(1.08)
}

/* Title */
#product-modal .pm-title {
    margin: 0;
    text-align: center;
    font-size: clamp(1.05rem, 2.2vw, 1.45rem);
    font-weight: 800;
    color: var(--accent-color, #e9a624)
}

/* Stage: 4:3 */
#product-modal .stage {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    max-height: 60vh;
    /* Bild passt sich Screen an */
    border-radius: 12px;
    overflow: hidden;
    background: #0d0d0d;
}

#product-modal #pm-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

#product-modal .stage.cover #pm-img {
    object-fit: cover
}

/* Arrows */
#product-modal .nav-prev,
#product-modal .nav-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .45);
    color: #fff;
    font-size: 22px;
    cursor: pointer
}

#product-modal .nav-prev {
    left: 8px
}

.nav-next {
    right: 8px
}

#product-modal .nav-prev:hover,
#product-modal .nav-next:hover {
    background: rgba(0, 0, 0, .65)
}

/* Thumbs */
#product-modal .pm-thumbs {
    display: flex;
    gap: 8px;
    padding: 6px 2px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

#product-modal .pm-thumbs::-webkit-scrollbar {
    height: 8px
}

#product-modal .pm-thumbs::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, .4);
    border-radius: 10px
}

#product-modal .pm-thumbs .thumb {
    border: 0;
    background: transparent;
    padding: 0;
    flex: 0 0 auto;
    border-radius: 8px;
    cursor: pointer;
    outline: none
}

#product-modal .pm-thumbs .thumb img {
    display: block;
    width: 120px;
    aspect-ratio: 4 / 3;
    height: auto;
    object-fit: cover;
    border-radius: 8px
}

@media (max-width:560px) {
    #product-modal .pm-thumbs .thumb img {
        width: 96px
    }
}

#product-modal .pm-thumbs .thumb:hover img {
    transform: translateY(-1px) scale(1.02);
    opacity: 1;
    box-shadow: 0 0 0 2px var(--accent-color, #e9a624)
}

#product-modal .pm-thumbs .thumb.active img {
    box-shadow: 0 0 0 2px var(--accent-color, #e9a624);
    opacity: 1
}

/* Info & Details */
#product-modal .pm-info {
    overflow-y: auto;
    max-height: 25vh;
    /* begrenzen, damit der CTA immer sichtbar bleibt */
}

#product-modal .pm-desc {
    margin: 6px 0 12px;
    line-height: 1.5;
    color: var(--text-muted-color, #ccc)
}

#product-modal .details-grid {
    display: grid;
    gap: 8px 12px;
    align-items: start;
    grid-template-columns: 1fr 2fr
}

@media (min-width:900px) {
    #product-modal .details-grid {
        grid-template-columns: 1fr 2fr 1fr 2fr
    }
}

#product-modal .details-grid .detail {
    display: contents
}

#product-modal .details-grid .label {
    font-weight: 600;
    opacity: .8;
    padding: 6px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, .1)
}

#product-modal .details-grid .value {
    padding: 6px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, .1)
}

/* CTA */
#product-modal .pm-cta {
    display: flex;
    justify-content: center;
    padding-top: 6px
}

#product-modal .btn-cta,
#product-modal #pm-cta {
    appearance: none;
    border: 0;
    cursor: pointer;
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--accent-color, #e9a624);
    color: #111;
    font-weight: 700
}

#product-modal .btn-cta:hover,
#product-modal #pm-cta:hover {
    filter: brightness(1.06)
}

/* Lightbox */
#img-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, .8)
}

#img-lightbox .lb-content {
    position: relative;
    max-width: 95vw;
    max-height: 95vh
}

#img-lightbox #lb-img {
    max-width: 95vw;
    max-height: 95vh;
    display: block
}

#img-lightbox .lb-prev,
#img-lightbox .lb-next,
#img-lightbox .lb-close {
    position: absolute;
    border: 0;
    background: rgba(0, 0, 0, .4);
    color: #fff;
    cursor: pointer
}

#img-lightbox .lb-prev,
#img-lightbox .lb-next {
    top: 50%;
    transform: translateY(-50%);
    padding: .4rem .6rem;
    font-size: 2rem
}

#img-lightbox .lb-prev {
    left: -.5rem
}

#img-lightbox .lb-next {
    right: -.5rem
}

#img-lightbox .lb-close {
    top: .25rem;
    right: .25rem;
    padding: .2rem .5rem;
    font-size: 1.5rem
}

/* ===========================
   LIGHT MODE STYLES
   =========================== */
body.light-mode #product-modal .modal-content {
    background: #f4f4f4;
    color: #222;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .2);
}

body.light-mode #product-modal .close-btn {
    background: rgba(0, 0, 0, .08);
    color: #111;
}

body.light-mode #product-modal .pm-title {
    color: var(--accent-color, #e9a624);
}

body.light-mode #product-modal .stage {
    background: #ddd;
}

body.light-mode #product-modal .pm-desc {
    color: #555;
}

body.light-mode #product-modal .details-grid .label {
    border-bottom: 1px solid rgba(0, 0, 0, .1);
    color: #333;
}

body.light-mode #product-modal .details-grid .value {
    border-bottom: 1px solid rgba(0, 0, 0, .1);
    color: #222;
}

body.light-mode #product-modal .btn-cta,
body.light-mode #product-modal #pm-cta {
    background: var(--accent-color, #e9a624);
    color: #fff;
}

body.light-mode #product-modal .btn-cta:hover,
body.light-mode #product-modal #pm-cta:hover {
    filter: brightness(1.08);
}

body.light-mode #product-modal .pm-thumbs .thumb img {
    border: 1px solid rgba(0, 0, 0, .1);
}

body.light-mode #product-modal .pm-thumbs .thumb:hover img {
    box-shadow: 0 0 0 2px var(--accent-color, #e9a624);
}

body.light-mode #product-modal .pm-thumbs .thumb.active img {
    box-shadow: 0 0 0 2px var(--accent-color, #e9a624);
}

/* Overlay füllt Viewport und erlaubt Außen-Scrollen bei sehr kleinen Screens */
#product-modal {
    position: fixed;
    inset: 0;
    z-index: 999998;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, .55);
    backdrop-filter: blur(2px);
    overflow: auto;
    /* Fallback-Scroll, falls Content höher als 100vh */
}

/* Karte: begrenzte Höhe + Innen-Scroll */
#product-modal .modal-content {
    width: min(1000px, 96vw);
    max-height: calc(100vh - 40px);
    /* wichtig: alles passt in den Viewport-Rahmen */
    overflow: auto;
    /* -> Inhalt scrollbar */
    border-radius: 16px;
    background: var(--panel-bg, #222);
    box-shadow: 0 14px 50px rgba(0, 0, 0, .4);
    display: grid;
    grid-template-rows: auto auto auto auto auto;
    /* Titel, Slideshow, Info, CTA ... */
    gap: 12px;
}

/* Bildbühne: niemals höher als ~60vh; Bild skaliert 'contain' */
#pm-stage {
    position: relative;
    width: 100%;
    max-height: 60vh;
    aspect-ratio: 4 / 3;
    /* schöne Grundform, bricht bei sehr schmalen Screens */
    overflow: hidden;
    border-radius: 12px;
    background: #111;
}

#pm-stage img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* nichts abschneiden */
    display: block;
}

/* Thumbs: horizontal scrollbar bei Platzmangel */
#pm-thumbs {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
    /* Platz für Scrollbar */
}

/* Info-Block unter den Bildern: eigener Scrollbereich falls nötig */
.pm-info {
    max-height: 28vh;
    /* zusammen mit 60vh oben bleibt genug Platz */
    overflow: auto;
}

/* Body-Scroll bei offenem Modal sperren (mit Klasse, s.u.) */
body.modal-open {
    overflow: hidden;
}

/* ===========================
   Product Modal Thumbnails
   =========================== */

#product-modal .pm-thumbs {
    display: flex;
    gap: 10px;
    padding: 8px 2px 4px;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

#product-modal .pm-thumbs .thumb {
    flex: 0 0 auto;
    width: 120px;
    aspect-ratio: 4 / 3;

    padding: 2px;
    border: 2px solid transparent;
    border-radius: 10px;

    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    overflow: hidden;

    transition:
        border-color 160ms ease,
        background 160ms ease,
        transform 160ms ease;
}

#product-modal .pm-thumbs .thumb img {
    width: 100%;
    height: 100%;
    display: block;

    object-fit: cover;
    border-radius: 7px;
}

#product-modal .pm-thumbs .thumb:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.1);
}

#product-modal .pm-thumbs .thumb.active {
    border-color: var(--accent-color, #e9a624);
    background: rgba(233, 166, 36, 0.14);
}

@media (max-width: 560px) {
    #product-modal .pm-thumbs .thumb {
        width: 96px;
    }
}

/* ===========================
   Image Lightbox
   =========================== */

#img-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;

    display: grid;
    place-items: center;

    padding: 18px;

    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

#img-lightbox .lb-content {
    position: relative;

    max-width: 96vw;
    max-height: 96dvh;

    display: grid;
    place-items: center;
}

#img-lightbox #lb-img {
    display: block;

    max-width: 96vw;
    max-height: 96dvh;

    object-fit: contain;
    border-radius: 14px;

    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.65);
}

#img-lightbox .lb-prev,
#img-lightbox .lb-next,
#img-lightbox .lb-close {
    position: absolute;

    display: grid;
    place-items: center;

    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;

    background: rgba(24, 24, 24, 0.72);
    color: #fff;

    cursor: pointer;

    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);

    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);

    transition:
        background 160ms ease,
        border-color 160ms ease,
        transform 160ms ease;
}

#img-lightbox .lb-prev,
#img-lightbox .lb-next {
    top: 50%;

    width: 48px;
    height: 48px;

    padding: 0;

    font-size: 2rem;
    line-height: 1;

    transform: translateY(-50%);
}

#img-lightbox .lb-prev {
    left: 14px;
}

#img-lightbox .lb-next {
    right: 14px;
}

#img-lightbox .lb-close {
    top: 14px;
    right: 14px;

    width: 46px;
    height: 46px;

    padding: 0;

    font-size: 1.8rem;
    line-height: 1;
}

#img-lightbox .lb-prev:hover,
#img-lightbox .lb-next:hover,
#img-lightbox .lb-close:hover {
    background: var(--accent-color, #e9a624);
    color: #111;
    border-color: var(--accent-color, #e9a624);
}

#img-lightbox .lb-prev:active,
#img-lightbox .lb-next:active,
#img-lightbox .lb-close:active {
    transform: translateY(-50%) scale(0.96);
}

#img-lightbox .lb-close:active {
    transform: scale(0.96);
}

@media (max-width: 640px) {
    #img-lightbox {
        padding: 10px;
    }

    #img-lightbox .lb-prev,
    #img-lightbox .lb-next {
        width: 42px;
        height: 42px;
        font-size: 1.7rem;
    }

    #img-lightbox .lb-prev {
        left: 8px;
    }

    #img-lightbox .lb-next {
        right: 8px;
    }

    #img-lightbox .lb-close {
        top: 8px;
        right: 8px;

        width: 42px;
        height: 42px;

        font-size: 1.6rem;
    }
}

/* =========================================================
   PRODUCT MODAL - similar products variant
   ========================================================= */

#product-modal {
    position: fixed;
    inset: 0;
    z-index: 999998;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    overflow: auto;
}

#product-modal .modal-content.pm-product-detail,
#product-modal .modal-content {
    width: min(1180px, calc(100vw - 36px));
    max-height: calc(100dvh - 36px);
    display: block;
    padding: 0;
    overflow: hidden;
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.015)),
        var(--secondary-bg-color, #222);
    color: var(--text-color, #fff);
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 24px 90px rgba(0, 0, 0, 0.58);
}

#product-modal .pm-layout {
    height: min(760px, calc(100dvh - 36px));
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(330px, 0.85fr);
}

#product-modal .pm-gallery-card,
#product-modal .pm-side-card {
    min-height: 0;
    overflow: hidden;
}

#product-modal .pm-gallery-card {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 12px;
    padding: 22px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

#product-modal .pm-side-card {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    gap: 14px;
    padding: 22px;
    overflow-y: auto;
}

#product-modal .close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 5;
    width: 42px;
    height: 42px;
    margin: 0;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: rgba(24, 24, 24, 0.72);
    color: #fff;
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#product-modal .close-btn:hover {
    background: var(--accent-color, #e9a624);
    color: #111;
    filter: none;
}

#product-modal .pm-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding-right: 48px;
}

#product-modal .pm-category-pill {
    width: fit-content;
    margin-bottom: 8px;
    padding: 4px 9px;
    border-radius: 999px;
    color: var(--accent-color, #e9a624);
    background: rgba(233, 166, 36, 0.12);
    border: 1px solid rgba(233, 166, 36, 0.32);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

#product-modal .pm-title {
    margin: 0;
    color: var(--text-color, #fff);
    text-align: left;
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    font-weight: 900;
    line-height: 1.05;
}

#product-modal .slideshow {
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 12px;
    overflow: hidden;
}

#product-modal #pm-stage,
#product-modal .stage {
    position: relative;
    width: 100%;
    min-height: 0;
    max-height: none;
    aspect-ratio: auto;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
}

#product-modal #pm-img,
#product-modal .stage.cover #pm-img {
    width: 100%;
    height: 100%;
    min-height: 0;
    object-fit: cover;
    display: block;
}

#product-modal .nav-prev,
#product-modal .nav-next {
    position: absolute;
    top: 50%;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: rgba(24, 24, 24, 0.70);
    color: #fff;
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
    transform: translateY(-50%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#product-modal .nav-prev {
    left: 12px;
}

#product-modal .nav-next {
    right: 12px;
}

#product-modal .nav-prev:hover,
#product-modal .nav-next:hover {
    background: var(--accent-color, #e9a624);
    color: #111;
}

#product-modal .pm-thumbs {
    max-width: 100%;
    display: flex;
    gap: 10px;
    padding: 2px 2px 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

#product-modal .pm-thumbs .thumb {
    flex: 0 0 112px;
    width: 112px;
    aspect-ratio: 4 / 3;
    padding: 2px;
    border: 2px solid transparent;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
    cursor: pointer;
}

#product-modal .pm-thumbs .thumb img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    border-radius: 8px;
}

#product-modal .pm-thumbs .thumb.active {
    border-color: var(--accent-color, #e9a624);
    background: rgba(233, 166, 36, 0.14);
}

#product-modal .pm-side-section {
    display: grid;
    gap: 10px;
}

#product-modal .pm-side-section h3 {
    margin: 0;
    color: var(--text-color, #fff);
    font-size: 1rem;
    font-weight: 800;
}

#product-modal .pm-facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

#product-modal .pm-fact-card {
    min-width: 0;
    padding: 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
}

#product-modal .pm-fact-icon {
    color: var(--accent-color, #e9a624);
    font-size: 1.2rem;
}

#product-modal .pm-fact-card strong {
    display: block;
    color: var(--text-color, #fff);
    font-size: 0.98rem;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#product-modal .pm-fact-card span:not(.pm-fact-icon) {
    display: block;
    margin-top: 3px;
    color: var(--text-muted-color, #cfcfcf);
    font-size: 0.78rem;
}

#product-modal .pm-similar-section {
    min-height: 0;
}

#product-modal .pm-similar-products {
    min-height: 0;
    overflow-y: auto;
    display: grid;
    gap: 10px;
    padding-right: 2px;
}

#product-modal .pm-similar-card {
    width: 100%;
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.045);
    color: inherit;
    cursor: pointer;
    text-align: left;
}

#product-modal .pm-similar-card:hover {
    background: rgba(255, 255, 255, 0.075);
    border-color: rgba(233, 166, 36, 0.42);
}

#product-modal .pm-similar-img {
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 10px;
    background: #111;
}

#product-modal .pm-similar-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#product-modal .pm-similar-body {
    min-width: 0;
    display: grid;
    gap: 4px;
}

#product-modal .pm-similar-body strong {
    color: var(--text-color, #fff);
    font-size: 0.95rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#product-modal .pm-similar-body span {
    color: var(--text-muted-color, #cfcfcf);
    font-size: 0.82rem;
}

#product-modal .pm-similar-empty {
    padding: 14px;
    border-radius: 14px;
    color: var(--text-muted-color, #cfcfcf);
    background: rgba(255, 255, 255, 0.045);
}

#product-modal .pm-desc {
    margin: 0;
    color: var(--text-muted-color, #cfcfcf);
    line-height: 1.55;
    font-size: 0.92rem;
    overflow: auto;
}

#product-modal .pm-info,
#product-modal .details-grid {
    display: contents;
    max-height: none;
    overflow: visible;
}

#product-modal .pm-cta {
    padding-top: 4px;
}

#product-modal .btn-cta,
#product-modal #pm-cta {
    width: 100%;
    min-height: 48px;
    border: 0;
    border-radius: 14px;
    background: var(--accent-color, #e9a624);
    color: #111;
    font-weight: 900;
    cursor: pointer;
}

body.light-mode #product-modal .modal-content.pm-product-detail,
body.light-mode #product-modal .modal-content {
    background: #ffffff;
    color: #222;
    border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode #product-modal .pm-gallery-card {
    border-right-color: rgba(0, 0, 0, 0.08);
}

body.light-mode #product-modal .pm-title,
body.light-mode #product-modal .pm-side-section h3,
body.light-mode #product-modal .pm-fact-card strong,
body.light-mode #product-modal .pm-similar-body strong {
    color: #222;
}

body.light-mode #product-modal .pm-desc,
body.light-mode #product-modal .pm-fact-card span:not(.pm-fact-icon),
body.light-mode #product-modal .pm-similar-body span,
body.light-mode #product-modal .pm-similar-empty {
    color: #555;
}

body.light-mode #product-modal .pm-fact-card,
body.light-mode #product-modal .pm-similar-card,
body.light-mode #product-modal .pm-similar-empty,
body.light-mode #product-modal .pm-thumbs .thumb {
    background: rgba(0, 0, 0, 0.035);
    border-color: rgba(0, 0, 0, 0.08);
}

@media (max-width: 860px) {
    #product-modal {
        padding: 8px;
        align-items: start;
    }

    #product-modal .modal-content.pm-product-detail,
    #product-modal .modal-content {
        width: calc(100vw - 16px);
        max-height: calc(100dvh - 16px);
        overflow: auto;
        border-radius: 16px;
    }

    #product-modal .pm-layout {
        height: auto;
        min-height: 0;
        display: grid;
        grid-template-columns: 1fr;
    }

    #product-modal .pm-gallery-card {
        padding: 16px;
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    #product-modal .pm-side-card {
        padding: 16px;
        overflow: visible;
    }

    #product-modal #pm-stage,
    #product-modal .stage {
        height: auto;
        aspect-ratio: 4 / 3;
        max-height: 46dvh;
    }

    #product-modal .pm-thumbs .thumb {
        flex-basis: 88px;
        width: 88px;
    }

    #product-modal .pm-facts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #product-modal .pm-similar-products {
        overflow: visible;
    }

    #product-modal .pm-description-section {
        display: none;
    }
}

@media (max-width: 430px) {
    #product-modal .pm-facts {
        grid-template-columns: 1fr;
    }

    #product-modal .pm-side-card {
        gap: 12px;
    }

    #product-modal .pm-title {
        font-size: 1.35rem;
    }

    #product-modal .pm-similar-card {
        grid-template-columns: 76px minmax(0, 1fr);
    }
}


/* =========================================================
   PRODUCT MODAL - recommended filaments override
   ========================================================= */

#product-modal #pm-img,
#product-modal .stage.cover #pm-img {
    object-fit: cover !important;
}

#product-modal .pm-side-card {
    grid-template-rows: auto auto minmax(0, 0.95fr) auto auto !important;
}

#product-modal .pm-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

#product-modal .pm-filament-section {
    min-height: 0;
}

#product-modal .pm-recommended-filaments {
    display: grid;
    gap: 10px;
}

#product-modal .pm-filament-card {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 11px;
    align-items: center;

    min-width: 0;
    padding: 8px;

    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);

    background: rgba(255, 255, 255, 0.045);
}

#product-modal .pm-filament-img {
    display: grid;
    place-items: center;

    width: 58px;
    aspect-ratio: 1 / 1;

    overflow: hidden;
    border-radius: 11px;

    background: rgba(0, 0, 0, 0.22);
}

#product-modal .pm-filament-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#product-modal .pm-filament-img-empty {
    color: var(--accent-color, #e9a624);
    font-size: 1.35rem;
}

#product-modal .pm-filament-body {
    min-width: 0;
    display: grid;
    gap: 3px;
}

#product-modal .pm-filament-body strong {
    color: var(--text-color, #fff);
    font-size: 0.95rem;
    line-height: 1.18;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#product-modal .pm-filament-body span {
    color: var(--text-muted-color, #cfcfcf);
    font-size: 0.8rem;
    line-height: 1.2;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#product-modal .pm-filament-body em {
    color: var(--accent-color, #e9a624);
    font-size: 0.78rem;
    font-style: normal;
    line-height: 1.25;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#product-modal .pm-filament-empty,
#product-modal .pm-filament-loading {
    padding: 12px;
    border-radius: 14px;

    color: var(--text-muted-color, #cfcfcf);
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.08);

    font-size: 0.9rem;
}

body.light-mode #product-modal .pm-filament-card,
body.light-mode #product-modal .pm-filament-empty,
body.light-mode #product-modal .pm-filament-loading {
    background: rgba(0, 0, 0, 0.035);
    border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode #product-modal .pm-filament-body strong {
    color: #222;
}

body.light-mode #product-modal .pm-filament-body span,
body.light-mode #product-modal .pm-filament-empty,
body.light-mode #product-modal .pm-filament-loading {
    color: #555;
}

@media (max-width: 860px) {
    #product-modal .pm-side-card {
        grid-template-rows: none !important;
    }

    #product-modal .pm-recommended-filaments {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 430px) {
    #product-modal .pm-facts {
        grid-template-columns: 1fr !important;
    }

    #product-modal .pm-filament-card {
        grid-template-columns: 52px minmax(0, 1fr);
    }

    #product-modal .pm-filament-img {
        width: 52px;
    }
}


/* =========================================================
   PRODUCT MODAL - hint above recommendations
   ========================================================= */

#product-modal .pm-side-card {
    grid-template-rows: auto auto auto minmax(0, 1fr) auto !important;
}

#product-modal .pm-description-section {
    display: grid !important;
}

@media (max-width: 860px) {
    #product-modal .pm-description-section {
        display: grid !important;
    }
}