:root {
  /* Surfaces + text — warm paper, deep green-ink */
  --bg: #faf6ee;
  --surface: #ffffff;
  --bg-raised: #f3ece0;
  --ink: #182a24;
  --muted: #6a7068;
  --line: #ebe3d4;
  /* Brand — deep evergreen (trust, home, calm) */
  --accent: #0e463b;
  --accent-ink: #0a352c;
  --brand-subtle: #e2efe8;
  /* Warm accent — "light through the window" (energy, highlights) */
  --warm: #cf7a2c;
  --warm-soft: #f7e9d5;
  --warm-ink: #8a4e14;
  /* Intent */
  --intent-danger-bg: #fbe9e7;
  --intent-danger-text: #9a3324;
  --warn-bg: #f7e9d5;
  --warn-ink: #8a4e14;
  /* Focus ring — high-contrast green, clears 3:1 on light */
  --focus-ring: #0e463b;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(48, 32, 12, 0.05), 0 12px 32px rgba(48, 32, 12, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

/* `hidden` must win over component display rules (e.g. .search-form flex). */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  background-image: radial-gradient(1100px 520px at 78% -80px, rgba(207, 122, 44, 0.14), transparent 62%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

main { max-width: 1120px; margin: 0 auto; padding: 0 20px 64px; }

/* Skip-to-content (keyboard/AT) */
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); color: var(--ink);
  padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 1600; font-weight: 600; }
.skip-link:focus { left: 16px; }

/* Visible focus on everything interactive (never removed) */
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
button, .mode, .deal-item, .doc-cycle {
  transition: background 120ms cubic-bezier(0.2, 0, 0, 1), color 120ms cubic-bezier(0.2, 0, 0, 1);
}

/* Tabular figures for prices, dates, counts, data */
.l-price, .headline, .ms-date, .db-next, .db-sub, .row .v, .conf, .l-summary,
.school-list, .deal-item .dist { font-variant-numeric: tabular-nums; }

/* Skeleton loading — matched to the final layout, not a spinner */
.skeleton { position: relative; overflow: hidden; background: var(--bg-raised); border-radius: var(--radius); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent); animation: shimmer 1.2s infinite; }
.sk-card { height: 92px; margin-bottom: 14px; }
.sk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.sk-tile { height: 226px; }
@keyframes shimmer { to { transform: translateX(100%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::after, *::before {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Header */
.site-header {
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 20px 8px;
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { color: var(--warm); font-size: 24px; line-height: 1; }
.lede strong { color: var(--warm-ink); font-weight: 600; }
.brand-name { font-family: var(--font-display); font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.brand-tag { color: var(--muted); margin: 0; font-size: 15px; }
.account { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.acct-email { font-size: 14px; color: var(--ink); font-weight: 600; }
.pillbtn { background: var(--accent); color: #fff; font-size: 14px; font-weight: 600; padding: 8px 18px; border-radius: 999px; }
.linkbtn { background: transparent; color: var(--accent); font-size: 14px; font-weight: 600; padding: 4px 6px; }
.linkbtn:hover { background: transparent; text-decoration: underline; }
.chip.demo { background: var(--warn-bg); color: var(--warn-ink); font-weight: 600; }
.deal-list { display: flex; flex-direction: column; gap: 6px; }
.deal-item { display: flex; justify-content: space-between; gap: 12px; background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: 14px; text-align: left; }
.deal-item:hover { background: var(--bg-raised); }
.deal-item .dist { color: var(--muted); }

/* Hero */
.hero { display: grid; grid-template-columns: 1.08fr 0.92fr; gap: 44px; align-items: center; padding: 44px 0 8px; }
.hero-copy { max-width: 640px; }
.hero-art { display: flex; justify-content: center; }
.window-illustration { width: 100%; max-width: 380px; height: auto; filter: drop-shadow(0 22px 44px rgba(48, 32, 12, 0.16)); }
@media (max-width: 920px) { .hero { grid-template-columns: 1fr; } .hero-art { display: none; } }
.hero-copy h1 {
  font-family: var(--font-display);
  font-size: clamp(34px, 5vw, 56px);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.04;
  margin: 0 0 14px;
}
.lede { color: var(--muted); font-size: 17px; margin: 0 0 22px; }
.search-form { display: flex; gap: 10px; flex-wrap: wrap; }
.search-form input {
  flex: 1 1 340px;
  padding: 14px 16px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
.search-form input:focus,
.chat-form input:focus,
#persona:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 14px 22px;
  border-radius: var(--radius);
  cursor: pointer;
}
button:hover { background: var(--accent-ink); }
button:disabled { opacity: 0.55; cursor: progress; }
.fairhousing-note { color: var(--muted); font-size: 13px; margin: 14px 0 0; }

/* Mode toggle */
.mode-toggle { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--bg-raised); padding: 4px; border-radius: 12px; margin-bottom: 16px; max-width: 100%; }
.mode {
  background: transparent; color: var(--muted); font-size: 14px; font-weight: 600;
  padding: 8px 16px; border-radius: 9px;
}
.mode:hover { background: transparent; color: var(--ink); }
.mode.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.listings-form input[type="number"] { flex: 0 1 130px; }

/* Listings */
.listings-section { margin-top: 28px; }
.listings-head { display: flex; align-items: center; gap: 12px; }
.listings-head h2 { font-family: var(--font-display); font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.tier-badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.tier-badge.live { background: var(--brand-subtle); color: var(--accent-ink); }
.tier-badge.demo { background: var(--warn-bg); color: var(--warn-ink); }
.listings-note { color: var(--muted); font-size: 13px; margin: 6px 0 16px; }
.conf { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; text-transform: capitalize; }
.conf-high { background: var(--brand-subtle); color: var(--accent-ink); }
.conf-medium { background: var(--warn-bg); color: var(--warn-ink); }
.conf-low { background: var(--intent-danger-bg); color: var(--intent-danger-text); }

/* Deal / transaction pipeline */
.deal-banner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 16px 20px; border-radius: var(--radius); margin-bottom: 16px; box-shadow: var(--shadow); }
.deal-banner.ok { background: var(--brand-subtle); }
.deal-banner.risk { background: var(--intent-danger-bg); }
.db-title { font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.db-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.db-next { font-size: 14px; text-align: right; }
.ms-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ms { padding: 12px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
.ms:first-child { border-top: 0; }
.ms-check { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.ms-check input { width: 17px; height: 17px; accent-color: var(--accent); }
.ms-label { font-size: 15px; font-weight: 600; }
.ms-complete .ms-label { color: var(--muted); text-decoration: line-through; }
.crit { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--intent-danger-text); background: var(--intent-danger-bg); padding: 1px 6px; border-radius: 999px; vertical-align: middle; }
.ms-meta { display: flex; align-items: center; gap: 8px; }
.ms-date { font-size: 13px; color: var(--muted); }
.ms-status { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 8px; border-radius: 999px; }
.s-upcoming { background: var(--bg-raised); color: var(--muted); }
.s-due-soon { background: var(--warn-bg); color: var(--warn-ink); }
.s-overdue { background: var(--intent-danger-bg); color: var(--intent-danger-text); }
.s-complete { background: var(--brand-subtle); color: var(--accent-ink); }
.ms-desc { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
.doc-cycle { background: var(--bg); color: var(--ink); border: 1px solid var(--line); font-size: 12px; font-weight: 600;
  padding: 3px 12px; border-radius: 999px; text-transform: capitalize; cursor: pointer; }
.doc-cycle:hover { background: var(--bg-raised); }
.listings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.listing {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.l-photo { height: 150px; background-size: cover; background-position: center; background-color: var(--bg-raised); }
.l-photo-empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
.l-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 3px; }
.l-price { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.l-summary { font-size: 14px; color: var(--ink); }
.l-addr { font-size: 13px; color: var(--muted); }
.l-status { align-self: flex-start; margin-top: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent-ink); background: var(--brand-subtle); padding: 2px 8px; border-radius: 999px; }

/* Workspace */
.workspace {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
  margin-top: 32px;
  align-items: start;
}
@media (max-width: 860px) { .workspace { grid-template-columns: 1fr; } }

/* Dossier */
.dossier { display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 10px; }
.card .headline { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.card .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.rows { display: grid; gap: 8px; margin-top: 4px; }
.row { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; }
.row .k { color: var(--muted); }
.row .v { font-weight: 600; text-align: right; }
.chip {
  display: inline-block;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  margin-top: 10px;
}
.chip.risk { background: var(--intent-danger-bg); color: var(--intent-danger-text); }
.chip.calm { background: var(--brand-subtle); color: var(--accent-ink); }
.disclaimer { font-size: 13px; color: var(--muted); margin-top: 10px; }
.school-list { margin: 6px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.school-list li { display: flex; justify-content: space-between; font-size: 14px; }
.school-list .dist { color: var(--muted); }
details.sources { font-size: 13px; }
details.sources summary { cursor: pointer; color: var(--muted); }
details.sources .src { display: flex; justify-content: space-between; padding: 5px 0; border-top: 1px solid var(--line); }
.src .ok { color: var(--accent); }
.src .missing { color: var(--muted); }

/* Chat */
.col-chat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 420px;
  max-height: 640px;
  overflow: hidden;
}
.chat-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.chat-head label { font-size: 13px; color: var(--muted); }
#persona { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; background: var(--bg); }
.persona-blurb { margin: 0; padding: 8px 16px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); }
.thread { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 12px; font-size: 15px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.agent { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.system { align-self: center; background: transparent; color: var(--muted); font-size: 13px; text-align: center; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; }
.chat-form button { padding: 11px 18px; }

.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 24px; }

/* Footer */
.site-footer { max-width: 1120px; margin: 0 auto; padding: 22px 20px 40px; border-top: 1px solid var(--line); }
.site-footer p { color: var(--muted); font-size: 13px; margin: 0; }
