﻿/* WizReal AI search (/AiSearch) — chat + results + map. docs/WEB_AI_SEARCH.md */

/* P2-e (PM 2026-11-04): colours come from the Phase 2 tokens (wz-tokens.css, loaded by the page),
   so Commercial mode (body.commercial) re-skins the AI page like the rest of the site. */
:root {
    --ai-header-h: 72px;
    --ai-border: var(--wz-line, #e6e8eb);
    --ai-muted: var(--wz-muted, #6b7280);
    --ai-bg: var(--wz-soft, #f7f8fa);
    --ai-green: var(--wz-p, #3e7b27);
    --ai-green-soft: var(--wz-tint, #e6f4ea);
    --ai-chat-w: 400px; /* PM 2026-10-29: wider chat, narrower list, wider map */
    --ai-map-w: 44%;
    --ai-mobilebar-h: 56px;
}

/* The page never scrolls (PM 2026-10-29): header, the three panes and the copyright bar
   all fit the viewport. aiSearch.js measures the header and the bar into --ai-header-h /
   --ai-footer-h; the panes scroll inside themselves. */
body.ai-page { overflow: hidden; }

/* Chat spans the full height on the left; the filter bar runs the full width over the
   list AND the map (design 2026-10-29); list and map sit under it. */
.ai-shell {
    display: grid;
    grid-template-columns: var(--ai-chat-w) minmax(0, 1fr) var(--ai-map-w);
    grid-template-rows: auto minmax(0, 1fr);
    height: calc(100vh - var(--ai-header-h) - var(--ai-footer-h, 0px));
    min-height: 420px;
    background: #fff;
    position: relative;
}

.ai-chat { grid-column: 1; grid-row: 1 / span 2; }
.ai-filters { grid-column: 2 / span 2; grid-row: 1; }
.ai-results { grid-column: 2; grid-row: 2; }
.ai-map { grid-column: 3; grid-row: 2; }
.ai-stagetoggle, .ai-sheet__grip { display: none; }

/* ------------------------------------------------------------------ chat */
.ai-chat {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--ai-border);
    min-height: 0;
    position: relative;
}

.ai-chat__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .9rem 1rem;
    border-bottom: 1px solid var(--ai-border);
}

.ai-chat__heading { min-width: 0; }

.ai-chat__title {
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-chat__sub {
    font-size: .8rem;
    color: var(--ai-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-chat__actions { display: flex; gap: .4rem; flex-shrink: 0; }

.ai-iconbtn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--ai-border);
    background: #fff;
    color: #333;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .15s ease;
}

.ai-iconbtn:hover { border-color: var(--ai-green); color: var(--ai-green); }
.ai-iconbtn.is-active { border-color: var(--ai-green); color: var(--ai-green); background: var(--ai-green-soft); }

/* history drawer */
.ai-history {
    position: absolute;
    top: 61px;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    z-index: 5;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

.ai-history__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .75rem;
}

.ai-history__clear { color: var(--ai-green); font-weight: 600; text-decoration: none; font-size: .9rem; }

.ai-history__list { overflow-y: auto; flex: 1 1 auto; min-height: 0; }

.ai-history__item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .4rem;
    border-radius: .6rem;
    cursor: pointer;
}

.ai-history__item:hover { background: var(--ai-bg); }
.ai-history__item.is-active { background: var(--ai-green-soft); }

.ai-history__icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ai-bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #444;
    flex-shrink: 0;
}

.ai-history__text { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 3px; } /* title above the meta line (PM 2026-10-29) */
.ai-history__name { display: block; font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-history__meta { display: block; font-size: .78rem; color: var(--ai-muted); }

.ai-history__del {
    border: 0;
    background: transparent;
    color: #9aa3ad;
    padding: .25rem;
}

.ai-history__del:hover { color: #dc3545; }
.ai-history__empty { color: var(--ai-muted); font-size: .9rem; padding: 1rem .25rem; }
.ai-history__hint { font-size: .75rem; color: var(--ai-muted); padding-top: .75rem; border-top: 1px solid var(--ai-border); }

/* messages */
.ai-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    min-height: 0;
}

.ai-msg { display: flex; gap: .5rem; align-items: flex-end; }
.ai-msg--user { justify-content: flex-end; }

.ai-msg__avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--ai-green-soft);
    color: var(--ai-green);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    flex-shrink: 0;
}

.ai-msg__bubble {
    max-width: 85%;
    padding: .7rem .9rem;
    border-radius: 1rem;
    font-size: .92rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.ai-msg--ai .ai-msg__bubble { background: var(--ai-bg); color: #222; border-bottom-left-radius: .3rem; }
.ai-msg--user .ai-msg__bubble { background: var(--ai-green); color: #fff; border-bottom-right-radius: .3rem; }
.ai-msg--error .ai-msg__bubble { background: #fff3f3; color: #8a1c1c; }

.ai-typing { display: inline-flex; gap: 4px; align-items: center; height: 1rem; }
.ai-typing i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ai-muted);
    animation: ai-bounce 1.2s infinite ease-in-out;
}
.ai-typing i:nth-child(2) { animation-delay: .15s; }
.ai-typing i:nth-child(3) { animation-delay: .3s; }

@keyframes ai-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: .5; }
    40% { transform: translateY(-4px); opacity: 1; }
}

/* suggestions */
/* One row that scrolls sideways: mouse wheel is turned into horizontal scroll in JS
   (PM 2026-10-29: the chips were cut off and could not be reached with a mouse). */
.ai-suggest {
    display: flex;
    align-items: center;
    flex-shrink: 0; /* a scroll container has min-height 0, so the chat column squashed it and the chip text fell out of the pill (PM 2026-10-29) */
    gap: .5rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding: .25rem 1rem .5rem;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    cursor: grab;
    -webkit-overflow-scrolling: touch;
}

.ai-suggest:hover { scrollbar-color: #c9ced4 transparent; }
.ai-suggest.is-dragging { cursor: grabbing; }
.ai-suggest::-webkit-scrollbar { height: 5px; }
.ai-suggest::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.ai-suggest:hover::-webkit-scrollbar-thumb { background: #c9ced4; }

.ai-suggest__chip {
    flex-shrink: 0;
    align-self: center;
    border: 1px solid var(--ai-border);
    background: #fff;
    border-radius: 999px;
    padding: .35rem .8rem;
    font-size: .82rem;
    line-height: 1.3;
    white-space: nowrap;
    transition: all .15s ease;
}

.ai-suggest__chip:hover { border-color: var(--ai-green); color: var(--ai-green); }

/* composer */
.ai-composer {
    margin: 0 1rem 1rem;
    border: 1px solid var(--ai-border);
    border-radius: 1rem;
    padding: .6rem .75rem .5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .04);
}

.ai-composer:focus-within { border-color: var(--ai-green); box-shadow: 0 0 0 3px rgba(62, 123, 39, .12); }

.ai-composer__input {
    width: 100%;
    border: 0;
    outline: 0;
    resize: none;
    font-size: .95rem;
    line-height: 1.4;
    max-height: 120px;
    background: transparent;
}

.ai-composer__row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .25rem; }
.ai-composer__hint { font-size: .72rem; color: var(--ai-muted); }
.ai-composer__buttons { display: flex; gap: .4rem; }

.ai-roundbtn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--ai-border);
    background: #fff;
    color: var(--ai-green);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all .15s ease;
}

.ai-roundbtn--send { background: var(--ai-green); border-color: var(--ai-green); color: #fff; }
.ai-roundbtn:disabled { opacity: .5; cursor: not-allowed; }
.ai-roundbtn--mic.is-listening { background: #fde8e8; border-color: #e35d5d; color: #e35d5d; }

/* --------------------------------------------------------------- results */
.ai-results {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: #fff;
    container-type: inline-size; /* the card grid follows the list's own width, not the window's */
}

@container (max-width: 500px) {
    .ai-results .ai-cards { grid-template-columns: minmax(0, 1fr); } /* outranks the two-column rule below; minmax so nowrap text cannot widen the track */
}

.ai-filters {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem 1.25rem;
    border-bottom: 1px solid var(--ai-border);
}

.ai-chips { display: flex; flex-wrap: wrap; gap: .5rem; min-width: 0; }

.ai-chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    flex-shrink: 0;
    white-space: nowrap;
    border: 1px solid var(--ai-border);
    border-radius: 999px;
    padding: .35rem .85rem;
    font-size: .85rem;
    font-weight: 500;
    line-height: 1.3;
    background: #fff;
}

.ai-chip--fixed { border-color: var(--ai-green); color: var(--ai-green); background: var(--ai-green-soft); }
.ai-chip--fixed.ai-chip--lease { border-color: #f59f00; color: #b36b00; background: #fff4e0; }
.ai-chip--fixed.ai-chip--sold { border-color: #c1121f; color: #c1121f; background: #fdeaec; }
/* "Clear all" sits after the removable chips (2026-10-30) */
.ai-chip--clear { cursor: pointer; color: var(--ai-muted); border-style: dashed; background: #fff; font: inherit; }
.ai-chip--clear:hover { color: #c1121f; border-color: #c1121f; background: #fdeaec; }

.ai-chip__x {
    border: 0;
    background: transparent;
    padding: 0;
    line-height: 1;
    color: #6b7280;
    font-size: .95rem;
}

.ai-chip__x:hover { color: #dc3545; }

.ai-savebtn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    border: 1px solid var(--ai-border);
    background: #fff;
    border-radius: .6rem;
    padding: .45rem .9rem;
    font-weight: 600;
    font-size: .9rem;
    transition: all .15s ease;
}

.ai-savebtn:hover:not(:disabled) { border-color: var(--ai-green); color: var(--ai-green); }
.ai-savebtn:disabled { opacity: .5; cursor: not-allowed; }
.ai-savebtn.is-saved { border-color: var(--ai-green); color: var(--ai-green); background: var(--ai-green-soft); }

.ai-results__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem .5rem;
}

.ai-results__title { font-weight: 700; font-size: 1.15rem; }
.ai-results__hint { font-size: .8rem; color: var(--ai-muted); white-space: nowrap; }

.ai-cards {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
    padding: .25rem 1.25rem 1rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)); /* design: two cards per row */
    gap: 1.25rem 1rem;
    align-content: start;
}

.ai-more { grid-column: 1 / -1; padding: .5rem 0 1rem; text-align: center; min-height: 2.5rem; }
.ai-more__loading { font-size: .85rem; color: var(--ai-muted); }
.ai-more__loading .spinner-border { width: 1rem; height: 1rem; border-width: .15em; margin-right: .4rem; vertical-align: -.15em; }

.ai-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--ai-muted);
    padding: 3rem 1rem;
}

.ai-empty i { font-size: 2rem; color: var(--ai-green); display: block; margin-bottom: .5rem; }

/* listing card */
/* overflow:hidden on the grid item made Chromium size every row at 2px (the cards
   vanished, seen in the browser 2026-10-29); the image box clips itself instead. */
.ai-card {
    position: relative;
    border-radius: 1rem;
    overflow: visible;
    background: #fff;
    border: 1px solid transparent;
    transition: box-shadow .15s ease, border-color .15s ease;
}

.ai-card:hover, .ai-card.is-hot { box-shadow: 0 8px 24px rgba(0, 0, 0, .10); border-color: var(--ai-border); }

.ai-card__link { position: absolute; inset: 0; z-index: 1; text-indent: -9999px; overflow: hidden; }
.ai-card__link:focus-visible { outline: 2px solid var(--ai-green); outline-offset: -2px; }

.ai-card__media { position: relative; aspect-ratio: 4 / 3; background: #eef0f2; border-radius: 1rem; overflow: hidden; }
.ai-card__media img { width: 100%; height: 100%; object-fit: cover; display: block; }

.ai-card__badges { position: absolute; top: .6rem; left: .6rem; display: flex; gap: .35rem; flex-wrap: wrap; z-index: 2; }

.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: #fff;
    border-radius: 999px;
    padding: .25rem .6rem;
    font-size: .74rem;
    font-weight: 600;
    color: #222;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

.ai-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ai-green); }
.ai-badge--lease::before { background: #f59f00; }
.ai-badge--sold::before { background: #c1121f; }
.ai-badge--match { color: var(--ai-green); }
.ai-badge--match::before { content: "✦"; width: auto; height: auto; background: none; font-size: .7rem; }

.ai-card .btn-favorite { margin: .6rem !important; width: 34px; height: 34px; z-index: 2; }
.ai-card .btn-favorite i { font-size: 18px; }

.ai-card__mls {
    position: absolute;
    right: .6rem;
    bottom: .6rem;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: .68rem;
    padding: .15rem .45rem;
    border-radius: .35rem;
}

.ai-card__body { padding: .75rem .85rem .7rem; }
.ai-card__top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.ai-card__price { font-weight: 700; font-size: 1.05rem; }
.ai-card__price .was { text-decoration: line-through; color: var(--ai-muted); font-weight: 400; font-size: .8rem; margin-right: .3rem; }
.ai-card__price .sold { color: #c1121f; }
.ai-card__dom { font-size: .76rem; color: var(--ai-muted); white-space: nowrap; }
.ai-card__addr { font-size: .9rem; color: #333; margin-top: .15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ai-card__facts { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .82rem; color: #444; margin-top: .35rem; }
.ai-card__facts i { margin-right: .25rem; color: #7a8390; }
.ai-card__type { font-size: .82rem; color: #444; margin-top: .5rem; }
.ai-card__type i { margin-right: .3rem; color: #7a8390; }
.ai-card__oh { font-size: .82rem; color: #444; margin-top: .3rem; }
.ai-card__oh i { margin-right: .3rem; color: var(--ai-green); }
.ai-card__oh b { color: var(--ai-green); font-weight: 600; }
.ai-card__locked { font-size: .8rem; color: var(--ai-muted); }
.ai-card__area { font-size: .8rem; color: var(--ai-muted); margin-top: .1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-card__desc {
    font-size: .8rem;
    color: #555;
    margin-top: .45rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ai-card__meta { display: flex; justify-content: space-between; gap: .5rem; font-size: .76rem; color: var(--ai-muted); margin-top: .45rem; }

.ai-card.is-locked img { filter: blur(6px); }

/* skeletons */
.ai-skel { border-radius: 1rem; overflow: hidden; }
.ai-skel__media, .ai-skel__line {
    background: linear-gradient(90deg, #eef0f2 25%, #f7f8fa 37%, #eef0f2 63%);
    background-size: 400% 100%;
    animation: ai-shimmer 1.4s ease infinite;
}
.ai-skel__media { aspect-ratio: 4 / 3; }
.ai-skel__line { height: 12px; border-radius: 6px; margin: .6rem .25rem 0; }
.ai-skel__line.w60 { width: 60%; }
.ai-skel__line.w80 { width: 80%; }

@keyframes ai-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ------------------------------------------------------------------- map */
.ai-map { position: relative; min-height: 0; border-left: 1px solid var(--ai-border); }
#aiMap { position: absolute; inset: 0; }

.ai-map__legend {
    position: absolute;
    left: .75rem;
    bottom: .75rem;
    background: rgba(255, 255, 255, .95);
    border-radius: 999px;
    padding: .35rem .8rem;
    font-size: .76rem;
    display: flex;
    gap: .9rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
    z-index: 2;
}

.ai-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .3rem; vertical-align: middle; }
.ai-dot--sale { background: var(--ai-green); }
.ai-dot--lease { background: #f59f00; }
.ai-dot--sold { background: #c1121f; }

/* Price pill like the mobile map: amount inside a ring coloured by listing kind
   (green sale, orange lease, red sold/leased). Rendered as HTML markers for whatever
   the clustered source shows at the current zoom. */
.ai-pin {
    --pin: var(--ai-green);
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: #fff;
    border: 2px solid var(--pin);
    border-radius: 999px;
    padding: .2rem .6rem;
    font-size: .78rem;
    font-weight: 700;
    color: #1f2937;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
    white-space: nowrap;
    cursor: pointer;
    transition: transform .12s ease, background .12s ease;
}

.ai-pin::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--pin); }
.ai-pin--lease { --pin: #f59f00; }
.ai-pin--sold { --pin: #c1121f; }
.ai-pin.is-hot, .ai-pin:hover { transform: scale(1.1); background: var(--pin); color: #fff; }
.ai-pin.is-hot::before, .ai-pin:hover::before { background: #fff; }

.ai-cluster {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ai-green);
    color: #fff;
    font-weight: 700;
    font-size: .8rem;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
    cursor: pointer;
    transition: transform .12s ease;
}

.ai-cluster--md { width: 44px; height: 44px; font-size: .88rem; }
.ai-cluster--lg { width: 54px; height: 54px; font-size: .95rem; }
.ai-cluster:hover { transform: scale(1.08); }
/* a hovered card whose pin is folded into this cluster (2026-10-30) */
.ai-cluster.is-hot { background: #1b1b1b; transform: scale(1.14); box-shadow: 0 0 0 4px rgba(62, 123, 39, .35), 0 2px 6px rgba(0, 0, 0, .3); }

/* hover / tap popup with one card, or the cluster's cards */
.ai-popup {
    width: 290px;
    max-height: 340px;
    overflow-y: auto;
    background: #fff;
    border-radius: .9rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
    padding: .5rem;
    font-size: .82rem;
}

.ai-popup__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    padding: .2rem .35rem .5rem;
    color: #333;
}

.ai-popup__head a { font-size: .78rem; font-weight: 600; }

.ai-popup__card {
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: .6rem;
    align-items: start;
    padding: .4rem .35rem;
    border-radius: .6rem;
    color: inherit;
    text-decoration: none;
}

.ai-popup__card:hover { background: var(--ai-bg); color: inherit; }
.ai-popup__card + .ai-popup__card { border-top: 1px solid var(--ai-border); }
.ai-popup__img { width: 92px; height: 68px; object-fit: cover; border-radius: .5rem; background: #eef0f2; display: block; }
.ai-popup__price { font-weight: 700; font-size: .92rem; }
.ai-popup__price .sold { color: #c1121f; }
.ai-popup__price .was { text-decoration: line-through; color: var(--ai-muted); font-weight: 400; font-size: .74rem; margin-right: .25rem; }
.ai-popup__addr { color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-popup__meta { color: var(--ai-muted); font-size: .76rem; }
.ai-popup__badge { display: inline-block; font-size: .68rem; font-weight: 600; border-radius: 999px; padding: .05rem .45rem; background: var(--ai-green-soft); color: var(--ai-green); margin-bottom: .15rem; }
.ai-popup__badge--lease { background: #fff3cd; color: #8a5a00; }
.ai-popup__badge--sold { background: #ffebee; color: #c62828; }

/* The Azure popup chrome stays, our card provides the look. */
.ai-map .atlas-map-popup .popup-content-container, .ai-map .popup-content-container { padding: 0 !important; border-radius: .9rem !important; background: transparent !important; box-shadow: none !important; }

/* mobile: chat / list / map switcher */
.ai-mobilebar { display: none; }
.ai-viewhomes { display: none; }

/* ------------------------------------------------------------ voice modal */
.ai-voice {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .35);
    z-index: 1060;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.ai-voice__card {
    background: #fff;
    border-radius: 1.5rem;
    width: min(520px, 100%);
    padding: 1.5rem 1.75rem 1.75rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
    text-align: center;
}

.ai-voice__top { display: flex; justify-content: space-between; align-items: center; }
.ai-voice__status { font-size: .78rem; font-weight: 700; letter-spacing: .08em; color: var(--ai-green); }
.ai-voice__lang {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    margin-top: 1rem;
    border: 1px solid var(--ai-border);
    border-radius: 999px;
    padding: .25rem .5rem .25rem .8rem;
    font-size: .85rem;
    color: #333;
    background: #fff;
}

.ai-voice__lang i { color: var(--ai-green); }
.ai-voice__lang select { border: 0; background: transparent; font-weight: 600; font-size: .85rem; color: #222; outline: 0; max-width: 200px; }

.ai-voice__transcript { font-size: 1.35rem; font-weight: 600; min-height: 3.5rem; margin: 1.25rem 0 1rem; color: #222; }
.ai-voice__transcript.is-placeholder { color: var(--ai-muted); font-weight: 400; }

.ai-voice__bars { display: flex; justify-content: center; align-items: center; gap: 3px; height: 40px; margin: 1.5rem 0; }
.ai-voice__bars i { width: 3px; border-radius: 2px; background: var(--ai-green); height: 8px; animation: ai-bar 1s ease-in-out infinite; }
.ai-voice__bars.is-idle i { animation-play-state: paused; height: 8px; }

@keyframes ai-bar { 0%, 100% { height: 8px; } 50% { height: 32px; } }

.ai-voice__stop {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 6px solid var(--ai-green-soft);
    background: var(--ai-green);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: .5rem auto;
}

.ai-voice__stop span { width: 18px; height: 18px; background: #fff; border-radius: 3px; display: block; }
.ai-voice__hint { font-size: .8rem; color: var(--ai-muted); margin-top: 1rem; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1399.98px) {
    :root { --ai-chat-w: 330px; --ai-map-w: 36%; }
}

@media (max-width: 1199.98px) {
    .ai-shell { grid-template-columns: var(--ai-chat-w) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) 300px; }
    .ai-chat { grid-row: 1 / span 3; }
    .ai-filters { grid-column: 2; }
    .ai-results { grid-column: 2; grid-row: 2; }
    .ai-map { grid-column: 2; grid-row: 3; border-left: 0; border-top: 1px solid var(--ai-border); }
}

/* Phones (design 2026-10-29): the filter bar stays on top, the list or the map fills the
   screen under it, a floating pill flips between them, and the chat is a sheet docked to
   the bottom that can be dragged up (--ai-sheet-h is set by aiSearch.js). */
@media (max-width: 768px) { /* wave 4: design phone layout (sheet + Map pill) includes 768 */
    .ai-shell {
        display: flex;
        flex-direction: column;
        height: calc(100vh - var(--ai-header-h) - var(--ai-footer-h, 0px));
        height: calc(100dvh - var(--ai-header-h) - var(--ai-footer-h, 0px));
        min-height: 0;
        overflow: hidden;
    }

    .ai-filters { flex-shrink: 0; padding: .6rem .9rem; gap: .5rem; }
    .ai-chips { flex: 1 1 auto; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; padding: 2px 0; }
    .ai-chips::-webkit-scrollbar { display: none; }

    /* list and map share the space under the bar; the sheet floats over them */
    .ai-results, .ai-map {
        position: absolute;
        top: var(--ai-filters-h, 56px);
        left: 0;
        right: 0;
        bottom: 0;
        display: none;
        border: 0;
    }

    .ai-shell[data-view="list"] .ai-results { display: flex; }
    .ai-shell[data-view="map"] .ai-map { display: block; }
    .ai-results__hint { display: none; }
    .ai-results__head { padding: .75rem .9rem .4rem; }
    .ai-cards { padding: .25rem .9rem calc(var(--ai-sheet-h, 300px) + 1rem); grid-template-columns: minmax(0, 1fr); }
    .ai-map__legend { display: none; }

    .ai-stagetoggle {
        display: inline-flex;
        align-items: center;
        gap: .5rem;
        position: absolute;
        left: 50%;
        bottom: calc(var(--ai-sheet-h, 300px) + 18px);
        transform: translateX(-50%);
        z-index: 7;
        border: 0;
        border-radius: 999px;
        background: #111;
        color: #fff;
        font-weight: 600;
        font-size: .95rem;
        padding: .7rem 1.4rem;
        box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
        transition: bottom .25s ease;
    }

    .ai-shell.is-dragging .ai-stagetoggle { transition: none; }
    .ai-shell.is-sheet-open .ai-stagetoggle { display: none; } /* expanded sheet covers the stage */

    .ai-chat {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        height: var(--ai-sheet-h, 300px);
        z-index: 6;
        background: #fff;
        border-right: 0;
        border-radius: 1.25rem 1.25rem 0 0;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, .18);
        transition: height .25s ease;
    }

    .ai-shell.is-dragging .ai-chat { transition: none; }

    .ai-sheet__grip {
        display: flex;
        justify-content: center;
        padding: .6rem 0 .1rem;
        cursor: grab;
        touch-action: none;
        flex-shrink: 0;
    }

    .ai-sheet__grip span { width: 42px; height: 5px; border-radius: 3px; background: #cfd4da; display: block; }
    .ai-chat__head { padding: .4rem 1rem .8rem; cursor: grab; touch-action: none; }
    .ai-history { top: 78px; }
    .ai-messages { padding: .75rem 1rem; }
    .ai-composer { margin: 0 .75rem .75rem; }

    /* "View N homes" pill in the chat collapses the sheet */
    .ai-viewhomes {
        display: inline-flex;
        align-items: center;
        gap: .4rem;
        align-self: center;
        border: 1px solid var(--ai-green);
        color: var(--ai-green);
        background: var(--ai-green-soft);
        border-radius: 999px;
        padding: .4rem .9rem;
        font-weight: 600;
        font-size: .85rem;
    }
}

/* ======================================================================
   P2-e (PM 2026-11-04): wz2 restyle per the prototype "aisearch" screen.
   The tokens live on body.wz2 (and body.wz2.commercial), so the AI colours
   are re-declared here where those tokens resolve.
   ====================================================================== */
body.wz2 {
    --ai-border: var(--wz-line);
    --ai-muted: var(--wz-muted);
    --ai-bg: var(--wz-soft);
    --ai-green: var(--wz-p);
    --ai-green-soft: var(--wz-tint);
}

body.wz2.ai-page .ai-shell { font-family: var(--wz-font); color: var(--wz-ink); }

body.wz2 .ai-chat { background: var(--wz-bg); }
body.wz2 .ai-chat__title { font-size: 15px; color: var(--wz-ink); }

body.wz2 .ai-iconbtn { border-color: var(--wz-line); color: var(--wz-ink2); }
body.wz2 .ai-iconbtn:hover,
body.wz2 .ai-iconbtn.is-active { border-color: var(--wz-p); color: var(--wz-p); background: var(--wz-tint); }

/* chat bubbles: soft grey bot, brand user, small tail corner */
body.wz2 .ai-msg__bubble { border-radius: 18px; font-size: 14.5px; }
body.wz2 .ai-msg--ai .ai-msg__bubble { background: var(--wz-soft); color: var(--wz-ink); border-bottom-left-radius: 6px; }
body.wz2 .ai-msg--user .ai-msg__bubble { background: var(--wz-p); color: #fff; border-bottom-right-radius: 6px; }
body.wz2 .ai-msg--error .ai-msg__bubble { background: var(--wz-err-bg); color: var(--wz-err); }
body.wz2 .ai-msg__avatar { background: var(--wz-tint); color: var(--wz-p); }

/* composer: rounded pill box, tinted mic, solid send */
body.wz2 .ai-composer {
    border: 1px solid var(--wz-line2);
    border-radius: 22px;
    padding: 12px 10px 10px 16px;
    box-shadow: 0 2px 12px rgba(17, 20, 24, .06);
}

body.wz2 .ai-composer:focus-within { border-color: var(--wz-p); box-shadow: var(--wz-focus-ring); }
body.wz2 .ai-composer__input { font-size: 14.5px; color: var(--wz-ink); }
body.wz2 .ai-roundbtn { width: 36px; height: 36px; border: 0; }
body.wz2 .ai-roundbtn--mic { background: var(--wz-tint); color: var(--wz-p); }
body.wz2 .ai-roundbtn--send { background: var(--wz-p); color: #fff; }
body.wz2 .ai-roundbtn--send:hover:not(:disabled) { background: var(--wz-p-d); }
body.wz2 .ai-roundbtn--mic.is-listening { background: var(--wz-err-bg); color: var(--wz-err); }

/* suggestion + criteria chips */
body.wz2 .ai-suggest__chip,
body.wz2 .ai-chip { border-color: var(--wz-line2); color: var(--wz-ink2); font-size: 13px; }
body.wz2 .ai-suggest__chip:hover { border-color: var(--wz-p); color: var(--wz-p); background: var(--wz-tint2); }
body.wz2 .ai-chip[data-key] { border-color: var(--wz-p); background: var(--wz-tint); color: var(--wz-ok); }
body.wz2 .ai-chip--fixed { border-color: var(--wz-p); color: var(--wz-ok); background: var(--wz-tint); }
body.wz2 .ai-chip__x { color: inherit; opacity: .7; }
body.wz2 .ai-chip__x:hover { color: var(--wz-err); opacity: 1; }

body.wz2 .ai-savebtn { border-color: var(--wz-line2); border-radius: var(--wz-r); color: var(--wz-ink); font-size: 13.5px; }
body.wz2 .ai-savebtn:hover:not(:disabled),
body.wz2 .ai-savebtn.is-saved { border-color: var(--wz-p); color: var(--wz-p); background: var(--wz-tint); }

body.wz2 .ai-results__title { font-size: 20px; color: var(--wz-ink); }

/* match badge (Great match / Match / Close match) on the JS fallback cards */
body.wz2 .ai-badge--match { color: var(--wz-ok); }
body.wz2 .ai-badge--match.is-close { color: var(--wz-warn); }

/* Cards rendered by the shared _WzListingCard partial: the wrapper only carries the
   hover/pin hooks (data-mls); the card itself draws border, radius and shadow. */
body.wz2 .ai-card.ai-card--wz { border: 0; border-radius: var(--wz-r-lg); background: transparent; }
body.wz2 .ai-card.ai-card--wz:hover,
body.wz2 .ai-card.ai-card--wz.is-hot { box-shadow: none; }
body.wz2 .ai-card.ai-card--wz.is-hot > * { box-shadow: 0 0 0 2px var(--wz-p); border-radius: var(--wz-r-lg); }

/* save modal */
body.wz2 #aiSaveModal .modal-content { border: 0; border-radius: var(--wz-r-modal); box-shadow: var(--wz-shadow-lg); }
body.wz2 #aiSaveModal .btn-primary { background: var(--wz-p); border-color: var(--wz-p); }
.ai-save__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ai-save__chips:empty { display: none; }
.ai-save__chips span {
    border: 1px solid var(--ai-border);
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12.5px;
    color: var(--ai-muted);
}

/* map legend dots follow the tokens */
body.wz2 .ai-dot--sale { background: var(--wz-mls); }

/* === 2026-11-18 wave 4: public (design aisearch) === */
/* 1440: chat 420px, results ~510px with two cards per row, map in an inset rounded card (12px gap); title on its own
   line (26px) with the hint under it; legend = the main map's source colours (MLS / FSBO / Pre-Con / Sold / Leased). */
@media (min-width: 1400px) {
    :root { --ai-chat-w: 420px; --ai-map-w: 510px; }
}
@media (min-width: 769px) {
    body.wz2 .ai-map { padding: 12px; border-left: 0; }
    body.wz2 .ai-map #aiMap { inset: 12px; overflow: hidden; border-radius: 20px; }
    body.wz2 .ai-map .ai-map__legend { left: 28px; bottom: 28px; }
}
body.wz2 .ai-results__head { display: block; padding: 22px 24px 12px; }
body.wz2 .ai-results__title { display: block; font-size: 26px; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; }
body.wz2 .ai-results__hint { display: block; margin-top: 10px; font-size: 13px; white-space: normal; }
body.wz2 .ai-dot--fsbo { background: var(--wz-fsbo); }
body.wz2 .ai-dot--precon { background: var(--wz-precon); }
body.wz2 .ai-dot--sold { background: #A6A9A4; }
body.wz2 .ai-pin--lease { --pin: var(--wz-mls); }
body.wz2 .ai-pin--sold { --pin: #A6A9A4; }
/* the design page has no footer: the copyright bar goes too (aiSearch.js then measures 0 for --ai-footer-h) */
body.ai-page .wz-footer { display: none; }
@media (max-width: 768px) {
    /* design 768: title and hint on one row; 390: title 24px with the hint under it */
    body.wz2 .ai-results__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; padding: 18px 16px 12px; }
    body.wz2 .ai-results__title { font-size: 24px; }
    body.wz2 .ai-results__hint { display: block; margin-top: 0; }
}
/* === end === */
/* === 2026-11-19 round 5: public === */
/* AI search sheet head (design 768 / 390): history and new-chat glyphs in ink on 40px outlined circles. */
body.wz2 .ai-chat__head .ai-iconbtn { color: var(--wz-ink); border-color: var(--wz-line2); }
body.wz2 .ai-chat__head .ai-iconbtn .bi { font-size: 17px; -webkit-text-stroke: .3px currentColor; }
@media (max-width: 991.98px) {
    body.wz2 .ai-chat__head .ai-iconbtn { width: 40px; height: 40px; }
}
/* === end === */

/* === 2026-11-20: listing (CG #6) - AI search for guests: free searches left + sign-in card === */
.ai-guest { margin: 0 1rem .6rem; }
.ai-guest__left {
    display: flex; align-items: flex-start; gap: .5rem;
    font-size: .82rem; line-height: 1.4; color: var(--ai-muted);
    background: var(--ai-bg); border-radius: .75rem; padding: .55rem .75rem;
}
.ai-guest__left .bi { color: var(--ai-green); font-size: .95rem; line-height: 1.3; }
.ai-guest__link { border: 0; background: none; padding: 0; color: var(--ai-green); font-weight: 600; text-decoration: underline; font-size: inherit; }
.ai-guest__gate {
    border: 1px solid var(--ai-border); border-radius: 1rem; padding: 1.1rem 1rem 1rem;
    text-align: center; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .04);
}
.ai-guest__ic {
    display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%;
    background: var(--ai-green-soft); color: var(--ai-green); font-size: 1.1rem; margin-bottom: .5rem;
}
.ai-guest__t { font-size: 1.02rem; font-weight: 700; margin: 0 0 .3rem; color: #1a1d21; }
.ai-guest__d { font-size: .85rem; color: var(--ai-muted); margin: 0 0 .85rem; line-height: 1.45; }
.ai-guest__btn { display: flex; width: 100%; justify-content: center; }
.ai-guest__btn + .ai-guest__btn { margin-top: .5rem; }
/* === end === */
/* === 2026-11-23: design2 === */
/* Designer A10, phone AI search as the design (wizreal-web.css .ais-chat:not(.open)): the collapsed sheet shows only the
   last message in a 64px window that fades at the top, no "Enter to send" hint, and a tighter guest note. aiSearch.js
   sizes the sheet to this content and re-measures the filter bar, so the status chip is no longer under the list. */
@media (max-width: 768px) {
    .ai-shell:not(.is-sheet-open) .ai-messages {
        flex: 0 0 auto; max-height: 64px; overflow: hidden; padding: 0 1rem 6px; justify-content: flex-end;
        -webkit-mask-image: linear-gradient(180deg, transparent, #000 45%); mask-image: linear-gradient(180deg, transparent, #000 45%);
    }
    .ai-shell:not(.is-sheet-open) .ai-messages > .ai-msg:has(~ .ai-msg) { display: none; }
    .ai-composer__hint { display: none; }
    .ai-composer__buttons { margin-left: auto; }
    .ai-composer { margin: 0 12px 14px; }
    .ai-guest { margin: 0 12px 8px; }
    .ai-guest__left { padding: .4rem .65rem; font-size: .78rem; }
}
/* === end === */

/* === 2026-12-02: qa2 === */
/* QA BUG-118: characters used under the composer; QA BUG-116: the kept question in the guest card. */
.ai-composer__count { margin-left: auto; font-size: .72rem; color: var(--ai-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ai-composer__count.is-full { color: #b42318; font-weight: 600; }
.ai-composer__count + .ai-composer__buttons { margin-left: .5rem; }
.ai-guest__kept { font-size: .82rem; color: var(--ai-ink, #1f2937); background: rgba(62, 123, 39, .08); border-radius: 8px; padding: .5rem .65rem; margin: 0 0 .85rem; line-height: 1.4; overflow-wrap: anywhere; }
/* === end === */
/* === 2026-12-03: ai2 === */
/* QA AI-44: the "Get the Wizreal app" banner (pwa-install.js, fixed at the bottom, phones and tablets) covered the
   message box. While it shows, the page ends above it (pwa-install.js puts has-pwa-prompt and --wz-appban-h on body);
   "Not now" removes both and the page takes the full height again. */
body.ai-page.has-pwa-prompt .ai-shell {
    height: calc(100vh - var(--ai-header-h) - var(--ai-footer-h, 0px) - var(--wz-appban-h, 96px) - 28px);
    height: calc(100dvh - var(--ai-header-h) - var(--ai-footer-h, 0px) - var(--wz-appban-h, 96px) - 28px);
    min-height: 0;
}
/* QA AI-28: links a server reply may carry, under its sentence. */
.ai-msg__links { display: flex; flex-wrap: wrap; gap: .35rem .9rem; margin-top: .45rem; }
.ai-msg__links a { font-weight: 600; color: var(--wz-p, #3e7b27); text-decoration: underline; text-underline-offset: 2px; }
/* QA 2026-12-04: "Start a new chat" under a chat that failed three times in a row. */
.ai-msg__action { border: 1px solid var(--wz-p, #3e7b27); background: #fff; color: var(--wz-p, #3e7b27); font: inherit; font-weight: 600; border-radius: 999px; padding: .3rem .9rem; cursor: pointer; }
.ai-msg__action:hover, .ai-msg__action:focus-visible { background: var(--wz-p, #3e7b27); color: #fff; }
/* QA AI-40: suggestions are off while a question is in flight. */
.ai-suggest__chip:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
/* QA AI-41: the reason under an empty name in Save Search. */
#aiSaveModal .invalid-feedback:empty { display: none !important; }
/* === end === */
