/* Roost — warm editorial "open house" aesthetic
   cream paper · ink type · clay + sage · Fraunces display */

:root {
  --paper:      #f3ebdd;
  --paper-2:    #ece1cd;
  --card:       #fbf7ef;
  --ink:        #2a2622;
  --ink-soft:   #6f665a;
  --ink-faint:  #a89c89;
  --line:       rgba(42, 38, 34, 0.12);
  --line-2:     rgba(42, 38, 34, 0.06);

  --clay:       #c2522f;
  --clay-deep:  #a13d22;
  --sage:       #5b7553;
  --sage-deep:  #44603d;
  --gold:       #cf9b3f;

  /* −2 … +2 rating ramp */
  --s-2: #b23a28;
  --s-1: #cb7a52;
  --s0:  #9c9080;
  --s1:  #7e9a6e;
  --s2:  #4e7a46;

  --shadow:    0 1px 2px rgba(42,38,34,.06), 0 8px 24px -12px rgba(42,38,34,.28);
  --shadow-lg: 0 30px 60px -24px rgba(42,38,34,.5);
  --radius:    14px;
  --display: 'Fraunces', Georgia, serif;
  --body: 'Hanken Grotesk', system-ui, sans-serif;
  --mono: 'Spline Sans Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
/* faint paper grain */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: .5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E");
}
#app, #modal-root, #toast-root { position: relative; z-index: 1; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--clay-deep); }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.label {
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600;
}

/* ---------- Identity gate ---------- */
.gate {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.gate-card { text-align: center; max-width: 560px; animation: rise .7s cubic-bezier(.2,.8,.2,1) both; }
.gate .mark { font-family: var(--display); font-size: clamp(56px, 12vw, 104px); font-weight: 600; line-height: .9; letter-spacing: -.02em; }
.gate .mark em { font-style: italic; color: var(--clay); }
.gate .tag { font-family: var(--display); font-style: italic; font-size: 19px; color: var(--ink-soft); margin: 14px 0 40px; }
.gate .who { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 18px; }
.gate-people { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.person {
  width: 168px; padding: 26px 18px 20px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); transition: transform .18s, box-shadow .18s, border-color .18s;
}
.person:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--clay); }
.person .ava { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--display); font-size: 30px; font-weight: 600; color: #fff; }
.person .nm { font-family: var(--display); font-size: 22px; font-weight: 600; }

/* ---------- App shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(243,235,221,.86);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.topbar-row { display: flex; align-items: center; gap: 16px; padding: 12px 20px; max-width: 1340px; margin: 0 auto; }
.brand { font-family: var(--display); font-weight: 600; font-size: 25px; letter-spacing: -.01em; line-height: 1; }
.brand em { font-style: italic; color: var(--clay); }
.brand small { display: block; font-family: var(--body); font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; margin-top: 2px; }
.build { font-size: 17px; letter-spacing: 2px; line-height: 1; user-select: all; cursor: default; align-self: center; }
.spacer { flex: 1; }

.search { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; min-width: 150px; }
.search input { border: none; background: none; outline: none; width: 100%; font-size: 14px; }
.search svg { opacity: .5; flex: none; }

.iconbtn { width: 38px; height: 38px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; transition: .15s; }
.iconbtn:hover { border-color: var(--clay); color: var(--clay); }
.iconbtn.spin svg { animation: spin 1s linear infinite; }

.userchip { display: flex; align-items: center; gap: 9px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px 5px 5px; }
.userchip .ava { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-family: var(--display); font-weight: 600; font-size: 15px; }
.userchip .nm { font-weight: 600; font-size: 14px; }
.userchip .sw { font-size: 11px; color: var(--ink-faint); }

/* tabs + controls row */
.controls { display: flex; align-items: center; gap: 10px; padding: 0 20px 12px; max-width: 1340px; margin: 0 auto; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 999px; font-weight: 600; font-size: 13.5px; color: var(--ink-soft); border: 1px solid transparent; transition: .15s; }
.tab:hover { background: var(--paper-2); }
.tab.active { background: var(--ink); color: var(--paper); }
.tab .ct { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 999px; background: rgba(42,38,34,.08); }
.tab.active .ct { background: rgba(255,255,255,.18); color: var(--paper); }
.tab.match.active { background: var(--sage-deep); }

.seg { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--card); }
.seg button { padding: 7px 12px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.seg button.active { background: var(--ink); color: var(--paper); }
.sortsel { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 12px; font-weight: 600; font-size: 13px; outline: none; }

/* ---------- Cards grid ---------- */
main { max-width: 1340px; margin: 0 auto; padding: 18px 20px 80px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
  animation: rise .5s cubic-bezier(.2,.8,.2,1) both; transition: transform .18s, box-shadow .18s, border-color .18s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card.match { border-color: var(--sage); box-shadow: 0 0 0 1px var(--sage), var(--shadow-lg); }
.card.rejected { opacity: .62; }

.card-top { position: relative; cursor: pointer; }
.thumb { aspect-ratio: 16/10; background-size: cover; background-position: center; }
/* photo-less editorial header */
.noimg { aspect-ratio: 16/10; display: flex; flex-direction: column; justify-content: flex-end; padding: 16px; position: relative; overflow: hidden; }
.noimg::after { content: ""; position: absolute; inset: 0; background:
  radial-gradient(120% 80% at 85% -10%, rgba(255,255,255,.5), transparent 60%); mix-blend-mode: overlay; }
.noimg .price { font-family: var(--display); font-size: 40px; font-weight: 600; line-height: .9; color: #fff; letter-spacing: -.02em; text-shadow: 0 1px 12px rgba(0,0,0,.18); position: relative; }
.noimg .price small { font-size: 17px; font-weight: 500; opacity: .82; }
.noimg .src-tag { position: relative; margin-top: 6px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; color: rgba(255,255,255,.9); }

.flags { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; z-index: 2; }
.flag { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 4px 8px; border-radius: 999px; background: var(--gold); color: #3a2a06; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.flag.match { background: var(--sage); color: #fff; }

.partner { position: absolute; top: 10px; right: 10px; display: flex; gap: 5px; z-index: 2; }
.pdot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; border: 2px solid var(--card); box-shadow: 0 1px 4px rgba(0,0,0,.2); }

.card-body { padding: 13px 15px 0; cursor: pointer; flex: 1; }
.card.has-photo .price-row { display: flex; align-items: baseline; gap: 8px; }
.card-body .price-row .price { font-family: var(--display); font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.card-body .ttl { font-size: 14px; line-height: 1.35; margin: 6px 0 0; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px 10px; margin: 10px 0 14px; font-size: 12.5px; color: var(--ink-soft); align-items: center; }
.meta-row .chip { background: var(--paper-2); padding: 3px 9px; border-radius: 999px; font-weight: 600; }
.meta-row .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-faint); }

/* rating dial */
.rate { display: flex; flex-direction: column; gap: 6px; padding: 0 15px 14px; }
.dial { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.stop {
  height: 38px; border-radius: 9px; display: grid; place-items: center; font-size: 15px; font-weight: 800;
  background: var(--paper-2); color: var(--ink-soft); border: 1px solid transparent; transition: .14s; line-height: 1;
}
.stop:hover { transform: translateY(-2px); }
.stop[data-v="-2"].on { background: var(--s-2); }
.stop[data-v="-1"].on { background: var(--s-1); }
.stop[data-v="0"].on  { background: var(--s0);  }
.stop[data-v="1"].on  { background: var(--s1);  }
.stop[data-v="2"].on  { background: var(--s2);  }
.stop.on { color: #fff; box-shadow: 0 4px 12px -4px rgba(0,0,0,.4); transform: translateY(-1px); }
.rate .partner-line { font-size: 12px; color: var(--ink-soft); display: flex; align-items: center; gap: 7px; min-height: 16px; }
.rate .partner-line b { font-weight: 700; }
.rate .partner-line .sw { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---------- Table ---------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); font-weight: 700; padding: 13px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
tr { cursor: pointer; }
tbody tr:hover { background: var(--paper); }
tr.match td:first-child { box-shadow: inset 3px 0 0 var(--sage); }
.t-price { font-family: var(--display); font-weight: 600; font-size: 17px; }
.scorepill { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; color: #fff; font-weight: 800; font-size: 12px; }
.scorepill.none { background: var(--paper-2); color: var(--ink-faint); }
.stagepill { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 3px 9px; border-radius: 999px; background: var(--paper-2); color: var(--ink-soft); }

/* ---------- Detail modal ---------- */
.scrim { position: fixed; inset: 0; background: rgba(28,24,20,.5); backdrop-filter: blur(3px); z-index: 50; display: flex; justify-content: center; align-items: flex-start; padding: 28px 16px; overflow-y: auto; animation: fade .2s; }
.sheet { width: min(720px, 100%); background: var(--paper); border-radius: 20px; box-shadow: var(--shadow-lg); overflow: hidden; animation: rise .35s cubic-bezier(.2,.8,.2,1) both; }
.sheet-hero { padding: 22px 26px; background: var(--card); border-bottom: 1px solid var(--line); position: relative; }
.sheet-hero .close { position: absolute; top: 16px; right: 16px; }
.sheet-hero .price { font-family: var(--display); font-size: 44px; font-weight: 600; line-height: .95; letter-spacing: -.02em; }
.sheet-hero .price small { font-size: 18px; font-weight: 500; color: var(--ink-soft); }
.sheet-hero h2 { font-family: var(--display); font-weight: 500; font-size: 21px; margin: 8px 0 0; line-height: 1.2; }
.sheet-hero .facts { display: flex; gap: 8px 14px; flex-wrap: wrap; margin-top: 12px; font-size: 13.5px; color: var(--ink-soft); }
.sheet-hero .facts .chip { background: var(--paper-2); padding: 4px 11px; border-radius: 999px; font-weight: 600; }
.gallery { display: flex; gap: 8px; overflow-x: auto; padding: 14px 26px 0; }
.gallery img { height: 150px; border-radius: 10px; object-fit: cover; }
.sheet-body { padding: 20px 26px 26px; display: flex; flex-direction: column; gap: 22px; }
.section h3 { font-family: var(--display); font-weight: 600; font-size: 15px; margin: 0 0 10px; }
.desc { font-size: 14.5px; line-height: 1.6; color: var(--ink-soft); white-space: pre-wrap; }

.src-list { display: flex; flex-direction: column; gap: 8px; }
.src-row { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 13px; font-size: 13.5px; }
.src-row .nm { font-weight: 700; text-transform: capitalize; }
.src-row .age { color: var(--ink-soft); }
.src-row a { margin-left: auto; font-weight: 700; text-decoration: none; }

.rate-big .dial .stop { height: 52px; font-size: 18px; }
.rate-big .stoplabels { display: grid; grid-template-columns: repeat(5,1fr); gap: 4px; margin-top: 5px; }
.rate-big .stoplabels span { text-align: center; font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; }

.note { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; margin-bottom: 8px; }
.note .by { font-size: 12px; color: var(--ink-faint); margin-bottom: 3px; }
.note .by b { color: var(--ink); }
.field { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; outline: none; }
.field:focus { border-color: var(--clay); }
textarea.field { resize: vertical; min-height: 64px; }
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.formgrid .full { grid-column: 1 / -1; }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px; border-radius: 999px; font-weight: 700; font-size: 14px; background: var(--ink); color: var(--paper); transition: .15s; }
.btn:hover { transform: translateY(-1px); }
.btn.clay { background: var(--clay); }
.btn.sage { background: var(--sage-deep); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; }

.dupe { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px dashed var(--gold); border-radius: 10px; padding: 10px 13px; font-size: 13.5px; }
.dupe .info { flex: 1; }

.appt-card { background: var(--sage); color: #fff; border-radius: 12px; padding: 14px 16px; }
.appt-card .when { font-family: var(--display); font-size: 20px; font-weight: 600; }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 90px 20px; color: var(--ink-soft); }
.empty .big { font-family: var(--display); font-style: italic; font-size: 26px; color: var(--ink); margin-bottom: 8px; }
.skeleton { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); height: 320px; animation: pulse 1.3s ease-in-out infinite; }

#toast-root { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: var(--paper); padding: 11px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg); animation: rise .3s both; }
.toast.warn { background: var(--clay-deep); }

.amrow { padding-top: 0 !important; }
.amrow .label { align-self: center; }
.amchip { padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); font-weight: 600; font-size: 12.5px; color: var(--ink-soft); transition: .15s; }
.amchip:hover { border-color: var(--sage); }
.amchip.on { background: var(--sage-deep); color: #fff; border-color: var(--sage-deep); }
.amenities { display: flex; flex-wrap: wrap; gap: 5px; margin: 2px 0 13px; }
.amenity { font-size: 11.5px; font-weight: 600; background: var(--paper-2); color: var(--ink-soft); padding: 3px 8px; border-radius: 7px; }
.amenity.hot { background: var(--gold); color: #3a2a06; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.postlink { display: inline-block; margin: 0 0 12px; font-size: 12.5px; font-weight: 700; color: var(--clay-deep); text-decoration: none; }
.postlink:hover { text-decoration: underline; }
.selfield { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.selfield select { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 11px 12px; outline: none; font-size: 14px; color: var(--ink); }
.selfield select:focus { border-color: var(--clay); }
.srcrow { display: flex; align-items: center; gap: 9px; padding: 9px 0; font-size: 14px; }
.srcrow input { width: 18px; height: 18px; accent-color: var(--sage-deep); }
.citygrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; max-height: 230px; overflow-y: auto; padding-right: 4px; }
.citychk { padding: 6px 0; font-size: 13.5px; }
.citychk .label { margin-left: auto; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: .6; } 50% { opacity: .9; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

@media (max-width: 640px) {
  .topbar-row { gap: 10px; padding: 10px 14px; }
  .brand { font-size: 21px; }
  .search { min-width: 0; flex: 1; }
  .controls { padding: 0 14px 10px; }
  main { padding: 14px 14px 90px; }
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .formgrid { grid-template-columns: 1fr; }
}
