:root {
  --paper: #f4efe4;
  --ink: #1b1d18;
  --muted: #5d6358;
  --card: #fffdf8;
  --line: #d7d0c2;
  --check: #1f6b3a;
  --check-soft: #e4f3e8;
  --accent: #c45c12;
  --accent-ink: #fff7ee;
  --steel: #2f3b36;
  --pin: #c45c12;
  --shadow: 0 10px 28px rgba(40, 32, 18, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  background: var(--paper);
  color: var(--ink);
  padding: 20px 16px calc(140px + env(safe-area-inset-bottom));
}

.top {
  max-width: 1100px;
  margin: 0 auto 18px;
  display: grid;
  grid-template-columns: 1.5fr .8fr;
  gap: 20px;
  align-items: end;
}
.kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 700;
  font-family: ui-sans-serif, system-ui, sans-serif;
  color: var(--accent);
}
h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 5vw, 46px);
  line-height: 1.05;
  letter-spacing: -0.03em;
}
.lede {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.45;
  max-width: 640px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.stats div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
}
.stats b { display: block; font-size: 26px; }
.stats span {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.controls, .list-head, .map-wrap, .cards, footer {
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
}
.controls {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, .8fr) auto;
  gap: 8px;
  margin-bottom: 16px;
}
.controls input, .controls select, .controls button, .ghost, .dock button, .sheet button, .drive button, .drive a {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: 16px/1.2 ui-sans-serif, system-ui, sans-serif;
  background: var(--card);
  color: var(--ink);
}
.controls button, #nearBtn { font-weight: 700; cursor: pointer; }

.map-wrap {
  background: #e7e1d3;
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
#map {
  width: 100%;
  height: 420px;
  background: #efe8d8;
}
.map-note {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  color: var(--muted);
  background: var(--card);
  border-top: 1px solid var(--line);
}
.map-note a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}
.popup-title { font-weight: 800; font-size: 15px; margin-bottom: 4px; }
.popup-rent { font-weight: 800; color: var(--check); }
.popup-special { margin: 6px 0; color: #215534; }
.popup-actions { display: flex; gap: 8px; margin-top: 8px; }
.popup-actions button, .popup-actions a {
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  font: 700 13px ui-sans-serif, system-ui, sans-serif;
  background: var(--accent);
  color: white;
  text-decoration: none;
  cursor: pointer;
}

.list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 8px auto 12px;
}
.list-head h2 { margin: 0; font-size: 22px; }
.list-actions { display: flex; gap: 8px; }
.ghost { cursor: pointer; background: transparent; }

.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.card {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.card.selected {
  border-color: var(--check);
  background: var(--check-soft);
}
.card.visited { opacity: 0.62; }
.card h3 { margin: 0 0 4px; font-size: 22px; }
.addr, .meta, .special { font-family: ui-sans-serif, system-ui, sans-serif; }
.addr { color: var(--muted); font-size: 14px; }
.rent { margin: 8px 0 4px; font-size: 22px; font-weight: 700; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  background: #fff;
}
.special { margin: 0; color: #215534; font-size: 14px; line-height: 1.35; }
.check {
  width: 40px;
  height: 40px;
  border: 2px solid #9aa194;
  border-radius: 12px;
  background: white;
  cursor: pointer;
}
.check::after {
  content: "";
}
.check[aria-pressed="true"] {
  background: var(--check);
  border-color: var(--check);
  color: white;
}
.check[aria-pressed="true"]::after { content: "✓"; font-size: 22px; }

.dock[hidden],
.drive[hidden] {
  display: none !important;
}

.dock {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--steel);
  color: #f6f1e8;
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(20, 16, 10, 0.28);
}
.dock-copy b { display: block; font-size: 18px; }
.dock-copy span { font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; color: #d4d0c6; }
.dock-buttons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.dock button { min-height: 44px; cursor: pointer; }
.primary, .drive a.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  text-decoration: none;
  text-align: center;
}

.sheet {
  width: min(560px, 92vw);
  border: 0;
  border-radius: 20px;
  padding: 20px;
  background: var(--card);
}
.sheet::backdrop { background: rgba(20, 16, 10, 0.45); }
.sheet h2 { margin-top: 0; }
.sheet ol { padding-left: 20px; line-height: 1.45; }
.sheet textarea {
  width: 100%;
  min-height: 140px;
  margin: 8px 0 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: 14px/1.4 ui-sans-serif, system-ui, sans-serif;
}
.hint { color: var(--muted); font-size: 14px; }
.sheet menu { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; }

.drive {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--paper);
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.drive-top { display: flex; justify-content: space-between; align-items: center; }
.drive-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.drive-kicker { text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); font-family: ui-sans-serif, system-ui, sans-serif; font-weight: 700; }
.drive-card h2 { font-size: clamp(32px, 7vw, 54px); margin: 0 0 10px; }
.drive-card p { font-size: 20px; }
.drive-actions, .drive-nav { display: grid; gap: 8px; }
.drive-actions { grid-template-columns: 1fr 1fr; }
.drive-nav { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
.drive a, .drive button { display: flex; align-items: center; justify-content: center; min-height: 56px; font-weight: 800; }

footer {
  margin-top: 24px;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
}

body.locked {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.lock-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.lock-card h1 { font-size: 34px; }
.lock-card input {
  width: 100%;
  min-height: 52px;
  margin: 16px 0 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font: 18px ui-sans-serif, system-ui, sans-serif;
}
.lock-card button { width: 100%; cursor: pointer; }
.lock-error { color: #9b2c2c; font-family: ui-sans-serif, system-ui, sans-serif; font-weight: 700; }

@media (max-width: 860px) {
  .top, .controls, .cards { grid-template-columns: 1fr; }
  .dock { flex-direction: column; align-items: stretch; }
  .dock-buttons { justify-content: stretch; }
  .dock-buttons button { flex: 1; }
  #map { height: 320px; }
  .list-head { flex-direction: column; align-items: flex-start; }
}
