:root {
  --paper: #f4f0e6;
  --panel: #fbf8f2;
  --ink: #1c1915;
  --muted: #5f584e;
  --line: #ddd4c6;
  --cpau: #1d4e89;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #d5dde4;
  color: var(--ink);
  font: 15px/1.35 "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

body { height: 100dvh; }

#map {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #d5dde4;
}

header, #legend, #panel { position: absolute; z-index: 2; }

header {
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

header > * { pointer-events: auto; }

h1 {
  margin: 0;
  padding: 6px 8px;
  background: var(--paper);
  border: 1px solid var(--ink);
  font-family: Palatino, "Iowan Old Style", Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
}

.count, #list-btn, #legend, #panel {
  background: var(--paper);
  border: 1px solid var(--ink);
}

.count {
  margin: 0;
  padding: 6px 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

#list-btn {
  margin-left: auto;
  padding: 6px 12px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

#legend {
  top: 48px;
  left: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  max-width: calc(100% - 16px);
  padding: 5px 8px;
  font-size: 12px;
}

.swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 4px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  vertical-align: -1px;
}

#panel {
  display: none;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 48dvh;
  overflow: auto;
  padding: 10px 12px calc(16px + env(safe-area-inset-bottom));
  border-width: 1px 0 0;
}

body.sheet-open #panel { display: block; }

form label, fieldset {
  display: block;
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--muted);
}

input, select {
  display: block;
  width: 100%;
  margin-top: 3px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

fieldset {
  margin: 0;
  padding: 4px 8px 2px;
  border: 1px solid var(--line);
}

fieldset legend { padding: 0 3px; }

.check {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
  color: var(--ink);
  font-size: 14px;
}

.check input { width: auto; margin: 0; }

.item, .back, .popup-btn {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.item {
  display: block;
  width: 100%;
  padding: 8px 2px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.item strong { display: block; font-size: 14px; }
.item span { color: var(--muted); font-size: 12px; }

.back {
  margin-bottom: 6px;
  padding: 0;
  font-size: 13px;
  text-decoration: underline;
}

#detail h2 {
  margin: 0 0 2px;
  font-family: Palatino, Georgia, serif;
  font-size: 22px;
  line-height: 1.1;
}

.facts { margin: 0; }
.facts div { margin: 2px 0; }
.addr { color: var(--muted); font-size: 13px; }

.more { margin-top: 8px; font-size: 13px; }
.more summary { cursor: pointer; }
.more p, .more li { margin: 4px 0; }

.mix { display: flex; height: 8px; margin: 6px 0; background: var(--line); }
.mix span { display: block; height: 100%; }
.mix-list { list-style: none; margin: 0; padding: 0; }
.mix-list li { display: flex; justify-content: space-between; gap: 8px; }

a { color: var(--cpau); }
.unknown { color: var(--muted); }

.leaflet-control-zoom { margin-bottom: 18px !important; }
.leaflet-control-attribution { font-size: 10px !important; max-width: 55%; }
.leaflet-popup-content { margin: 8px 10px; font: 13px/1.3 "Segoe UI", Helvetica, sans-serif; }
.leaflet-popup-content strong { font-family: Palatino, Georgia, serif; font-size: 16px; }
.popup-btn {
  margin-top: 4px;
  padding: 0;
  font-size: 13px;
  text-decoration: underline;
}

@media (min-width: 800px) {
  .leaflet-bottom.leaflet-left { margin-left: 356px; }
  #legend { top: 8px; left: auto; right: 8px; }

  #panel {
    top: 52px;
    left: 8px;
    bottom: 8px;
    right: auto;
    width: 340px;
    max-height: none;
    border-width: 1px;
  }

  h1 { font-size: 20px; }
}
