.modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s var(--ease), visibility 0.3s var(--ease);
}

.modal.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(31, 42, 27, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal__dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 420px);
    max-height: min(92vh, 900px);
    overflow: auto;
    padding: clamp(28px, 4vw, 36px);
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.modal__dialog--wide {
    width: min(100%, 980px);
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: clamp(24px, 4vw, 36px);
    align-items: start;
    padding: clamp(24px, 3vw, 32px);
}

.modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-soft);
    color: var(--ink);
    font-size: 1.75rem;
    line-height: 1;
    transition: background var(--transition), color var(--transition);
}

.modal__close:hover {
    background: var(--green-light);
    color: var(--green-dark);
}

.modal__title {
    padding-right: 40px;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 800;
    color: var(--ink);
}

.modal__title + .lead-form {
    margin-top: 24px;
}

.lead-form--simple {
    gap: 14px;
}

.house-modal__gallery {
    min-width: 0;
}

.house-modal__main {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--bg-soft);
}

.house-modal__photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.45s var(--ease);
}

.house-modal__photo.is-active {
    opacity: 1;
}

.house-modal__thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.house-modal__thumb {
    flex: 0 0 calc(25% - 8px);
    padding: 0;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    background: none;
    transition: border-color var(--transition);
}

.house-modal__thumb.is-active {
    border-color: var(--green);
}

.house-modal__thumb img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.house-modal__body {
    min-width: 0;
    padding-right: 28px;
}

.house-modal__title {
    font-size: clamp(1.5rem, 2.5vw, 2rem);
    font-weight: 800;
    color: var(--ink);
}

.house-modal__desc {
    margin-top: 14px;
    line-height: 1.65;
    color: var(--muted);
}

.house-modal__specs {
    display: grid;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}

.house-modal__spec {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: baseline;
}

.house-modal__spec dt {
    color: var(--muted);
    font-size: var(--fs-base);
}

.house-modal__spec dd {
    font-weight: 700;
    color: var(--ink);
    text-align: right;
}

.house-modal__actions {
    margin-top: 28px;
    padding-top: 28px;
    border-top: 1px solid var(--line);
}

.lead-form {
    display: grid;
    gap: 16px;
}

.lead-form__field {
    display: grid;
    gap: 8px;
}

.lead-form__label {
    font-size: var(--fs-small);
    font-weight: 700;
    color: var(--ink);
}

.lead-form__input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.lead-form__input:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(79, 138, 61, 0.15);
}

.lead-form__input.is-invalid {
    border-color: #c62828;
}

.lead-form__consent {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: var(--fs-small);
    line-height: 1.45;
    color: var(--muted);
    cursor: pointer;
}

.lead-form__checkbox {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--green);
}

.lead-form__submit {
    width: 100%;
}

.lead-form__message {
    font-size: var(--fs-small);
    line-height: 1.45;
}

.lead-form__message.is-success {
    color: var(--green-dark);
}

.lead-form__message.is-error {
    color: #c62828;
}

.modal--lightbox {
    padding: 0;
    z-index: 400;
}

.modal--lightbox .modal__overlay {
    background: rgba(15, 20, 16, 0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.lightbox {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: min(1200px, calc(100vw - 40px));
    max-height: calc(100vh - 40px);
}

.lightbox__close {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: var(--white);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
}

.lightbox__close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.lightbox__frame {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-height: calc(100vh - 100px);
    margin: 0;
}

.lightbox__img {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: calc(100vh - 100px);
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
    animation: lightbox-zoom 0.35s var(--ease);
}

.lightbox__nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: var(--white);
    font-size: 2.4rem;
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
}

.lightbox__nav:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-50%) scale(1.06);
}

.lightbox__nav--prev {
    left: -72px;
}

.lightbox__nav--next {
    right: -72px;
}

.lightbox__nav.is-hidden {
    visibility: hidden;
    pointer-events: none;
}

.lightbox__counter {
    position: absolute;
    bottom: -48px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.85);
    font-size: var(--fs-base);
    font-weight: 700;
    letter-spacing: 0.06em;
}

@keyframes lightbox-zoom {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@media (max-width: 860px) {
    .lightbox__nav--prev {
        left: 4px;
    }

    .lightbox__nav--next {
        right: 4px;
    }

    .lightbox__nav {
        width: 44px;
        height: 44px;
    }

    .lightbox__close {
        top: 8px;
        right: 8px;
    }

    .lightbox__counter {
        bottom: 8px;
    }
}

@media (max-width: 860px) {
    .modal__dialog--wide {
        grid-template-columns: 1fr;
        width: min(100%, 640px);
    }

    .house-modal__body {
        padding-right: 0;
    }

    .house-modal__thumb {
        flex: 0 0 calc(33.333% - 7px);
    }
}

@media (max-width: 560px) {
    .modal {
        padding: 12px;
    }

    .modal__dialog,
    .modal__dialog--wide {
        padding: 22px 18px;
    }

    .house-modal__thumb {
        flex: 0 0 calc(50% - 5px);
    }
}
