:root {
    --blue: #0a6a8f;
    --blue-dark: #054a66;
    --page-bg: #eef4f7;
    --surface: #ffffff;
    --surface-soft: #f6fafc;
    --text: #15222b;
    --muted: #5e6c76;
    --border: #d7e2e9;
    --shadow: 0 18px 48px rgba(15, 35, 49, 0.12);
    --feed-bg: #0f1f29;
    --feed-bg-deeper: #0a1620;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top, rgba(10, 106, 143, 0.11), transparent 46%),
        linear-gradient(180deg, #f7fbfd 0%, #edf3f7 100%);
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Mobile-first search experience. */
.go-back-link,
.search-again-link {
    position: fixed;
    top: 12px;
    z-index: 10;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid rgba(10, 106, 143, 0.12);
    background: rgba(255, 255, 255, 0.95);
    color: var(--blue-dark);
    box-shadow: 0 10px 30px rgba(15, 35, 49, 0.14);
    font-size: 13px;
    font-weight: 700;
    backdrop-filter: blur(10px);
}

.search-topbar,
.detail-topbar {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 12;
}

.search-brand,
.detail-brand {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 0;
}

.search-brand .app-logo-image,
.detail-brand .app-logo-image {
    display: block;
    width: auto;
    height: 58px;
    filter: drop-shadow(0 10px 24px rgba(15, 35, 49, 0.18));
}

.go-back-link {
    right: 12px;
}

.search-again-link {
    left: 12px;
}

.go-back-link:hover,
.search-again-link:hover {
    transform: translateY(-1px);
    background: #ffffff;
}

.search-page {
    width: min(100%, 1120px);
    min-height: 100vh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 72px 14px 20px;
}

.search-page-results {
    padding-bottom: 14px;
}

.search-bar {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 16px;
    border: 1px solid rgba(21, 34, 43, 0.08);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow);
}

.search-heading {
    grid-column: 1 / -1;
}

.search-heading h1 {
    margin: 0 0 6px;
    color: var(--text);
    font-size: 24px;
    line-height: 1.12;
    letter-spacing: -0.03em;
}

.search-heading p {
    margin: 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.55;
}

.search-section {
    display: grid;
    gap: 6px;
}

.search-section label {
    font-size: 13px;
    font-weight: 800;
    color: var(--blue-dark);
    letter-spacing: 0.01em;
}

.search-section input,
.search-section select {
    width: 100%;
    min-height: 48px;
    border: 1px solid #c7d6de;
    border-radius: 14px;
    outline: 0;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 15px;
    padding: 0 14px;
    transition:
        border-color 160ms ease,
        box-shadow 160ms ease,
        background-color 160ms ease;
}

.search-section input:focus,
.search-section select:focus {
    border-color: rgba(10, 106, 143, 0.7);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(10, 106, 143, 0.12);
}

.search-section input::placeholder {
    color: #7c8c95;
}

.search-bar button {
    grid-column: 1 / -1;
    min-height: 50px;
    padding: 0 24px;
    border: 0;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--blue), var(--blue-dark));
    color: #ffffff;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 14px 30px rgba(10, 106, 143, 0.26);
    transition:
        transform 160ms ease,
        box-shadow 160ms ease,
        filter 160ms ease;
}

.search-bar button:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 36px rgba(10, 106, 143, 0.3);
    filter: brightness(1.03);
}

.search-message {
    width: min(100%, 900px);
    margin: 0;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 10px 24px rgba(15, 35, 49, 0.08);
    text-align: center;
    font-weight: 700;
}

.search-message-error {
    color: #9f1239;
}

.results-area {
    width: 100%;
    min-height: 0;
    flex: 1;
    display: grid;
    place-items: stretch;
}

.video-feed {
    width: 100%;
    max-width: none;
    height: 100dvh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 0;
    padding: 0;
}

.video-results-toolbar {
    position: relative;
    z-index: 5;
    width: 100%;
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: max(10px, env(safe-area-inset-top)) clamp(16px, 4vw, 32px) 10px;
}

.video-stage {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.video-card {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    max-width: none;
    overflow: visible;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    opacity: 1;
    transform: translateY(0);
    transition:
        opacity 220ms ease,
        transform 220ms ease;
    will-change: opacity, transform;
}

.video-card.slide-out-up {
    opacity: 0;
    transform: translateY(-42px);
}

.video-card.slide-out-down {
    opacity: 0;
    transform: translateY(42px);
}

.video-card.slide-in-from-up {
    opacity: 0;
    transform: translateY(-42px);
    transition: none;
}

.video-card.slide-in-from-down {
    opacity: 0;
    transform: translateY(42px);
    transition: none;
}

.video-details-button {
    min-height: 42px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--blue), var(--blue-dark));
    color: #ffffff;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(5, 74, 102, 0.28);
}

.video-close-button {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    color: #ffffff;
    background: rgba(5, 74, 102, 0.92);
    font-size: 28px;
    line-height: 1;
    box-shadow: 0 8px 20px rgba(5, 74, 102, 0.24);
}

.video-close-button:hover {
    background: var(--blue-dark);
}

.video-details-button:hover {
    filter: brightness(1.08);
}

.apartment-video {
    width: 100%;
    height: min(70dvh, 760px);
    display: block;
    background: transparent;
    object-fit: contain;
}

.video-source {
    display: none;
}

.mobile-video-stack {
    display: none;
    width: 100%;
    gap: 14px;
}

.mobile-feed-sentinel {
    width: 100%;
    height: 1px;
}

.feed-control-button {
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.feed-control-button:hover {
    background: rgba(255, 255, 255, 0.22);
}

.feed-controls {
    position: fixed;
    left: 50%;
    bottom: 14px;
    z-index: 4;
    display: grid;
    grid-auto-flow: column;
    gap: 12px;
    transform: translateX(-50%);
}

.video-position {
    position: fixed;
    left: 12px;
    bottom: 14px;
    z-index: 4;
    margin: 0;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(9, 31, 44, 0.72);
    color: #ffffff;
    justify-self: center;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

.video-feed.is-mobile-scroll {
    width: 100%;
    height: 100dvh;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
}

.video-feed.is-mobile-scroll .video-stage {
    display: none;
}

.video-feed.is-mobile-scroll .mobile-video-stack {
    display: block;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
}

.video-feed.is-mobile-scroll .video-position {
    position: static;
    left: auto;
    bottom: auto;
    margin: 0;
    justify-self: center;
}

.video-feed.is-mobile-scroll .feed-controls {
    display: none;
}

.video-feed.is-mobile-scroll .video-card {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    aspect-ratio: auto;
    border-radius: 0;
}

@media (max-width: 767px) {
    .search-page:not(.video-results-active) {
        padding: 82px 16px 28px;
    }

    .search-page:not(.video-results-active) .search-bar {
        gap: 17px;
        padding: 22px 18px 20px;
        border-radius: 24px;
    }

    .search-page:not(.video-results-active) .search-heading h1 {
        font-size: 27px;
    }

    .search-page:not(.video-results-active) .search-heading p {
        font-size: 14px;
        line-height: 1.5;
    }

    .search-page:not(.video-results-active) .search-section {
        gap: 8px;
    }

    .search-page:not(.video-results-active) .search-section label {
        font-size: 14px;
    }

    .search-page:not(.video-results-active) .search-section input,
    .search-page:not(.video-results-active) .search-section select {
        min-height: 54px;
        font-size: 16px;
    }

    .search-page:not(.video-results-active) .search-bar button {
        min-height: 54px;
        font-size: 16px;
    }

    /* Mobile uses native page scrolling instead of feed navigation buttons. */
    .video-feed .feed-controls {
        display: none;
    }

    /* Let the result feed reach the screen edges; the video stays centered within it. */
    .search-page.video-results-active {
        width: 100%;
        height: 100dvh;
        min-height: 0;
        padding: 0;
        gap: 0;
    }

    .search-page.video-results-active .results-area {
        width: 100%;
    }

    .video-feed.is-mobile-scroll {
        height: 100dvh;
    }

    .video-feed.is-mobile-scroll .mobile-video-stack {
        flex: 1;
    }

    .video-feed.is-mobile-scroll .mobile-video-card {
        width: 100%;
        height: 100%;
        scroll-snap-align: start;
        scroll-snap-stop: always;
    }

    .video-feed.is-mobile-scroll .video-details-button {
        min-height: 42px;
        font-size: 14px;
    }

    .video-feed.is-mobile-scroll .video-position {
        position: static;
        margin: 0 auto;
    }
}

.detail-page {
    width: min(100%, 1180px);
    min-height: 100vh;
    margin: 0 auto;
    padding: 72px 16px 28px;
}

.detail-summary {
    padding: 18px;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 16px 36px rgba(24, 35, 43, 0.14);
}

.detail-header {
    margin-bottom: 14px;
}

.detail-header h1 {
    margin: 0;
}

.detail-top-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    align-items: start;
}

.detail-info-card {
    padding: 18px 16px;
    border: 1px solid #d9e3ea;
    border-radius: 14px;
    background: #f7fbfd;
}

.detail-label {
    display: block;
    margin: 0 0 8px;
    color: var(--blue);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.detail-value {
    margin: 0 0 8px;
    color: var(--text);
    font-size: 17px;
    font-weight: 700;
    line-height: 1.4;
}

.detail-gallery-section {
    margin-top: 24px;
    padding: 18px;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 16px 36px rgba(24, 35, 43, 0.14);
}

.detail-image-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}

.detail-image-card {
    appearance: none;
    border: 0;
    padding: 0;
    width: 100%;
    margin: 0;
    min-height: 260px;
    border-radius: 14px;
    overflow: hidden;
    background: #d9e3ea;
    box-shadow: 0 10px 24px rgba(24, 35, 43, 0.12);
    cursor: zoom-in;
}

.detail-image-card img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.empty-detail {
    margin: 0;
    color: #52606b;
    line-height: 1.6;
}

.image-modal {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 12px;
}

.image-modal[hidden] {
    display: none;
}

.image-modal-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(8, 15, 20, 0.82);
    cursor: pointer;
}

.image-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(96vw, 980px);
    max-height: 90vh;
    margin: 0;
    border-radius: 16px;
    overflow: hidden;
    background: #101820;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.image-modal-image {
    display: block;
    width: 100%;
    max-height: 90vh;
    object-fit: contain;
    background: #101820;
}

.image-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #18232b;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.video-buffering-indicator {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    color: #ffffff;
    background: rgba(8, 15, 20, 0.5);
    font-size: 13px;
    font-weight: 700;
    pointer-events: none;
}

.video-buffering-indicator[hidden],
.feed-load-progress[hidden],
.image-modal-loading[hidden],
.image-modal-error[hidden] {
    display: none;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.38);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: loading-spin 700ms linear infinite;
}

.feed-load-progress {
    position: absolute;
    right: 18px;
    bottom: 82px;
    left: 18px;
    z-index: 6;
    height: 4px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.35);
}

.feed-load-progress-bar {
    position: absolute;
    inset: 0 auto 0 0;
    width: 38%;
    border-radius: inherit;
    background: #61d3ff;
    box-shadow: 0 0 12px rgba(97, 211, 255, 0.8);
    animation: progress-sweep 1.1s ease-in-out infinite;
}

.image-modal-loading,
.image-modal-error {
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    margin: 0;
    padding: 24px;
    color: #ffffff;
    text-align: center;
    font-size: 14px;
}

.image-modal-error {
    color: #ffd1d1;
}

.image-modal-image[hidden] {
    display: none;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    clip-path: inset(50%);
}

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

@keyframes progress-sweep {
    from { transform: translateX(-110%); }
    to { transform: translateX(300%); }
}

@media (prefers-reduced-motion: reduce) {
    .loading-spinner,
    .feed-load-progress-bar {
        animation-duration: 2.5s;
    }
}

@media (min-width: 768px) {
    body {
        background:
            linear-gradient(rgba(0, 63, 89, 0.62), rgba(0, 95, 131, 0.48)),
            url("/static/listings/images/blue_interior_apartment.be9a3f9e50b1.jpg");
        background-position: center;
        background-size: cover;
        background-attachment: fixed;
    }

    .go-back-link,
    .search-again-link {
        top: 20px;
        min-height: 42px;
        padding: 0 16px;
        font-size: 14px;
    }

    .go-back-link {
        right: 20px;
    }

    .search-again-link {
        left: 20px;
    }

    .search-page {
        align-items: center;
        justify-content: center;
        gap: 14px;
        padding: 28px 20px 24px;
    }

    .search-page-results {
        padding-bottom: 22px;
    }

    .search-page.video-results-active {
        width: 100%;
        height: 100dvh;
        min-height: 100dvh;
        padding: 0;
        gap: 0;
        justify-content: flex-start;
        align-items: stretch;
        background: transparent;
    }

    .search-bar {
        width: min(100%, 860px);
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
        padding: 28px;
        border-radius: 28px;
    }

    .search-heading {
        margin-bottom: 2px;
        grid-column: 1 / -1;
    }

    .search-heading h1 {
        font-size: 32px;
    }

    .search-bar button {
        grid-column: 1 / -1;
        width: min(260px, 100%);
        justify-self: center;
    }

    .results-area {
        width: 100%;
        margin: 0;
    }

    .video-feed {
        width: 100%;
        height: 100dvh;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        backdrop-filter: none;
    }

    .video-stage {
        width: 100%;
        height: 100%;
        padding: 0;
        align-items: center;
        gap: 20px;
        border-radius: 0;
        background: transparent;
    }

    .video-card {
        width: 100%;
        max-width: 100%;
        height: 100%;
        aspect-ratio: auto;
        border-radius: 0;
        border: 0;
        box-shadow: none;
    }

    .feed-control-button {
        width: 52px;
        height: 52px;
        font-size: 24px;
    }

    .feed-controls {
        left: auto;
        right: 26px;
        top: 50%;
        bottom: auto;
        grid-auto-flow: row;
        transform: translateY(-50%);
    }

    .video-position {
        position: absolute;
        left: 26px;
        bottom: 26px;
        background: rgba(255, 255, 255, 0.92);
        color: #18232b;
        border: 0;
        box-shadow: none;
    }

    .detail-page {
        padding: 88px 24px 40px;
    }

    .detail-summary {
        padding: 20px;
    }

    .detail-top-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .detail-gallery-section {
        padding: 24px;
    }

    .detail-image-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 18px;
    }

    .detail-image-card {
        min-height: 320px;
    }

    .image-modal {
        padding: 20px;
    }
}

@media (min-width: 1024px) {
    .search-page.video-results-active {
        align-items: stretch;
    }

    .video-position {
        left: 24px;
        bottom: 24px;
    }

    .search-page {
        padding-left: 24px;
        padding-right: 24px;
    }

    .video-feed {
        max-width: none;
    }
}

@media (min-width: 1200px) {
    .search-page.video-results-active .results-area {
        width: 100%;
    }
}

@media (min-width: 1200px) {
    .search-page {
        padding-top: 88px;
    }

    .search-bar,
    .results-area {
        width: min(100%, 920px);
    }
}

/* Video results use a dark, edge-to-edge stage so the listing stays readable. */
.video-feed {
    position: relative;
    display: block;
    background: #080f14;
}

.video-results-toolbar {
    position: absolute;
    top: 0;
    left: 0;
    min-height: 76px;
    padding: max(12px, env(safe-area-inset-top)) clamp(16px, 4vw, 36px) 12px;
    background: #fff;
    box-shadow: 0 4px 18px rgba(15, 35, 49, 0.12);
}

.feed-brand {
    display: inline-flex;
    align-items: center;
}

.feed-brand .app-logo-image {
    display: block;
    width: auto;
    height: 42px;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.45));
}

.video-feed .video-close-button {
    width: 44px;
    height: 44px;
    border: 1px solid var(--blue);
    background: var(--blue);
    color: #fff;
    font-size: 28px;
    backdrop-filter: blur(12px);
}

.video-feed .video-close-button:hover {
    background: var(--blue-dark);
}

.video-stage {
    position: absolute;
    inset: 0;
    height: auto;
    overflow: hidden;
    background: #080f14;
}

.video-card {
    overflow: hidden;
    background: #080f14;
}

.apartment-video {
    width: 100%;
    height: 100%;
    max-height: 100%;
    background: #080f14;
    object-fit: contain;
}

.video-details-button {
    min-width: 150px;
    min-height: 48px;
    padding: 0 24px;
    background: linear-gradient(135deg, var(--blue), var(--blue-dark));
    color: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
    font-size: 15px;
}

.video-details-button:hover {
    filter: brightness(1.08);
}

.video-feed-footer {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 5;
    display: flex;
    justify-content: center;
    padding: 14px 16px max(20px, env(safe-area-inset-bottom));
    background: #fff;
    box-shadow: 0 -4px 18px rgba(15, 35, 49, 0.12);
}

.video-details-button:focus-visible,
.video-feed .video-close-button:focus-visible {
    outline: 3px solid #8de1ff;
    outline-offset: 3px;
}

@media (max-width: 767px) {
    .video-results-toolbar {
        min-height: 70px;
        padding-right: 14px;
        padding-left: 14px;
    }

    .feed-brand .app-logo-image {
        height: 36px;
    }

    .video-details-button {
        min-width: 144px;
        min-height: 46px;
        font-size: 14px;
    }
}
