:root {
  --bg: #e4ddd0;
  --header: #162420;
  --header-text: #f4f0e7;
  --paper: #f6f2ea;
  --card: #fffdf9;
  --ink: #1c1915;
  --muted: #5e574c;
  --line: #d5cbbd;
  --confirmed: #0c6b5c;
  --confirmed-bg: #e4f2ee;
  --claim: #8f4b08;
  --claim-bg: #f8efe4;
  --listing: #4d5863;
  --listing-bg: #eceff1;
  --tesla: #8a3126;
  --tesla-bg: #f8ebe7;
  --focus: #0c6b5c;
  --shadow: 0 10px 28px rgba(40, 32, 20, 0.12);
  --serif: "Source Serif 4", "Iowan Old Style", Palatino, Georgia, serif;
  --sans: "Source Sans 3", "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
}

button, input, select { font: inherit; color: inherit; }

.mast {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px 12px;
  background: var(--header);
  color: var(--header-text);
}

.kicker {
  margin: 0 0 2px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c9d5cf;
}

.mast h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 560;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.tally {
  margin: 0;
  max-width: 340px;
  text-align: right;
  font-size: 14px;
  color: #e4ebe7;
}

.panes { display: none; }

.app {
  display: grid;
  grid-template-columns: 268px minmax(320px, 430px) minmax(280px, 1fr);
  min-height: 0;
}

.filters, .list {
  min-height: 0;
  overflow: auto;
  background: var(--paper);
}

.filters {
  padding: 14px 14px 24px;
  border-right: 1px solid var(--line);
}

.list {
  border-right: 1px solid var(--line);
}

.field, fieldset {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 14px;
  padding: 0;
  border: 0;
}

.field span, legend, .check-row {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

fieldset label, .check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 15px;
  font-weight: 400;
  color: var(--ink);
}

.check-row em { font-style: normal; color: var(--muted); }

input[type="search"], input[type="number"], select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #c9bfb0;
  border-radius: 6px;
  background: white;
}

input:focus-visible, select:focus-visible, button:focus-visible, .card:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.text-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--confirmed);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.list-status, .status, .empty {
  margin: 0;
  padding: 18px 16px;
  color: var(--muted);
}

.card {
  display: block;
  width: 100%;
  padding: 14px 16px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-left: 4px solid transparent;
  background: var(--card);
  text-align: left;
  cursor: pointer;
}

.card.is-selected {
  border-left-color: var(--header);
  background: #f3f7f5;
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.card h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.stalls {
  flex: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.addr {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.badge-confirmed { background: var(--confirmed-bg); color: var(--confirmed); }
.badge-claim { background: var(--claim-bg); color: var(--claim); }
.badge-listing { background: var(--listing-bg); color: var(--listing); }
.badge-meta { background: #efeae2; color: #3f3a33; }
.badge-short { background: var(--tesla-bg); color: var(--tesla); }

.meta-line {
  margin: 0 0 8px;
  font-size: 14px;
}

.access, .tesla, .sources {
  margin: 0 0 8px;
  font-size: 14px;
}

.tesla {
  padding: 8px 10px;
  background: #f4efe6;
  border-left: 3px solid #b08968;
}

.sources { margin-bottom: 0; }

.sources a {
  color: var(--confirmed);
  font-weight: 600;
}

.map-wrap {
  position: relative;
  min-height: 0;
  background: #d5d0c6;
}

#map { height: 100%; width: 100%; background: #d9e2dc; }

.legend {
  position: absolute;
  z-index: 500;
  left: 12px;
  bottom: 28px;
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  background: rgba(255, 253, 249, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 12px;
}

.legend p { display: flex; align-items: center; gap: 8px; margin: 0; }

.swatch { position: static; display: inline-block; }

.map-note {
  position: absolute;
  z-index: 500;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  max-width: min(420px, calc(100% - 24px));
  padding: 8px 12px;
  background: var(--header);
  color: var(--header-text);
  border-radius: 8px;
  font-size: 14px;
  box-shadow: var(--shadow);
}

.map-note:empty { display: none; }

.pin-icon { background: none; border: 0; }

.pin {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.35);
}

.pin-confirmed { background: var(--confirmed); }
.pin-claim { background: var(--claim); }
.pin-listing { background: var(--listing); }

.pin-tesla {
  border-radius: 2px;
  transform: rotate(45deg) scale(0.92);
  box-shadow: 0 0 0 1.5px var(--tesla), 0 1px 2px rgba(0, 0, 0, 0.35);
}

.pin-selected {
  outline: 2px solid #111;
  outline-offset: 2px;
}

.cluster-wrap { background: none; border: 0; }

.cluster {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--header);
  color: #f4f0e7;
  font-weight: 700;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.leaflet-popup-content-wrapper {
  border-radius: 10px;
  background: var(--card);
}

.leaflet-popup-content { margin: 10px 12px; width: 260px; }

.popup h3 {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.2;
}

.popup p { margin: 0 0 6px; font-size: 13px; }
.popup .tesla { font-size: 13px; }

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 16px;
  background: #efe8dc;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.foot p { margin: 0; color: #3d3830; }

dialog {
  width: min(640px, calc(100vw - 24px));
  padding: 0;
  border: 0;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(22, 28, 24, 0.46); }

dialog header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--header);
  color: var(--header-text);
}

dialog h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 560;
}

dialog header button {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #8aa399;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.about-body { padding: 4px 18px 18px; }
.about-body p { margin: 12px 0; }

.noscript {
  padding: 12px 16px;
  background: #fff4e5;
}

@media (max-width: 980px) {
  body { grid-template-rows: auto auto 1fr auto; }

  .mast { align-items: flex-start; flex-direction: column; gap: 6px; padding: 12px 14px; }
  .mast h1 { font-size: 22px; }
  .tally { text-align: left; max-width: none; }

  .panes {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    background: #243833;
  }

  .panes button {
    padding: 10px 8px;
    border: 0;
    background: transparent;
    color: #d5e0db;
    font-weight: 700;
    cursor: pointer;
  }

  .panes button[aria-pressed="true"] {
    background: var(--paper);
    color: var(--ink);
  }

  .app { display: block; }

  .filters, .list, .map-wrap { display: none; height: 100%; }
  body[data-pane="filters"] .filters { display: block; }
  body[data-pane="list"] .list { display: block; }
  body[data-pane="map"] .map-wrap { display: block; }

  .foot { flex-direction: column; align-items: flex-start; gap: 4px; }
  .legend { bottom: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
