:root {
  --bg: #f7f6f3;
  --card: #ffffff;
  --ink: #1e2430;
  --muted: #6b7280;
  --line: #e4e2dc;
  --accent: #2f6f4f;
  --accent-ink: #ffffff;
  --warn: #b45309;
  --danger: #b91c1c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --card: #1d2129;
    --ink: #e8e6e1;
    --muted: #9aa1ad;
    --line: #2c313b;
    --accent: #4d9b74;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}
main { max-width: 980px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topnav {
  display: flex; align-items: center; gap: 1.25rem;
  padding: 0.7rem 1.25rem;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topnav a { color: var(--ink); font-weight: 500; }
.topnav a.on { color: var(--accent); }
.topnav .brand { font-weight: 700; margin-right: 0.5rem; }
.btn-add {
  margin-left: auto;
  background: var(--accent); color: var(--accent-ink) !important;
  padding: 0.35rem 0.8rem; border-radius: 8px; font-size: 0.9rem;
}
.btn-add:hover { text-decoration: none; opacity: 0.9; }

h1 { font-size: 1.5rem; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 1rem 1.25rem; margin-bottom: 1rem;
}
.prop-card { display: block; color: var(--ink); }
.prop-card:hover { text-decoration: none; border-color: var(--accent); }
.prop-head { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.prop-head .addr { font-weight: 600; font-size: 1.05rem; }
.prop-meta { color: var(--muted); font-size: 0.9rem; margin-top: 0.25rem; }

.badge {
  display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.03em; border: 1px solid var(--line); color: var(--muted);
}
.badge.watching  { background: #e0e7ff33; }
.badge.touring   { color: var(--accent); border-color: var(--accent); }
.badge.offer     { color: var(--warn); border-color: var(--warn); }
.badge.in_escrow { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.badge.passed, .badge.closed { opacity: 0.6; }

.progress { height: 6px; background: var(--line); border-radius: 3px; margin-top: 0.6rem; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); }

form.stack label { display: block; margin: 0.6rem 0 0.15rem; font-size: 0.85rem; color: var(--muted); }
input[type=text], input[type=date], select, textarea {
  width: 100%; padding: 0.45rem 0.6rem; border: 1px solid var(--line);
  border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit;
}
textarea { min-height: 4.5rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
button, .btn {
  margin-top: 0.9rem; padding: 0.45rem 1rem; border: none; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font: inherit;
  font-weight: 600; cursor: pointer;
}
button.ghost, .btn.ghost {
  background: transparent; color: var(--accent); border: 1px solid var(--accent);
}
button.tiny { margin: 0; padding: 0.1rem 0.5rem; font-size: 0.8rem; }

.prop-wrap { position: relative; }
.star-btn {
  background: none; border: none; cursor: pointer; margin: 0; padding: 0 0.15rem;
  font-size: 1rem; color: var(--muted); line-height: 1; vertical-align: middle;
}
.star-btn.on { color: #d97706; }
.prop-wrap .star-btn { position: absolute; top: 0.6rem; right: 0.35rem; z-index: 2; }

details.section { margin: 1.5rem 0 0; }
details.section > summary {
  cursor: pointer; font-size: 1.4rem; font-weight: 600; margin-bottom: 0.5rem;
  list-style: none; display: flex; align-items: baseline; gap: 0.6rem;
}
details.section > summary::before { content: "▸"; font-size: 1.2rem; color: var(--muted); }
details.section[open] > summary::before { content: "▾"; }
details.section > summary::-webkit-details-marker { display: none; }

.map { width: 100%; border-radius: 12px; border: 1px solid var(--line); z-index: 0; }
.map-overview { height: 380px; margin-bottom: 1.25rem; }
.map-detail { height: 260px; margin: 0.75rem 0; }
@media (prefers-color-scheme: dark) {
  .map { filter: brightness(0.85) saturate(0.85); }
}

.chat-msg { margin: 0.9rem 0; }
.chat-msg .who { font-size: 0.85rem; margin-bottom: 0.15rem; }
.chat-msg .body { border-left: 3px solid var(--line); padding: 0.1rem 0 0.1rem 0.9rem; }
.chat-msg.assistant .body { border-left-color: var(--accent); }
.chat-msg .body p { margin: 0.4rem 0; }
.chat-msg .body table { border-collapse: collapse; margin: 0.5rem 0; display: block; overflow-x: auto; }
.chat-msg .body th, .chat-msg .body td { border: 1px solid var(--line); padding: 0.25rem 0.5rem; font-size: 0.9rem; }

.htmx-indicator { opacity: 0; transition: opacity 200ms; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

.ms-list { list-style: none; padding: 0; margin: 0; }
.ms-list li {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.4rem 0; border-bottom: 1px solid var(--line);
}
.ms-list li:last-child { border-bottom: none; }
.ms-list .done { text-decoration: line-through; color: var(--muted); }
.ms-stage { font-size: 0.7rem; text-transform: uppercase; color: var(--muted); min-width: 4.5rem; }
.ms-due { margin-left: auto; font-size: 0.8rem; color: var(--warn); white-space: nowrap; }
.ms-check { cursor: pointer; font-size: 1.05rem; background: none; border: none; margin: 0; padding: 0; }
.ms-del { background: none; border: none; color: var(--muted); cursor: pointer; margin: 0; padding: 0 0.25rem; }
.ms-del:hover { color: var(--danger); }

table.facts { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.facts td { padding: 0.3rem 0.5rem 0.3rem 0; vertical-align: top; border-bottom: 1px solid var(--line); }
table.facts td.k { color: var(--muted); white-space: nowrap; width: 32%; }
table.facts td.src { font-size: 0.78rem; width: 10%; text-align: right; }

.note { border-left: 3px solid var(--line); padding: 0.2rem 0 0.2rem 0.8rem; margin: 0.6rem 0; }
.note .when { font-size: 0.78rem; color: var(--muted); }

table.cost-summary { width: 100%; border-collapse: collapse; font-size: 0.92rem; margin-bottom: 0.8rem; }
table.cost-summary td { padding: 0.25rem 0.5rem 0.25rem 0; vertical-align: top; }
table.cost-summary td.k { color: var(--muted); white-space: nowrap; width: 45%; }
table.cost-summary tr.sep td { padding-top: 0.6rem; }
table.cost-summary tr.total td { font-weight: 700; border-top: 2px solid var(--line); padding-top: 0.4rem; }

details.cost-inputs { margin-top: 0.6rem; }
details.cost-inputs > summary { cursor: pointer; list-style: none; }
details.cost-inputs > summary::-webkit-details-marker { display: none; }

.compare-select { margin-bottom: 1.25rem; }
.compare-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.6rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.25rem 0.6rem; border: 1px solid var(--line); border-radius: 999px;
  font-size: 0.85rem; cursor: pointer; user-select: none;
}
.chip:has(input:checked) { border-color: var(--accent); color: var(--accent); }
.chip input { margin: 0; }

.compare-scroll { overflow-x: auto; }
table.compare-table { border-collapse: collapse; width: 100%; min-width: 500px; font-size: 0.92rem; }
table.compare-table th, table.compare-table td {
  padding: 0.35rem 0.7rem; border-bottom: 1px solid var(--line);
  text-align: left; vertical-align: top;
}
table.compare-table th { font-weight: 600; white-space: nowrap; background: var(--card); position: sticky; top: 0; }
table.compare-table td.k { color: var(--muted); white-space: nowrap; min-width: 130px; }
table.compare-table tr.section-row td {
  font-weight: 700; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em;
  padding-top: 0.8rem; color: var(--muted); border-bottom: 2px solid var(--line);
}
table.compare-table tr.total-row td { font-weight: 700; }

.guide-body { max-width: 760px; }
.guide-body h1 { font-size: 1.6rem; }
.guide-body h2 { margin-top: 2rem; border-bottom: 1px solid var(--line); padding-bottom: 0.25rem; }
.guide-body table { border-collapse: collapse; width: 100%; margin: 1rem 0; display: block; overflow-x: auto; }
.guide-body th, .guide-body td { border: 1px solid var(--line); padding: 0.4rem 0.6rem; text-align: left; }
.guide-body blockquote { border-left: 3px solid var(--accent); margin: 1rem 0; padding: 0.2rem 1rem; color: var(--muted); }
.guide-nav { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem; }
.guide-nav a { font-size: 0.85rem; padding: 0.25rem 0.7rem; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); }
.guide-nav a.on { border-color: var(--accent); color: var(--accent); }
