/* GAFF — self-hosted, no external assets */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0efe9;
  --ink: #1b1d1a;
  --ink-2: #55584f;
  --ink-3: #8a8d84;
  --line: #e0dfd6;
  --accent: #2f6b4f;
  --accent-ink: #ffffff;
  --accent-soft: #e6efe9;
  --warn: #a8621b;
  --bad: #a3352c;
  --good: #2f6b4f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14150f;
    --surface: #1d1f19;
    --surface-2: #262820;
    --ink: #eceade;
    --ink-2: #b3b5a8;
    --ink-3: #7e8175;
    --line: #33362c;
    --accent: #6fae8a;
    --accent-ink: #10130e;
    --accent-soft: #223028;
    --warn: #d99b57;
    --bad: #d9736a;
    --good: #6fae8a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }

/*
 * The UA rule for the `hidden` attribute is `[hidden] { display: none }`, which
 * any class-based `display` beats on specificity. Every panel here sets its own
 * display (grid/flex), so without this they stay on screen after `.hidden = true`
 * — the unlocked app renders correctly but sits behind a gate overlay that never
 * goes away.
 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }

/* ------------------------------------------------------------------- gate */

.gate {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg); z-index: 100; padding: 24px;
}
.gate-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 32px; width: min(380px, 100%);
  box-shadow: var(--shadow); display: grid; gap: 10px;
}
.gate-card h1 {
  margin: 0; font-size: 28px; letter-spacing: .12em; font-weight: 700;
}
.gate-card > p { margin: 0 0 12px; color: var(--ink-3); font-size: 13px; }
.gate-card label { font-size: 12px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; }
.gate-card input {
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg);
}
.gate-card button {
  margin-top: 6px; padding: 11px; border: 0; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.gate-err { color: var(--bad); font-size: 13px; margin: 4px 0 0 !important; }

/* ----------------------------------------------------------------- topbar */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 14px 20px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.brand-mark { font-weight: 700; letter-spacing: .14em; font-size: 17px; }
.brand-sub { font-size: 11px; color: var(--ink-3); letter-spacing: .04em; }

.stats { display: flex; gap: 18px; flex-wrap: wrap; margin-left: auto; }
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 16px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); }

.topbar-actions { display: flex; gap: 8px; }

.btn {
  padding: 8px 14px; border: 1px solid transparent; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 13px;
}
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .5; cursor: default; filter: none; }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.sm { padding: 5px 10px; font-size: 12px; }

/* ---------------------------------------------------------------- filters */

.filters {
  position: sticky; top: 57px; z-index: 15;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 8px; }
.tab {
  padding: 5px 14px; border: 0; border-radius: 6px; background: transparent;
  color: var(--ink-2); font-size: 13px; font-weight: 600;
}
.tab.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.filter-group { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.filter-group label { font-size: 11px; color: var(--ink-3); display: flex; flex-direction: column; gap: 3px; }
.filter-group input[type=number] {
  width: 76px; padding: 5px 7px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--surface); font-size: 13px;
}
.filter-group .check { flex-direction: row; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-2); }

.filter-meta { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--ink-3); }

/* ------------------------------------------------------------------- list */

.list {
  display: grid; gap: 14px; padding: 20px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
  max-width: 1600px; margin: 0 auto;
}

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(0,0,0,.07), 0 14px 34px rgba(0,0,0,.10); }

.card-media { position: relative; aspect-ratio: 16/9; background: var(--surface-2); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-media .no-photo {
  width: 100%; height: 100%; display: grid; place-items: center;
  color: var(--ink-3); font-size: 12px;
}
.card-flags { position: absolute; top: 8px; left: 8px; display: flex; gap: 5px; flex-wrap: wrap; }
.card-score {
  position: absolute; top: 8px; right: 8px;
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
  font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 2px solid var(--good); color: var(--ink);
  backdrop-filter: blur(4px);
}
.card-score.mid { border-color: var(--warn); }
.card-score.low { border-color: var(--bad); }
.card-score.none { border-color: var(--line); color: var(--ink-3); font-size: 11px; }

.flag {
  font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 5px; background: var(--ink); color: var(--bg);
}
.flag.new { background: var(--accent); color: var(--accent-ink); }
.flag.fail { background: var(--bad); color: #fff; }
.flag.agreed { background: var(--warn); color: #fff; }
.flag.rated { background: var(--surface); color: var(--ink-2); border: 1px solid var(--line); }

.card-body { padding: 13px 15px 15px; display: grid; gap: 9px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card-addr { font-weight: 600; font-size: 14px; line-height: 1.35; }
.card-price { font-weight: 700; font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }

.card-facts { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.fact { display: flex; gap: 4px; align-items: baseline; }
.fact b { font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.fact.warn b { color: var(--warn); }
.fact.bad b { color: var(--bad); }

.card-summary {
  font-size: 13px; color: var(--ink-2); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.tag {
  font-size: 11px; padding: 2px 7px; border-radius: 20px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.card-foot {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--ink-3); padding-top: 3px;
  border-top: 1px solid var(--line); margin-top: 2px; padding-top: 9px;
}
.stars-mini { color: var(--warn); letter-spacing: .5px; }

/* ------------------------------------------------------------------ drawer */

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.42); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(680px, 100%); background: var(--surface);
  border-left: 1px solid var(--line); overflow-y: auto;
  box-shadow: -8px 0 40px rgba(0,0,0,.2);
}
.drawer-inner { padding: 22px 26px 60px; }

.d-close {
  position: sticky; top: 0; float: right;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  width: 30px; height: 30px; border-radius: 8px; font-size: 16px; line-height: 1;
}
.d-title { margin: 0 40px 4px 0; font-size: 20px; line-height: 1.3; }
.d-sub { color: var(--ink-3); font-size: 13px; margin: 0 0 18px; }

.d-section { margin: 22px 0 0; }
.d-section > h3 {
  margin: 0 0 10px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--ink-3); font-weight: 700;
}

.d-hero { display: flex; gap: 16px; align-items: center; margin-bottom: 4px; }
.d-scorebig {
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  border: 3px solid var(--good); flex: 0 0 auto;
}
.d-scorebig.mid { border-color: var(--warn); }
.d-scorebig.low { border-color: var(--bad); }
.d-scorebig.none { border-color: var(--line); }
.d-scorebig b { font-size: 24px; font-variant-numeric: tabular-nums; line-height: 1; }
.d-scorebig span { font-size: 9px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }

.dims { display: grid; gap: 7px; }
.dim { display: grid; grid-template-columns: 150px 1fr 62px; gap: 10px; align-items: center; font-size: 13px; }
.dim-name { color: var(--ink-2); }
.dim-bar { height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.dim-fill { height: 100%; background: var(--accent); border-radius: 4px; }
.dim-fill.geo { background: var(--ink-2); }
.dim-num { text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--ink-3); }
.dim-note { grid-column: 1 / -1; font-size: 12px; color: var(--ink-3); margin: -2px 0 6px 0; line-height: 1.4; }
.dim.unknown .dim-name, .dim.unknown .dim-num { color: var(--ink-3); font-style: italic; }

.gates { display: grid; gap: 6px; }
.gate-row { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.gate-pill {
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 5px;
  min-width: 46px; text-align: center; letter-spacing: .04em;
}
.gate-pill.pass { background: var(--accent-soft); color: var(--accent); }
.gate-pill.fail { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.gate-pill.unk { background: var(--surface-2); color: var(--ink-3); }
.gate-val { color: var(--ink-3); font-size: 12px; margin-left: auto; font-variant-numeric: tabular-nums; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 16px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

.prose { font-size: 13.5px; line-height: 1.6; color: var(--ink-2); white-space: pre-wrap; }
.concerns { margin: 0; padding-left: 20px; font-size: 13px; color: var(--ink-2); }
.concerns li { margin-bottom: 4px; }

.desc-box {
  max-height: 260px; overflow-y: auto; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px;
  font-size: 12.5px; line-height: 1.55; color: var(--ink-2); white-space: pre-wrap;
}

/* rating form */
.rate {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; display: grid; gap: 12px;
}
.rate-stars { display: flex; gap: 5px; }
.star {
  width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); font-size: 17px; line-height: 1; color: var(--ink-3);
}
.star.on { background: var(--warn); border-color: var(--warn); color: #fff; }
.rate-verdicts { display: flex; gap: 6px; flex-wrap: wrap; }
.vbtn {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); font-size: 12px; color: var(--ink-2);
}
.vbtn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.rate textarea {
  width: 100%; min-height: 90px; padding: 10px 12px; resize: vertical;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  font-size: 13.5px; line-height: 1.5;
}
.rate-hint { font-size: 11.5px; color: var(--ink-3); line-height: 1.45; margin: -4px 0 0; }
.rate-actions { display: flex; gap: 8px; align-items: center; }
.rate-prev {
  font-size: 12px; color: var(--ink-3); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
}

/* -------------------------------------------------------- empty and toast */

.empty { padding: 70px 20px; text-align: center; color: var(--ink-3); font-size: 14px; line-height: 1.6; }
.empty b { color: var(--ink); display: block; font-size: 16px; margin-bottom: 6px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 11px 18px;
  border-radius: 22px; font-size: 13px; z-index: 200; box-shadow: var(--shadow);
  max-width: min(560px, 92vw);
}
.toast.err { background: var(--bad); color: #fff; }

.spinner {
  display: inline-block; width: 11px; height: 11px; margin-right: 5px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  .topbar { gap: 12px; }
  .stats { order: 3; width: 100%; margin-left: 0; gap: 14px; }
  .filters { top: 96px; }
  .list { padding: 14px; gap: 12px; }
  .drawer-inner { padding: 18px 18px 60px; }
  .dim { grid-template-columns: 118px 1fr 54px; }
}

/* ------------------------------------------------------------ site imagery */

.sat-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
}
.sat-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  aspect-ratio: 1 / 1;
  max-height: 420px;
  margin: 0 auto;
}
.sat-tile { width: 100%; height: 100%; display: block; object-fit: cover; }

/* Crosshair marking the property itself. */
.sat-pin {
  position: absolute;
  width: 22px; height: 22px;
  margin: -11px 0 0 -11px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(0,0,0,.55), 0 0 10px rgba(0,0,0,.5);
  pointer-events: none;
}
.sat-pin::after {
  content: '';
  position: absolute; inset: 7px;
  background: var(--accent);
  border-radius: 50%;
}

.sat-bar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 8px;
}
.sat-scale { font-size: 11px; color: var(--ink-3); }
.sat-credit { font-size: 10px; color: var(--ink-3); margin-top: 5px; }

/* -------------------------------------------------------------- ask Claude */

.ask { display: grid; gap: 10px; }
.ask-hint { font-size: 12.5px; color: var(--ink-3); line-height: 1.5; margin: 0; }

.ask-log {
  display: grid; gap: 10px; max-height: 460px; overflow-y: auto;
  padding-right: 4px;
}
.ask-msg { border-radius: 10px; padding: 11px 13px; font-size: 13.5px; line-height: 1.55; }
.ask-msg.user {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  justify-self: end; max-width: 88%;
}
.ask-msg.assistant { background: var(--surface-2); border: 1px solid var(--line); }
.ask-msg.pending { color: var(--ink-3); font-style: italic; }

.ask-body { display: grid; gap: 7px; }
.ask-p  { margin: 0; }
.ask-li { margin: 0 0 0 14px; position: relative; }
.ask-li::before {
  content: '·'; position: absolute; left: -11px; color: var(--accent); font-weight: 700;
}
.ask-h  { margin: 6px 0 0; font-size: 13px; font-weight: 700; color: var(--ink); }
.ask-hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.ask-body code {
  font-family: var(--mono); font-size: 12px;
  background: var(--bg); padding: 1px 4px; border-radius: 4px;
}

.ask-sources { margin-top: 8px; font-size: 11.5px; }
.ask-sources summary { cursor: pointer; color: var(--ink-3); }
.ask-sources ul { margin: 6px 0 0; padding-left: 16px; display: grid; gap: 3px; }
.ask-sources a { color: var(--accent); text-decoration: none; }
.ask-sources a:hover { text-decoration: underline; }

.ask-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.ask-chip {
  font-size: 11.5px; padding: 5px 10px; border-radius: 20px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
}
.ask-chip:hover { background: var(--surface-2); color: var(--ink); border-color: var(--accent); }

.ask-row { display: flex; gap: 8px; align-items: flex-end; }
.ask-input {
  flex: 1; resize: vertical; min-height: 44px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); font-size: 13.5px; line-height: 1.5;
}
.ask-row .btn { align-self: stretch; padding-left: 18px; padding-right: 18px; }
