:root {
  --chat-rail: 1160px;
  --ai-bubble: 680px;
  --user-bubble: 520px;
}

.property-detail-drawer {
  box-sizing: border-box;
  display: flex;
  position: fixed;
  z-index: 60;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(100%, 430px);
  min-width: 0;
  overflow: hidden;
  flex-direction: column;
  border-left: 1px solid #dfe6e2;
  background: #fff;
  box-shadow: -8px 0 24px rgba(22, 48, 40, .09);
  opacity: 0;
  visibility: hidden;
  transform: translateX(100%);
  pointer-events: none;
  transition: transform 240ms ease, opacity 200ms ease, visibility 0s linear 240ms;
}
.app-shell.detail-open .property-detail-drawer { opacity: 1; visibility: visible; transform: translateX(0); pointer-events: auto; transition-delay: 0s; }
.property-detail-header { display: flex; flex: 0 0 64px; align-items: center; justify-content: space-between; padding: 0 18px; border-bottom: 1px solid #e4e9e7; }
.property-detail-header h2 { margin: 0; color: #1d2925; font-size: 15px; font-weight: 700; }
.property-detail-close { display: grid; width: 34px; height: 34px; padding: 0; place-items: center; border: 0; border-radius: 50%; background: transparent; color: #53615c; cursor: pointer; }
.property-detail-close:hover { background: #f0f5f2; }
.property-detail-close svg { width: 18px; height: 18px; }
.property-detail-content { min-height: 0; padding: 18px; overflow-y: auto; overscroll-behavior: contain; }
.property-detail-image { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 9px; background: #edf2ef; }
.property-detail-status { display: inline-flex; margin-top: 12px; padding: 4px 7px; border-radius: 4px; background: #e5f4eb; color: #19704e; font-size: 9px; font-weight: 700; text-transform: uppercase; }
.property-detail-content h3 { margin: 13px 0 0; color: #1d2925; font-size: 16px; line-height: 1.45; }
.property-detail-location { display: flex; gap: 6px; align-items: flex-start; margin: 8px 0 0; color: #68756f; font-size: 11px; line-height: 1.45; }
.property-detail-location svg { flex: 0 0 14px; width: 14px; height: 14px; margin-top: 1px; }
.property-detail-price { margin-top: 14px; color: #06715d; font-size: 21px; font-weight: 700; line-height: 1.35; }
.property-detail-facts { display: grid; gap: 0; margin: 16px 0 0; border-top: 1px solid #e5eae8; }
.property-detail-facts > div { display: grid; grid-template-columns: minmax(90px, .8fr) minmax(0, 1.2fr); gap: 10px; padding: 10px 0; border-bottom: 1px solid #edf0ef; font-size: 10px; line-height: 1.4; }
.property-detail-facts dt { color: #718079; }
.property-detail-facts dd { margin: 0; color: #26342f; font-weight: 600; text-align: right; }
.property-detail-amenities { margin-top: 18px; }
.property-detail-amenities h4 { margin: 0 0 9px; font-size: 12px; }
.property-detail-amenities p { margin: 0; color: #78847f; font-size: 10px; line-height: 1.5; }
.property-detail-amenities ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.property-detail-amenities li { display: flex; gap: 7px; color: #52625c; font-size: 10px; }
.property-detail-amenities svg { width: 13px; height: 13px; color: #159477; }
.property-detail-actions { display: grid; gap: 8px; margin-top: 22px; padding-bottom: 8px; }
.property-detail-actions button { display: flex; min-height: 42px; align-items: center; justify-content: center; gap: 7px; border: 1px solid #08715d; border-radius: 6px; background: #08715d; color: #fff; font-size: 11px; font-weight: 700; cursor: pointer; }
.property-detail-actions button + button { background: #fff; color: #08715d; }
.property-detail-actions button.saved { background: #eef7f4; }
.property-detail-actions svg { width: 15px; height: 15px; }

.workspace { position: relative; min-width: 0; }
.brand { align-items: center; }
.brand-copy { display: flex; min-width: 0; flex-direction: column; justify-content: center; gap: 3px; overflow: visible; }
.brand-copy strong { color: #17211d; font-size: 16px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.brand-copy small { display: block !important; overflow: visible; color: #7b8581; font-size: 10px; font-weight: 400; line-height: 1.3; opacity: 1 !important; visibility: visible !important; white-space: nowrap; }

.support-card.advisor-card {
  position: relative;
  width: auto;
  min-height: 108px;
  margin: 10px 18px;
  padding: 17px 88px 15px 15px;
  overflow: hidden;
  border: 1px solid #dbe6e1;
  border-radius: 11px;
  background: #f8faf8;
  text-align: left;
  cursor: pointer;
  transition: box-shadow 160ms ease, transform 160ms ease, border-color 160ms ease;
}
.support-card.advisor-card:hover,
.support-card.advisor-card:focus-visible { border-color: #c9dbd4; outline: none; box-shadow: 0 5px 14px rgba(18, 58, 47, .08); transform: translateY(-1px); }
.advisor-card-copy { position: relative; z-index: 1; }
.advisor-card-copy strong,
.advisor-card-copy span { display: block; }
.advisor-card-copy strong { color: #26332f; font-size: 11px; line-height: 1.4; }
.advisor-card-copy span { margin-top: 6px; color: #7d8984; font-size: 9px; line-height: 1.55; }
.support-card.advisor-card > img { position: absolute; right: 4px; bottom: -10px; width: 90px; height: 114px; object-fit: contain; object-position: center bottom; }

.chat { box-sizing: border-box; padding: 18px 36px 190px !important; overflow-x: hidden; background: #fafbf9; }
.chat .message,
.chat .message.user,
.chat .message.loading-message { box-sizing: border-box; width: min(var(--chat-rail), 100%) !important; max-width: var(--chat-rail) !important; margin: 0 auto 14px !important; }
.chat .message { align-items: flex-end; gap: 10px; }
.chat .message.assistant,
.chat .message.loading-message { align-items: flex-start; }
.chat .message-content { width: auto; max-width: var(--ai-bubble); }
.chat .message.has-cards .message-content,
.chat .message.has-wizard .message-content { width: calc(100% - 44px); max-width: calc(100% - 44px); }
.chat .message .bubble { box-sizing: border-box; width: fit-content; max-width: var(--ai-bubble); height: auto !important; min-height: 0 !important; padding: 14px 16px; border: 1px solid #dce3df; border-radius: 10px 10px 10px 3px; background: #fff; font-size: 13px; line-height: 1.6; white-space: normal !important; box-shadow: 0 3px 10px rgba(25, 50, 42, .06); }
.chat .message.user { justify-content: flex-end !important; }
.chat .message.user .bubble { width: fit-content !important; max-width: var(--user-bubble); margin-left: auto; padding: 12px 15px !important; border: 0; border-radius: 11px 11px 3px 11px; background: #006b58; color: #fff; box-shadow: none; }
.chat .message .avatar,
.chat .user-message-avatar { flex: 0 0 34px; width: 34px; height: 34px; }

.conversation-wizard { box-sizing: border-box; position: relative; width: 100%; margin-top: 8px; padding: 10px 14px; border: 1px solid #cfddd7; border-radius: 10px; background: #fff; box-shadow: 0 3px 10px rgba(25, 50, 42, .04); }
.wizard-heading { gap: 5px; margin-bottom: 0 !important; }
.wizard-heading > div { align-items: center; }
.wizard-heading progress { height: 4px; }
.conversation-wizard > p { margin: 7px 0; font-size: 14px; line-height: 1.35; }
.wizard-options { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.wizard-options button { min-height: 52px; padding: 7px 12px; border-radius: 9px; font-size: 12px; line-height: 1.4; transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease; }
.wizard-options button:hover,
.wizard-options button:focus-visible,
.wizard-options button.selected { border-color: #13806b; outline: none; background: #eef7f3; box-shadow: inset 0 0 0 1px rgba(19, 128, 107, .12); }
.wizard-custom-form { min-height: 38px !important; margin-top: 7px; }
.wizard-custom-form input { padding: 9px 12px; font-size: 12px; }
.wizard-custom-form button { width: 38px; flex: 0 0 38px; }
.wizard-actions { position: absolute; top: 8px; right: 14px; margin: 0; }
.wizard-actions button { padding: 5px 7px; }

.property-results { box-sizing: border-box; width: 100%; margin-top: 14px; }
.property-results-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; color: #26332f; }
.property-results-heading strong { font-size: 14px; line-height: 1.4; }
.chat .message.has-cards .message-content .property-results .property-grid { display: grid !important; grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: 14px; width: 100% !important; max-width: none !important; margin-top: 0 !important; padding: 0; overflow: visible !important; }
.chat .message.has-cards .property-card { display: flex; min-width: 0; width: auto !important; height: auto; overflow: hidden; flex: none !important; flex-direction: column; border: 1px solid #dde4e0; border-radius: 11px; background: #fff; box-shadow: 0 3px 10px rgba(25, 50, 42, .055); transition: box-shadow 160ms ease, transform 160ms ease, border-color 160ms ease; }
.chat .property-card:hover { border-color: #cbdad4; box-shadow: 0 7px 18px rgba(25, 50, 42, .09); transform: translateY(-2px); }
.chat .property-media { display: block; width: 100%; height: auto; margin: 0 !important; padding: 0; aspect-ratio: 1.55 / 1 !important; overflow: hidden; border: 0; border-radius: 0; background: #edf1ef; }
.chat .property-media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.chat .property-card-body { display: flex; flex: 1; flex-direction: column; padding: 12px 13px 6px; }
.chat .property-card-body > strong { min-height: 39px; color: #173f35; font-size: 12px; line-height: 1.45; }
.chat .property-location { min-height: 31px; margin-top: 4px; font-size: 10px; line-height: 1.45; }
.chat .property-facts { display: grid; gap: 3px; min-height: 34px; margin-top: 6px; overflow: hidden; }
.chat .property-facts span { max-width: 100%; color: #65736e; font-size: 10px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.chat .property-card-body > b { min-height: 40px; margin-top: 8px; color: #08715d; font-size: 13px; line-height: 1.4; }
.chat .property-price-sheet-slot { min-height: 22px; margin-top: 6px; line-height: 1.2; }
.chat .property-price-sheet { display: inline; color: #08715d; font-size: 10px; font-weight: 600; line-height: 1.2; text-decoration: none; }
.chat .property-price-sheet:hover,
.chat .property-price-sheet:focus-visible { color: #005746; text-decoration: underline; }
.chat .property-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; min-height: 0; margin-top: auto; padding: 8px 12px 12px; }
.chat .property-actions button { width: 100%; min-width: 0; min-height: 36px; padding: 7px 8px; border-radius: 6px; font-size: 9px; line-height: 1.25; }

.composer { box-sizing: border-box; position: absolute; z-index: 20; right: 0; bottom: 0; left: 0; margin: 0 !important; padding: 10px 24px 12px !important; background: linear-gradient(to top, #fafbf9 72%, rgba(250, 251, 249, .92)); }
.composer-box { box-sizing: border-box; width: min(1020px, 100%) !important; max-width: 1020px !important; min-height: 54px; margin: 0 auto; border-radius: 28px; }
.composer > small { display: block; margin-top: 6px; font-size: 10px; line-height: 1.35; }

@media (min-width: 1181px) {
  .app-shell { grid-template-columns: 266px minmax(0, 1fr) 0; transition: grid-template-columns 240ms ease; }
  .app-shell.detail-open { grid-template-columns: 266px minmax(0, 1fr) 340px; }
  .sidebar { width: 266px; grid-template-rows: 88px 72px minmax(220px, 1fr) auto 66px !important; }
  .brand { padding: 14px 20px; }
  .sidebar-brand-logo { flex: 0 0 54px; width: 54px; height: 54px; }
  .chat .message.has-cards .message-content .property-results .property-grid {
    display: flex !important;
    grid-template-columns: none !important;
    gap: 14px;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    flex-wrap: nowrap;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    scrollbar-color: #8ba69d #edf2f0;
    overscroll-behavior-x: contain;
    padding-bottom: 8px;
  }
  .chat .message.has-cards .message-content .property-results .property-grid::-webkit-scrollbar { height: 7px; }
  .chat .message.has-cards .message-content .property-results .property-grid::-webkit-scrollbar-track { border-radius: 4px; background: #edf2f0; }
  .chat .message.has-cards .message-content .property-results .property-grid::-webkit-scrollbar-thumb { border-radius: 4px; background: #8ba69d; }
  .chat .message.has-cards .message-content .property-results .property-grid::-webkit-scrollbar-thumb:hover { background: #557d70; }
  .chat .message.has-cards .property-card {
    flex: 0 0 calc((100% - 42px) / 4) !important;
    width: calc((100% - 42px) / 4) !important;
    scroll-snap-align: start;
  }
  .app-shell.detail-open .chat .message.has-cards .property-card {
    flex-basis: calc((100% - 28px) / 3) !important;
    width: calc((100% - 28px) / 3) !important;
  }
  .chat .property-media { height: 145px; aspect-ratio: auto !important; }
  .property-detail-drawer { position: relative; z-index: 1; width: 340px; height: 100vh; grid-column: 3; grid-row: 1; transform: translateX(24px); }
}

@media (min-width: 761px) and (max-width: 1180px) {
  .app-shell { grid-template-columns: 230px minmax(0, 1fr) 0; transition: grid-template-columns 240ms ease; }
  .app-shell.detail-open { grid-template-columns: 230px minmax(0, 1fr) 310px; }
  .sidebar { width: 230px; grid-template-rows: 78px 64px minmax(180px, 1fr) auto 62px !important; }
  .brand { padding: 10px 14px; }
  .sidebar-brand-logo { flex: 0 0 46px; width: 46px; height: 46px; }
  .brand-copy strong { font-size: 15px; }
  .brand-copy small { font-size: 10px; white-space: normal; }
  .chat { padding-right: 24px !important; padding-left: 24px !important; }
  .chat .message.has-cards .message-content .property-results .property-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .property-detail-drawer { position: relative; z-index: 1; width: 310px; height: 100vh; grid-column: 3; grid-row: 1; transform: translateX(24px); }
}

@media (max-width: 760px) {
  :root { --ai-bubble: calc(100vw - 66px); --user-bubble: calc(100vw - 66px); }
  .topbar { min-height: 56px; padding: 6px 10px; }
  .chat-heading h1 { font-size: 14px; }
  .chat-heading p { font-size: 10px; }
  .sidebar .brand { min-height: 72px; padding: 9px 14px; }
  .sidebar-brand-logo { flex: 0 0 46px; width: 46px; height: 46px; }
  .brand-copy strong { font-size: 15px; }
  .brand-copy small { font-size: 10px; white-space: normal; }
  .support-card.advisor-card { display: block; }
  .dashboard,
  .welcome-panel { box-sizing: border-box; width: 100%; max-width: 100%; min-width: 0; overflow-x: hidden; }
  .welcome-panel { padding-right: 12px !important; padding-left: 12px !important; }
  .welcome-panel h1 { width: calc(100vw - 24px); max-width: calc(100vw - 24px); padding: 0 4px; font-size: 18px !important; line-height: 1.35; overflow-wrap: anywhere; white-space: normal !important; }
  .welcome-panel > p { width: calc(100vw - 24px); max-width: calc(100vw - 24px); padding: 0 6px; font-size: 11px; line-height: 1.5; white-space: normal !important; }
  .quick-actions { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; width: calc(100vw - 24px) !important; max-width: calc(100vw - 24px) !important; gap: 8px !important; }
  .quick-actions .action-card { box-sizing: border-box; width: 100% !important; min-width: 0; height: 50px; margin: 0; }
  .action-break { display: none !important; }
  .featured-showcase { box-sizing: border-box; width: calc(100vw - 24px); max-width: calc(100vw - 24px); min-width: 0; }
  .featured-heading { width: 100%; }
  .featured-home-grid { width: 100%; max-width: 100%; }
  .hero-search { box-sizing: border-box; width: calc(100% - 18px) !important; max-width: calc(100% - 18px) !important; }
  .chat { padding: 16px 10px 132px !important; }
  .chat .message,
  .chat .message.user,
  .chat .message.loading-message { width: 100% !important; max-width: none !important; margin-bottom: 14px !important; }
  .chat .message { gap: 7px; }
  .chat .message .avatar,
  .chat .user-message-avatar { flex-basis: 30px; width: 30px; height: 30px; }
  .chat .message-content,
  .chat .message.has-cards .message-content,
  .chat .message.has-wizard .message-content { width: calc(100% - 37px); max-width: calc(100% - 37px); }
  .chat .message .bubble,
  .chat .message.user .bubble { max-width: 100%; padding: 11px 12px !important; font-size: 13px; }
  .conversation-wizard { padding: 11px; border-radius: 9px; }
  .conversation-wizard > p { margin: 9px 0 8px; font-size: 14px; }
  .wizard-options { grid-template-columns: 1fr; gap: 7px; }
  .wizard-options button { min-height: 46px; padding: 9px 11px; text-align: left; }
  .wizard-custom-form { display: flex; width: 100%; }
  .wizard-custom-form input { min-width: 0; }
  .property-results { width: 100%; min-width: 0; margin-top: 14px; }
  .property-results-heading strong { font-size: 13px; }
  .chat .message.has-cards .message-content .property-results .property-grid {
    display: flex !important;
    grid-template-columns: none !important;
    gap: 10px;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 8vw 4px 0;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .chat .message.has-cards .message-content .property-results .property-grid::-webkit-scrollbar { display: none; }
  .chat .message.has-cards .property-card {
    width: min(82vw, 300px) !important;
    min-width: 0;
    flex: 0 0 min(82vw, 300px) !important;
    scroll-snap-align: start;
    scroll-snap-stop: normal;
  }
  .chat .property-media { aspect-ratio: 16 / 9 !important; }
  .chat .property-card-body { padding: 10px 11px 5px; }
  .chat .property-card-body > strong {
    display: -webkit-box;
    min-height: 38px;
    overflow: hidden;
    font-size: 13px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .chat .property-location,
  .chat .property-facts span { font-size: 10px; }
  .chat .property-location { min-height: 28px; }
  .chat .property-facts { min-height: 31px; }
  .chat .property-card-body > b { min-height: 36px; margin-top: 6px; font-size: 14px; }
  .chat .property-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chat .property-actions button { min-height: 40px; font-size: 10px; }
  .composer { right: 0; left: 0; padding: 8px 9px 9px !important; }
  .composer-box { width: 100% !important; min-height: 50px; }
  .composer > small { font-size: 10px; }
}

/* Mobile dashboard lock: keep controls inside their tiles and prevent the
   featured rail from opening on a clipped/partially visible card. */
@media (max-width: 760px) {
  .sidebar {
    box-sizing: border-box;
    position: fixed;
    z-index: 40;
    inset: 0 auto 0 0;
    width: min(320px, calc(100vw - 24px)) !important;
    max-width: calc(100vw - 24px) !important;
    height: 100dvh;
    padding: 0 !important;
    overflow: hidden;
  }

  .sidebar .brand,
  .sidebar .new-chat,
  .sidebar .history-panel,
  .sidebar .support-card,
  .sidebar .sidebar-footer {
    min-width: 0;
    max-width: 100%;
  }

  .sidebar .history-panel {
    box-sizing: border-box;
    overflow-x: hidden;
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: 39;
    inset: 0;
  }

  .chat .message.assistant,
  .chat .message.loading-message {
    box-sizing: border-box;
    display: grid !important;
    grid-template-columns: 30px minmax(0, 1fr);
    column-gap: 7px;
    align-items: end;
    width: 100% !important;
    min-width: 0;
    max-width: 100% !important;
  }

  .chat .message.assistant > .avatar,
  .chat .message.loading-message > .avatar {
    grid-column: 1;
    min-width: 30px;
    margin: 0;
  }

  .chat .message.assistant > .message-content,
  .chat .message.loading-message > .message-content {
    grid-column: 2;
    box-sizing: border-box;
    width: 100% !important;
    min-width: 0;
    max-width: 100% !important;
  }

  .app-shell:not(.chat-mode) .welcome-panel {
    padding-right: 12px !important;
    padding-left: 12px !important;
  }

  .app-shell:not(.chat-mode) .quick-actions {
    box-sizing: border-box;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
  }

  .app-shell:not(.chat-mode) .quick-actions .action-card {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    height: 54px !important;
    min-height: 54px !important;
    padding: 7px 10px !important;
    overflow: hidden;
  }

  .app-shell:not(.chat-mode) .quick-actions .action-card > svg {
    position: static !important;
    flex: 0 0 30px !important;
    width: 30px !important;
    height: 30px !important;
    margin: 0 !important;
    padding: 7px !important;
    transform: none !important;
  }

  .app-shell:not(.chat-mode) .quick-actions .action-card > span {
    display: block !important;
    position: static !important;
    min-width: 0;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
    font-size: 10px !important;
    line-height: 1.3 !important;
    text-align: left !important;
    overflow-wrap: normal !important;
  }

  .app-shell:not(.chat-mode) .featured-showcase {
    width: 100% !important;
    max-width: 100% !important;
  }

  .app-shell:not(.chat-mode) .featured-home-grid {
    box-sizing: border-box;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 0 5px !important;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-padding-inline: 0;
  }

  .app-shell:not(.chat-mode) .featured-home-card {
    box-sizing: border-box;
    flex: 0 0 100% !important;
    width: 100% !important;
    min-width: 100% !important;
    scroll-snap-align: start;
  }

  .app-shell:not(.chat-mode) .hero-search {
    right: 9px !important;
    left: 9px !important;
    width: auto !important;
    max-width: none !important;
  }
}
