:root {
  --bg: #f3efe7;
  --bg-deep: #e8e0d2;
  --surface: #fffcf7;
  --ink: #1f1b16;
  --muted: #6f675e;
  --line: #ddd4c6;
  --forest: #2c4a3e;
  --forest-2: #3d6b57;
  --over: #9a3412;
  --over-bg: #ffedd5;
  --under: #166534;
  --under-bg: #dcfce7;
  --pending: #9a6700;
  --pending-bg: #fef3c7;
  --contingent: #1d4ed8;
  --contingent-bg: #dbeafe;
  --sold: #5c4d3d;
  --sold-bg: #efe6d8;
  --shadow: 0 1px 2px rgba(31, 27, 22, 0.05), 0 16px 40px rgba(31, 27, 22, 0.06);
  --radius: 18px;
  --font: "Outfit", system-ui, sans-serif;
  --serif: "Fraunces", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #e4eee8 0%, transparent 55%),
    var(--bg);
  line-height: 1.45;
}

img {
  max-width: 100%;
  display: block;
}

img[hidden] {
  display: none !important;
}

a {
  color: var(--forest);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 6vw;
  background: var(--forest);
  color: #f6f3ee;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: inherit;
  text-decoration: none;
  font-family: var(--serif);
  font-weight: 650;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.brand img {
  width: 28px;
  height: 28px;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
}

.nav a {
  color: inherit;
  text-decoration: none;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-size: 0.92rem;
  opacity: 0.86;
}

.nav a[aria-current="page"],
.nav a:hover {
  background: rgba(255, 255, 255, 0.12);
  opacity: 1;
}

main {
  width: min(1120px, calc(100% - 1.5rem));
  margin: 1.5rem auto 4rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.toolbar {
  display: grid;
  gap: 0.7rem;
  margin-bottom: 1.1rem;
}

.toolbar label {
  display: grid;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

select {
  appearance: none;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath fill='%232c4a3e' d='M5 8l5 5 5-5'/%3E%3C/svg%3E") right 0.8rem center no-repeat;
  color: var(--ink);
  border-radius: 12px;
  padding: 0.85rem 2.4rem 0.85rem 0.95rem;
  font: 600 1.02rem var(--font);
}

select:focus,
input:focus,
button:focus-visible {
  outline: 3px solid #b7d3c6;
  outline-offset: 1px;
}

.banner {
  margin: 0;
  padding: 0.75rem 0.95rem;
  border-radius: 12px;
  font-size: 0.95rem;
}

.banner.sample {
  background: #eef4ef;
  color: var(--forest);
}

.banner.over {
  background: var(--over-bg);
  color: var(--over);
}

.banner.under,
.banner.at {
  background: var(--under-bg);
  color: var(--under);
}

.banner.error {
  background: #fee2e2;
  color: #991b1b;
}

.banner.ok {
  background: var(--under-bg);
  color: var(--under);
}

.hero {
  display: grid;
  gap: 0.7rem;
  margin-bottom: 1.15rem;
}

.kicker {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.22rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-deep);
  color: var(--muted);
}

.pill.sale {
  background: var(--under-bg);
  color: var(--under);
}

.pill.pending {
  background: var(--pending-bg);
  color: var(--pending);
}

.pill.contingent {
  background: var(--contingent-bg);
  color: var(--contingent);
}

.pill.sold {
  background: var(--sold-bg);
  color: var(--sold);
}

h1,
h2 {
  font-family: var(--serif);
  font-weight: 650;
  letter-spacing: -0.03em;
  margin: 0;
}

h1 {
  font-size: clamp(1.6rem, 4vw, 2.35rem);
  line-height: 1.15;
}

h2 {
  font-size: 1.2rem;
  margin-bottom: 0.85rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.15rem;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  min-height: 88px;
}

.metric .label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.metric .value {
  font-size: 1.12rem;
  font-weight: 600;
}

.metric.price.over {
  border-color: #fdba74;
  background: #fff7ed;
}

.metric.price.under,
.metric.price.at {
  border-color: #86efac;
  background: #f0fdf4;
}

.metric a {
  font-weight: 600;
  text-decoration: none;
}

.metric a:hover {
  text-decoration: underline;
}

.photo-card {
  position: relative;
  margin: 0 0 1.15rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.photo-card > img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #ece6db;
}

.photo-fallback {
  display: none;
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #ece6db;
}

.photo-fallback.visible {
  display: block;
}

.house-map {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  border: 0;
}

.house-map[hidden],
.map-placeholder[hidden] {
  display: none !important;
}

.map-placeholder {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.6rem;
  padding: 1.5rem 1.5rem 4.5rem;
  text-align: center;
  color: var(--muted);
}

.map-placeholder img {
  width: min(100%, 420px);
  background: transparent;
}

.map-placeholder p {
  margin: 0;
  font-weight: 500;
}

.zillow-cta {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 1100;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: min(90%, 280px);
  padding: 0.9rem 1.4rem;
  border-radius: 999px;
  background: #006aff;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(0, 80, 180, 0.35);
}

.zillow-cta:hover {
  background: #0057d2;
}

.zillow-cta:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

.osm-pin {
  background: #c2410c;
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 2px 8px rgba(31, 27, 22, 0.35);
}

.leaflet-container {
  width: 100%;
  height: 100%;
  font-family: var(--font);
  background: #dbe4dc;
}

.leaflet-control-attribution {
  font-size: 10px;
}

.chart-card {
  padding: 1.2rem 1.2rem 1.4rem;
}

.chart-wrap {
  position: relative;
  height: 360px;
}

.empty {
  text-align: center;
  padding: 3rem 1.25rem;
}

.empty h1 {
  margin-bottom: 0.6rem;
}

.form-stack {
  display: grid;
  gap: 0.9rem;
  max-width: 640px;
}

.lede {
  color: var(--muted);
  margin: 0.4rem 0 1.2rem;
  font-size: 1.05rem;
}

.lede code {
  white-space: nowrap;
}

label.field {
  display: grid;
  gap: 0.4rem;
  font-weight: 600;
}

input[type="text"] {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  font: 1rem var(--font);
  background: #fff;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

button {
  border: 0;
  border-radius: 999px;
  background: var(--forest);
  color: #f6f3ee;
  font: 600 1rem var(--font);
  padding: 0.85rem 1.3rem;
  cursor: pointer;
}

button:hover {
  background: var(--forest-2);
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

button.secondary,
.button-link {
  background: transparent;
  color: var(--forest);
  border: 1px solid var(--line);
}

.button-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  border-radius: 999px;
  padding: 0.85rem 1.3rem;
  font-weight: 600;
}

.button-link-solid {
  background: var(--forest);
  color: #f6f3ee;
  border-color: var(--forest);
}

.button-link-solid:hover {
  background: var(--forest-2);
  border-color: var(--forest-2);
  color: #f6f3ee;
}

.about {
  display: grid;
  gap: 1.15rem;
}

.about-hero {
  margin-bottom: 0;
}

.about-hero .lede {
  max-width: 42rem;
}

.about-hero .lede strong {
  color: var(--ink);
  font-weight: 600;
}

.about-grid {
  display: grid;
  gap: 1.15rem;
}

.about .panel h2 {
  margin-bottom: 0.65rem;
}

.about .panel p {
  margin: 0 0 0.85rem;
  color: var(--ink);
}

.about .panel p:last-child {
  margin-bottom: 0;
}

.about .panel p strong {
  font-weight: 600;
}

.arch-panel {
  overflow: hidden;
}

.arch-lede {
  margin-bottom: 1rem;
}

.arch-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: #f7f3eb;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem;
}

.arch-wrap .mermaid {
  margin: 0;
  display: flex;
  justify-content: center;
  min-width: 720px;
  color: transparent;
}

.arch-wrap .mermaid[data-processed] {
  color: inherit;
}

.arch-wrap .mermaid svg {
  max-width: none;
  height: auto;
}

.arch-flow {
  display: none;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0;
}

.arch-flow li {
  position: relative;
  background: #f7f3eb;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem;
}

.arch-flow li + li {
  margin-top: 0.85rem;
}

.arch-flow li + li::before {
  content: "";
  position: absolute;
  top: -0.85rem;
  left: 1.35rem;
  width: 2px;
  height: 0.85rem;
  background: var(--forest-2);
}

.arch-kicker {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.arch-flow strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.about .arch-flow p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.arch-plain {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.roadmap {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.85rem;
  counter-reset: roadmap;
}

.roadmap li {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.85rem;
  row-gap: 0.2rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbf8f2;
}

.roadmap li::before {
  counter-increment: roadmap;
  content: counter(roadmap);
  grid-row: 1 / span 2;
  align-self: start;
  width: 1.85rem;
  height: 1.85rem;
  margin-top: 0.1rem;
  border-radius: 999px;
  background: var(--forest);
  color: #f6f3ee;
  font-size: 0.85rem;
  font-weight: 600;
  display: grid;
  place-items: center;
}

.roadmap h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.roadmap p {
  margin: 0;
  color: var(--muted);
  grid-column: 2;
}

.about-cta .lede {
  margin-bottom: 1rem;
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.graveyard-intro,
.rankings-intro {
  margin-bottom: 1.1rem;
}

.graveyard-intro .lede,
.rankings-intro .lede {
  margin-bottom: 0.7rem;
}

.graveyard-count {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.graveyard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.85rem;
}

.grave-card {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 0.95rem 1.05rem;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
}

.grave-thumb {
  width: 88px;
  height: 88px;
  border-radius: 14px;
  object-fit: cover;
  background: #ece6db;
}

.grave-thumb-empty {
  background:
    linear-gradient(145deg, #efe6d8 0%, #ece6db 100%);
}

.grave-body {
  min-width: 0;
}

.grave-address {
  margin: 0 0 0.4rem;
  font-family: var(--font);
  font-size: 1.08rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.grave-address a {
  color: inherit;
  text-decoration: none;
}

.grave-address a:hover {
  color: var(--forest);
  text-decoration: underline;
}

.grave-meta {
  margin: 0 0 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.65rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.grave-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.grave-metric {
  background: #fbf8f2;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
}

.grave-metric .label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.grave-metric .value {
  font-size: 1.02rem;
  font-weight: 600;
}

.rankings-note {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.rank-card,
.rank-placeholder {
  display: grid;
  grid-template-columns: auto auto 72px minmax(0, 1fr);
  gap: 0.75rem 0.85rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem;
  user-select: none;
}

.rank-placeholder {
  border-style: dashed;
  background: #f3efe7;
  box-shadow: none;
}

.rank-handle {
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border-radius: 12px;
  background: #f3efe7;
  color: var(--forest);
  touch-action: none;
  cursor: grab;
}

.rank-handle svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: currentColor;
}

.rank-handle:hover,
.rank-handle:focus-visible {
  background: #e4eee8;
}

.rank-card.is-dragging {
  position: fixed;
  z-index: 20;
  margin: 0;
  pointer-events: none;
  box-shadow: 0 12px 32px rgba(31, 27, 22, 0.18);
  cursor: grabbing;
}

.rank-card.is-dragging .rank-handle {
  cursor: grabbing;
}

.rank-number {
  margin: 0;
}

.rank-input {
  width: 2.7rem;
  height: 2.7rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--forest);
  color: #f6f3ee;
  font: 650 1.15rem var(--serif);
  text-align: center;
  padding: 0;
  -moz-appearance: textfield;
  appearance: textfield;
  user-select: text;
}

.rank-input::-webkit-outer-spin-button,
.rank-input::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.rank-thumb {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  object-fit: cover;
  background: #ece6db;
  pointer-events: none;
}

.rank-thumb-empty {
  background:
    linear-gradient(145deg, #e4eee8 0%, #ece6db 100%);
}

.rank-body {
  min-width: 0;
}

.rank-address {
  margin: 0 0 0.35rem;
  font-weight: 600;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
}

.rank-meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.7rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
}

@media (min-width: 720px) {
  .metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .panel,
  .chart-card {
    padding: 1.5rem;
  }

  .about-grid.split {
    grid-template-columns: 1fr 1fr;
  }

  .grave-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .grave-card {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 0.7rem 0.75rem;
    padding: 0.85rem;
  }

  .grave-thumb {
    width: 64px;
    height: 64px;
  }

  .rank-card,
  .rank-placeholder {
    grid-template-columns: auto auto 56px minmax(0, 1fr);
    gap: 0.55rem 0.6rem;
    padding: 0.75rem;
  }

  .rank-thumb {
    width: 56px;
    height: 56px;
  }

  .rank-handle,
  .rank-input {
    width: 2.45rem;
    height: 2.45rem;
  }

  .site-header {
    padding: 0.8rem 1rem;
  }

  .chart-wrap {
    height: 260px;
  }

  .brand span {
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav a {
    padding: 0.4rem 0.65rem;
    font-size: 0.85rem;
  }

  .arch-wrap {
    display: none;
  }

  .arch-flow {
    display: grid;
  }
}
