@font-face {
  font-family: 'Bricolage Grotesque';
  font-weight: 600 700;
  font-display: swap;
  src: url('fonts/bricolage-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Bricolage Grotesque';
  font-weight: 600 700;
  font-display: swap;
  src: url('fonts/bricolage-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'DM Sans';
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/dmsans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'DM Sans';
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/dmsans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #F6F4EF;
  --surface: #FFFFFF;
  --ink: #1B1D1F;
  --muted: #5A5D61;
  --line: #DAD5CA;
  --line-soft: #E2DDD0;
  --line-strong: #CFC9BB;
  --teal: #0F5C5A;
  --teal-soft: #DCEBE9;
  --amber: #F7D774;
  --amber-line: #C9A227;
  --placeholder: #E4DFD2;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'DM Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; color: inherit; touch-action: manipulation; }
a, .chip, .tab { touch-action: manipulation; }
/* Installed on a phone: no rubber-band scrolling of the whole app. */
html, body { overscroll-behavior: none; }
button:disabled { cursor: default; opacity: 0.4; }
input { font-family: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
h1, h2, p { margin: 0; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 700; }

/* Layout: a phone-width column that fills the viewport height. */
.app {
  position: relative;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--bg);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (min-width: 481px) {
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
.screen { height: 100%; display: flex; flex-direction: column; }

.topbar {
  height: 56px; flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px 0 20px;
  border-bottom: 1px solid var(--line);
}
.topbar-back { justify-content: flex-start; gap: 4px; padding: 0 20px 0 8px; }
.topbar-back .title { margin-left: 8px; }
.title { font-family: var(--display); font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }

.ghost-btn {
  height: 44px; padding: 0 14px;
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: 0; border-radius: 22px;
  font-size: 15px; font-weight: 600;
}
.topbar-back .ghost-btn { padding: 0 12px; gap: 4px; }
.topbar-actions { display: flex; align-items: center; }
@media (max-width: 379px) {
  .topbar-actions .ghost-btn { padding: 0 11px; }
  .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* Chips and tabs share the same on/off look. */
.tabs { height: 48px; flex: none; display: flex; align-items: center; gap: 8px; padding: 2px 16px 0; }
.tab, .chip {
  height: 44px; border-radius: 22px; font-size: 14.5px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line-strong);
}
.tab { flex: 1; }
.tab[aria-pressed="true"] { background: var(--ink); color: #FFFFFF; border-color: var(--ink); }
.chip { flex: none; min-width: 48px; padding: 0 14px; font-size: 14px; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--teal); color: #FFFFFF; border-color: var(--teal); }

/* Two panes side by side; the track slides between them. */
.swiper {
  flex: 1; min-height: 0; overflow: hidden; position: relative;
  user-select: none; -webkit-user-select: none;
  touch-action: pan-y;
}
.track {
  display: flex; width: 200%; height: 100%;
  transform: translateX(-50%);
  transition: transform 0.28s ease;
}
.track.show-comps { transform: translateX(0); }
@media (prefers-reduced-motion: reduce) { .track { transition: none; } }
.pane {
  width: 50%; flex: none; height: 100%;
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  /* Panes scroll vertically only; horizontal drags are pane swipes. */
  touch-action: pan-y;
  display: flex; flex-direction: column;
}
#comps-pane { padding: 10px 16px 16px; gap: 8px; }
#info-pane { padding: 10px 20px 16px; gap: 12px; }

/* Comps pane */
.subject {
  flex: none; padding: 10px 14px;
  background: var(--teal-soft); border: 1px solid var(--teal); border-radius: 12px;
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.subject-addr { font-family: var(--display); font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subject-meta { font-size: 14px; font-weight: 600; }

#filters { display: flex; flex-direction: column; gap: 8px; }
.filter-row { display: flex; align-items: center; gap: 6px; }
.filter-label { flex: none; width: 44px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.chip-scroll { flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chip-scroll::-webkit-scrollbar { display: none; }

.comp-list { display: flex; flex-direction: column; gap: 6px; }
.comp {
  min-height: 54px; padding: 8px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: 10px;
}
.comp-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.comp-addr { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comp-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comp-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.comp-price { font-size: 15.5px; font-weight: 700; }
.comp-price.for-sale { color: var(--teal); }
.comp-when { font-size: 12px; color: var(--muted); }
.comp-footer { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px; font-size: 13px; color: var(--muted); }
.empty { padding: 20px 8px; text-align: center; font-size: 14px; color: var(--muted); }

.link-btn {
  min-height: 44px; padding: 0 8px; margin: -12px -8px;
  background: none; border: 0; color: var(--teal);
  font-size: 13.5px; font-weight: 700; text-decoration: underline; text-underline-offset: 2px;
}

/* Deal pane */
.headline { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.headline-main { min-width: 0; }
.ask { font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.05; }
.addr { margin-top: 4px; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#city { font-size: 13.5px; }
.headline-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.badge { padding: 4px 10px; border-radius: 12px; background: var(--teal); color: #FFFFFF; font-size: 12.5px; font-weight: 600; }

.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.fact { padding: 8px 12px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: 10px; }
.fact.span-2 { grid-column: span 2; }
.fact-label { font-size: 12px; color: var(--muted); }
.fact-value { font-size: 17px; font-weight: 700; }

.comp-card {
  padding: 12px; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.comp-label { font-size: 13.5px; font-weight: 600; }
.money-input {
  height: 52px; display: flex; align-items: center; gap: 4px; padding: 0 14px;
  background: var(--bg); border: 2px solid var(--teal); border-radius: 10px;
  font-size: 22px; font-weight: 700;
}
.money-input span { color: var(--muted); }
.money-input input {
  flex: 1; min-width: 0; height: 40px; border: 0; background: transparent;
  font-size: 22px; font-weight: 700; color: var(--ink);
  user-select: text; -webkit-user-select: text;
}
.money-input input:focus-visible { outline: none; }
.money-input:focus-within { box-shadow: 0 0 0 3px var(--teal-soft); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13.5px; }
.hint { text-align: center; font-size: 12.5px; color: var(--muted); }

/* Bottom bar */
.bottombar {
  height: 76px; flex: none;
  display: flex; align-items: center; gap: 8px; padding: 0 16px;
  border-top: 1px solid var(--line);
}
.pill-btn {
  flex: 1; height: 48px; border-radius: 24px;
  padding: 0 10px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 15px; font-weight: 700; white-space: nowrap;
}
.pill-btn svg { flex: none; }
.icon-btn {
  flex: none; width: 48px; height: 48px; border-radius: 24px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--line-strong);
}
.highlight-btn { flex: 1.15; background: var(--surface); border: 1px solid var(--line-strong); }
.highlight-btn[aria-pressed="true"] { background: var(--amber); border-color: var(--amber-line); }
.highlight-btn[aria-pressed="true"] svg { fill: currentColor; }
.primary-btn { background: var(--teal); border: 1px solid var(--teal); color: #FFFFFF; }

/* History */
.history-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 14px 16px 20px;
  display: flex; flex-direction: column; gap: 8px;
}
.history-body > p { padding: 0 4px 4px; font-size: 13px; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-row {
  width: 100%; min-height: 72px; padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-radius: 12px; text-align: left;
  background: var(--surface); border: 1px solid var(--line-soft);
}
.history-row.is-hl { background: var(--amber); border-color: var(--amber-line); }
.history-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.history-addr { display: flex; align-items: center; gap: 6px; font-size: 15.5px; font-weight: 700; min-width: 0; }
.history-addr span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }

/* Add / edit property */
.add-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 14px 16px 24px;
  display: flex; flex-direction: column; gap: 10px;
}
.lookup-form { display: flex; flex-direction: column; gap: 8px; }
.search-row { display: flex; gap: 8px; }
.text-input {
  flex: 1; min-width: 0; height: 48px; padding: 0 14px;
  background: var(--surface); border: 2px solid var(--teal); border-radius: 10px;
  font-size: 16px; color: var(--ink);
}
.text-input:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--teal-soft); }
.search-btn { flex: none; padding: 0 18px; }
.input-wrap { position: relative; flex: 1; min-width: 0; display: flex; }
.input-wrap .text-input { padding-right: 44px; }
.clear-btn {
  position: absolute; right: 2px; top: 2px; width: 44px; height: 44px;
  background: none; border: 0; border-radius: 22px; font-size: 22px; color: var(--muted);
}
.suggestions {
  list-style: none; margin: 0; padding: 4px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}
.suggestion {
  min-height: 52px; padding: 8px 10px; border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.suggestion[aria-selected="true"], .suggestion:hover { background: var(--teal-soft); }
.suggestion-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.suggestion-label { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggestion-detail { font-size: 13px; color: var(--muted); }
.suggestion-tag { flex: none; padding: 2px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 700;
  background: var(--teal); color: #FFFFFF; }
.suggestion-note { padding: 10px; font-size: 13.5px; color: var(--muted); }
.lookup-status { font-size: 13.5px; color: var(--muted); min-height: 1em; }
.lookup-status.is-error { color: #A12A1E; font-weight: 600; }
.subject-link { font-size: 13px; font-weight: 600; color: var(--teal); }
.confirm { display: flex; flex-direction: column; gap: 12px; }
.confirm .subject-addr { white-space: normal; }
.confirm-note { font-size: 13.5px; color: var(--muted); }
.redfin-facts {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: 10px;
}
.fields {
  margin: 0; padding: 0; border: 0;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
}
.fields legend { margin-bottom: 8px; padding: 0; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field.span-2 { grid-column: span 2; }
.field em { font-style: normal; font-weight: 400; }
.field input, .field select {
  height: 46px; padding: 0 12px; width: 100%;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px;
  font-family: inherit; font-size: 16px; font-weight: 700; color: var(--ink);
}
.field input:focus-visible, .field select:focus-visible { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.confirm-btn { flex: none; width: 100%; }
.delete-link { align-self: center; color: #A12A1E; margin: 0; }
.edit-link { align-self: flex-start; margin: -6px 0 -6px -8px; }
a.comp { color: inherit; text-decoration: none; }
.comp.in-est { border-color: var(--teal); box-shadow: inset 3px 0 0 var(--teal); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* InvestorLift notice */
.notice {
  position: absolute; z-index: 5; left: 12px; right: 12px;
  top: calc(64px + env(safe-area-inset-top, 0px));
  display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center;
  padding: 12px 8px 12px 14px; border-radius: 12px;
  background: var(--teal-soft); border: 1px solid var(--teal);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}
.notice-text { font-size: 14.5px; font-weight: 600; }
.notice-link { grid-column: 1; font-size: 14px; font-weight: 700; color: var(--teal); }
.notice-close {
  grid-column: 2; grid-row: 1 / span 2; width: 44px; height: 44px;
  background: none; border: 0; border-radius: 22px; font-size: 24px; color: var(--ink);
}

.toast {
  position: absolute; left: 16px; right: 16px;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  padding: 10px 14px; border-radius: 10px;
  background: var(--ink); color: #FFFFFF; font-size: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* Deal extras */
a.badge { text-decoration: none; }
.fact-small { font-size: 14px; line-height: 1.5; }
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }
.comp-list .loading { padding: 20px 8px; text-align: center; font-size: 14px; color: var(--muted); }

/* Numbered, starrable comps */
.comp { padding-left: 8px; padding-right: 4px; gap: 8px; }
.comp-num {
  flex: none; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--line-soft); color: var(--ink); font-size: 13px; font-weight: 700;
}
.comp-link { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  color: inherit; text-decoration: none; min-height: 44px; }
.comp.is-starred { background: #FBEFC4; border-color: var(--amber-line); }
.comp.is-starred .comp-num { background: var(--amber); }
.star-btn {
  flex: none; width: 44px; height: 44px; border-radius: 22px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 0; color: var(--muted);
}
.star-btn[aria-pressed="true"] { color: #B08A12; }
.star-btn[aria-pressed="true"] svg { fill: currentColor; }
.comp-note { font-size: 11.5px; color: #8A6A0A; font-weight: 600; }
.starred-hint { font-size: 12.5px; color: var(--muted); padding: 0 4px; }
.suggest-sub { display: block; font-size: 12px; }

.footer-links { display: flex; gap: 16px; }

/* Map popup */
.map-backdrop { position: absolute; inset: 0; z-index: 19; background: rgba(27, 29, 31, 0.45); }
.map-modal {
  position: absolute; z-index: 20;
  inset: calc(12px + env(safe-area-inset-top, 0px)) 10px calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg); border-radius: 16px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}
.map-top { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 6px 8px 16px; border-bottom: 1px solid var(--line); }
.map-title { min-width: 0; }
.map-title .title { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-close { flex: none; width: 44px; height: 44px; border-radius: 22px; background: none; border: 0; font-size: 26px; color: var(--ink); }
.map-canvas { flex: 1 1 58%; min-height: 200px; background: var(--placeholder); }
.map-legend {
  flex: none; display: flex; flex-wrap: wrap; gap: 4px 12px;
  padding: 8px 14px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line);
}
.map-legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dot.subject { background: var(--teal); border-radius: 3px; }
.dot.starred { background: var(--amber); box-shadow: 0 0 0 1px var(--amber-line); }
.dot.sold { background: var(--ink); }
.dot.active { background: #2F7FB8; }
.dot.pending { background: #B8742F; }
.map-list { flex: 1 1 42%; overflow-y: auto; margin: 0; padding: 8px 10px 12px; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.map-list li { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 8px; min-height: 52px;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: 10px; cursor: pointer; }
.map-list li.is-starred { background: #FBEFC4; border-color: var(--amber-line); }
.map-list li.is-starred .comp-num { background: var(--amber); }
.map-list .comp-main { flex: 1; }

/* Numbered pins */
.pin {
  width: 30px; height: 30px; border-radius: 50%; position: relative;
  display: flex; align-items: center; justify-content: center;
  font: 700 13px/1 'DM Sans', system-ui, sans-serif; color: #FFFFFF;
  border: 2px solid #FFFFFF; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.pin.sold { background: var(--ink); }
.pin.active { background: #2F7FB8; }
.pin.pending { background: #B8742F; }
.pin.starred { background: var(--amber); color: var(--ink); border-color: var(--amber-line); }
.pin-star { position: absolute; top: -9px; right: -9px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--ink); color: var(--amber); font-size: 12px; line-height: 18px; text-align: center; }
.pin.subject { width: 34px; height: 34px; border-radius: 8px; background: var(--teal); }
.leaflet-popup-content { font: 13.5px/1.4 'DM Sans', system-ui, sans-serif; margin: 10px 12px; }
.popup-title { font-weight: 700; font-size: 14.5px; }
