.modal {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 2147483647;
    pointer-events: none;
}

.modal.is-open {
    display: flex;
    align-items: center;
    justify-content: center;
}

body.modal-open {
    overflow: hidden;
}

.modal__backdrop,
.modal__dialog {
    pointer-events: auto;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    backdrop-filter: blur(2px);
}

.modal__dialog {
    position: relative;
    width: min(var(--modal-max-w), 96vw);
    height: clamp(var(--modal-min-h), var(--modal-vh), 900px);
    max-height: var(--modal-vh);
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}

.modal__close {
    position: absolute;
    top: 10px;
    right: 10px;
    border: 0;
    background: #fff;
    border: 1px solid var(--border);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    z-index: 2;
}

.modal__grid {
    display: grid;
    grid-template-columns: minmax(620px, 1.7fr) 1fr;
    gap: 0;
    height: 100%;
    min-height: 0;
}

.modal__gallery {
    display: grid;
    grid-template-rows: 1fr;
    background: #000;
    min-height: 0;
}

.modal__stage {
    position: relative;
    height: 100%;
    min-height: 420px;
    overflow: hidden;
    padding-bottom: 84px;
}

.modal__stage img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: #000;
}

/* flechas */
.modal__stage .nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 8px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: 22px;
    display: grid;
    place-items: center;
    cursor: pointer;
    z-index: 5;
}

.modal__stage .nav--prev {
    left: 10px;
}

.modal__stage .nav--next {
    right: 10px;
}

/* strip */
.modal__strip {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 10px;
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px;
    border-radius: 10px;
    background: rgba(15, 15, 15, .55);
    backdrop-filter: blur(4px) saturate(120%);
    border: 1px solid rgba(255, 255, 255, .18);
    overflow-x: auto;
    z-index: 3;
    height: 80px;
}

.modal__strip img {
    width: 92px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    opacity: .75;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, .25);
}

.modal__strip img.is-active {
    opacity: 1;
    outline: 2px solid var(--accent);
}

.modal__counter {
    position: absolute;
    right: 18px;
    bottom: 54px;
    padding: 3px 8px;
    font-size: 12px;
    color: #eee;
    background: rgba(0, 0, 0, .45);
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 999px;
    backdrop-filter: blur(3px);
    z-index: 3;
}

/* info derecha */
.modal__info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    background: #fff;
    padding: 14px 16px;
}

.modal__content {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding-right: 2px;
}

.modal__info h3 {
    margin: 0 0 6px;
}

.modal__info .muted {
    margin: 0 0 12px;
}

.modal__sub {
    margin: 12px 0 6px;
    font-size: .95rem;
    color: var(--muted);
}

.proj-stack-prev {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 12px;
}

.proj-stack-prev img {
    width: 20px;
    height: 20px;
    display: block;
}

/* acciones */
.modal__actions {
    flex: 0 0 auto;
    position: sticky;
    bottom: 0;
    background: #fff;
    padding-top: 10px;
    margin-top: 12px;
    border-top: 1px solid var(--border);
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.actions a {
    text-decoration: none;
    border: 1px solid var(--txt);
    padding: 8px 12px;
    border-radius: 10px;
    font-weight: 700;
}

.actions a.btn--accent {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.actions .badge {
    margin-left: auto;
}

/* responsive modal */
@media (max-width:1200px) {
    .modal__grid {
        grid-template-columns: 1.6fr 1fr;
    }
}

@media (max-width:1024px) {
    .modal__grid {
        grid-template-columns: 1.4fr 1fr;
    }

    .modal__thumbs img {
        width: 84px;
        height: 56px;
    }
}

@media (max-width:760px) {
    .modal__grid {
        grid-template-columns: 1fr;
    }

    .modal__stage {
        height: 58vh;
        min-height: 320px;
        padding-bottom: 74px;
    }

    .modal__counter {
        bottom: 74px;
    }
}