:root {
  --ink: #111111;
  --muted: #5c5c5c;
  --shell: 1120px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  /* Not part of the supplied palette, but needed to keep error states
     (429/503 messages, etc.) visually distinct from normal text. */
  --danger: #b3261e;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --font-body: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
}

html {
  background: #eef2ee;
}

body {
  background: #eef2ee;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2 {
  font-family: var(--font-body);
  font-weight: 500;
  letter-spacing: -0.03em;
  margin: 0;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

a {
  color: var(--ink);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: #141414;
  color: #ffffff;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--space-2);
  z-index: 100;
}
.skip-link:focus {
  left: var(--space-2);
  top: var(--space-2);
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- Background video ---------- */

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image: url("https://images.higgs.ai/?default=1&output=webp&url=https%3A%2F%2Fd8j0ntlcm91z4.cloudfront.net%2Fuser_38xzZboKViGWJOttwIXH07lWA1P%2Fhf_20260831_223518_f11bfa03-4e65-47e1-a4a7-30e42a7a8c2f.png&w=1920&q=85");
  background-size: cover;
  background-position: center;
  animation: fade-in 1.15s var(--ease) both;
}

.bg-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  .bg-video {
    display: none;
  }
  .bg-layer {
    animation: none !important;
  }
}

/* ---------- Page content (above the video) ---------- */

.page {
  position: relative;
  z-index: 2;
}

/* ---------- Entrance animation ---------- */

@keyframes rise {
  from {
    opacity: 0;
    transform: translate3d(0, 18px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.app-header,
.chat-panel,
.results-panel,
.app-footer {
  animation: rise 0.9s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}

@media (prefers-reduced-motion: reduce) {
  .app-header,
  .chat-panel,
  .results-panel,
  .app-footer {
    animation: none !important;
  }
}

/* ---------- Header ---------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  max-width: var(--shell);
  margin: 0 auto;
  padding: 26px 24px 0;
}

@media (max-width: 899px) {
  .app-header {
    padding: 18px 20px 0;
  }
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

@media (max-width: 899px) {
  .brand {
    font-size: 21px;
  }
}

.brand-icon {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

@media (max-width: 899px) {
  .brand-icon {
    width: 25px;
    height: 25px;
  }
}

.brand h1 {
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-toggle {
  flex-shrink: 0;
  background: #141414;
  color: #ffffff;
  font-size: 14.5px;
  font-weight: 500;
  padding: 13px 22px;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  transition: background-color 0.18s ease, transform 0.18s ease;
}
.lang-toggle:hover {
  background: #000000;
  transform: translateY(-1px);
}

@media (max-width: 899px) {
  .lang-toggle {
    padding: 11px 17px;
    font-size: 13.5px;
  }
}

/* ---------- Layout ---------- */
/* Single centred column over the video background; the chat and results
   cards stack vertically at every width. */

.app-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  max-width: 790px;
  margin: 0 auto;
  padding: var(--space-5) 20px;
}

/* ---------- Glass cards ---------- */

.chat-panel,
.results-panel {
  background: rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 20px;
  box-shadow: 0 18px 44px -26px rgba(0, 0, 0, 0.28);
}

@media (max-width: 639px) {
  .chat-panel,
  .results-panel {
    border-radius: 17px;
  }
}

/* ---------- Chat ---------- */

.chat-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 420px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-height: 60vh;
}

.message {
  max-width: 85%;
  padding: var(--space-3) var(--space-4);
  border-radius: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.message.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(0, 0, 0, 0.07);
  color: var(--ink);
  border-bottom-left-radius: 6px;
}

.message.user {
  align-self: flex-end;
  background: #141414;
  color: #ffffff;
  border-bottom-right-radius: 6px;
}

.message.system-error {
  align-self: center;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: 0.9rem;
}

.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 0 var(--space-4) var(--space-3);
}

.quick-reply-btn {
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.07);
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: background-color 0.18s var(--ease);
}
.quick-reply-btn:hover {
  background: #f1f1ef;
}

.chat-input-row {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.chat-input-row input {
  flex: 1;
  min-height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  background: #ffffff;
  color: var(--ink);
  font-size: 16px;
}

.chat-input-row input::placeholder {
  color: #3d3d3d;
  opacity: 0.72;
}

.btn-icon {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 12px;
  background: #141414;
  color: #ffffff;
  cursor: pointer;
  transition: background-color 0.18s var(--ease);
}
.btn-icon:hover {
  background: #000000;
}
.btn-icon svg {
  width: 20px;
  height: 20px;
}
.btn-icon:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Requirement chips ---------- */
/* Read-only summary of state.requirements, shown above the chat input. */

.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 0 var(--space-4) var(--space-3);
}

.chip {
  gap: var(--space-1);
}

.chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 2px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #4a4a4a;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.18s var(--ease);
}
.chip-remove:hover {
  background: rgba(0, 0, 0, 0.08);
}

/* ---------- Results ---------- */

.results-panel {
  padding: var(--space-5);
}

.results-panel h2 {
  font-size: 1.05rem;
  margin-bottom: var(--space-4);
}

.results-status {
  min-height: 1.5em;
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: var(--space-2);
}
.results-status.is-error {
  color: var(--danger);
}

.results-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.listing-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: var(--space-3);
  background: rgba(248, 248, 246, 0.97);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 20px;
  box-shadow: 0 10px 24px -16px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

@media (max-width: 639px) {
  .listing-card {
    border-radius: 17px;
  }
}

.listing-image {
  width: 96px;
  height: 96px;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.04);
  display: block;
}

.listing-image-placeholder {
  width: 96px;
  height: 96px;
  background: rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.listing-image-placeholder svg {
  width: 32px;
  height: 32px;
}

.listing-body {
  padding: var(--space-3) var(--space-3) var(--space-3) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.listing-title {
  font-weight: 500;
  letter-spacing: -0.03em;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.listing-address {
  font-size: 0.85rem;
  color: var(--muted);
}

.listing-facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.85rem;
  font-weight: 500;
}

.listing-reason {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}

.listing-link {
  align-self: flex-start;
  margin-top: var(--space-1);
  padding: var(--space-1) var(--space-3);
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background-color 0.18s var(--ease);
}
.listing-link:hover {
  background: #f1f1ef;
}
.listing-link svg {
  width: 14px;
  height: 14px;
}

/* ---------- Small badge pill ---------- */
/* Used by the footer note (index.html) and the property-type fact on
   listing cards (app.js: span.badge-pill). */

.badge-pill {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 999px;
  padding: var(--space-1) var(--space-3);
  font-size: 13.5px;
  color: #4a4a4a;
  margin: 0;
}

/* ---------- Footer ---------- */

.app-footer {
  display: flex;
  justify-content: center;
  padding: var(--space-5) var(--space-4) var(--space-7);
}

/* ---------- Small screens ---------- */

@media (max-width: 480px) {
  .listing-card {
    grid-template-columns: 72px 1fr;
  }
  .listing-image,
  .listing-image-placeholder {
    width: 72px;
    height: 72px;
  }
}

@media (max-width: 320px) {
  .app-header {
    gap: var(--space-2);
  }
  .brand {
    font-size: 18px;
  }
  .lang-toggle {
    padding: 9px 13px;
    font-size: 12.5px;
  }
}

/* ---------- Landscape phones ---------- */

@media (max-height: 560px) and (orientation: landscape) {
  .app-header {
    padding-top: 12px;
  }
  .app-main {
    padding-top: var(--space-2);
    padding-bottom: var(--space-2);
    gap: var(--space-3);
  }
  .results-panel {
    padding: var(--space-3);
  }
  .chat-messages {
    max-height: 40vh;
  }
  .app-footer {
    padding: var(--space-3) var(--space-4) var(--space-4);
  }
}
