:root {
  --paper: #f3efe6;
  --paper-2: #fffdf8;
  --ink: #1c1915;
  --muted: #5c564c;
  --line: #ddd4c4;
  --accent: #1f4b45;
  --accent-soft: #e5f0ed;
  --banner: #f3e6d4;
  --banner-ink: #5c3b22;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

#shell {
  display: grid;
  grid-template-columns: 23rem minmax(0, 1fr);
  height: 100%;
  min-height: 100vh;
}

#panel {
  overflow: auto;
  padding: 1.1rem 1.15rem 1.5rem;
  border-right: 1px solid var(--line);
  background: var(--paper);
}

.kicker {
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--accent);
}

h1 {
  margin: 0.15rem 0 0.35rem;
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 1.85rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

h2 {
  margin: 1.15rem 0 0.45rem;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.lede { margin: 0; color: var(--ink); }

.banner {
  margin: 0.85rem 0 0;
  padding: 0.7rem 0.75rem;
  background: var(--banner);
  color: var(--banner-ink);
  border-radius: 6px;
  font-size: 0.92rem;
}

.group { margin: 0 0 0.85rem; }
.group h3 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
}
.group-note {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.layer {
  display: grid;
  grid-template-columns: 1.15rem 1fr;
  gap: 0.15rem 0.45rem;
  align-items: start;
  padding: 0.28rem 0;
}
.layer input { margin-top: 0.28rem; accent-color: var(--accent); }
.layer label { font-weight: 600; cursor: pointer; }
.layer .status {
  grid-column: 2;
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}
.layer .status.is-error { color: var(--banner-ink); }

#legend:empty::before,
#sources:empty::before {
  content: "Turn a layer on.";
  color: var(--muted);
  font-size: 0.88rem;
}

.legend-block, .source-card, .excluded-item, .gap-cell {
  border-top: 1px solid var(--line);
  padding: 0.55rem 0;
}
.legend-block h3, .source-card h3, .gap-cell h3 {
  margin: 0 0 0.25rem;
  font-size: 0.92rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
}
.swatch-row {
  display: grid;
  grid-template-columns: 1rem 1fr;
  gap: 0.15rem 0.45rem;
  align-items: start;
  margin: 0.2rem 0;
}
.swatch {
  width: 1rem;
  height: 0.85rem;
  margin-top: 0.15rem;
  border: 1px solid rgba(28, 25, 21, 0.35);
  border-radius: 2px;
}
.swatch-row p { margin: 0; }
.swatch-row .note, .fine {
  color: var(--muted);
  font-size: 0.8rem;
}

.source-card p { margin: 0.15rem 0; }
.source-card a { color: var(--accent); }
.limits { margin: 0.3rem 0 0; padding-left: 1.1rem; }
.limits li { margin: 0.15rem 0; }

#not-drawn { margin-top: 1rem; }
#not-drawn summary { cursor: pointer; font-weight: 600; }
.excluded-item h3 { font-size: 0.9rem; }
.excluded-item p { margin: 0.15rem 0; font-size: 0.86rem; }

#basemap-credit {
  margin-top: 1.1rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}
#basemap-credit a { color: var(--accent); }

#stage { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; }

#zoom-note {
  position: absolute;
  left: 0.6rem;
  bottom: 2.2rem;
  max-width: 18rem;
  margin: 0;
  padding: 0.4rem 0.55rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.78rem;
  z-index: 2;
}

#gaps-toggle {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  z-index: 2;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
}
#gaps-toggle[aria-expanded="true"] { background: var(--accent); color: white; border-color: var(--accent); }

#gaps {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(26rem, 100%);
  z-index: 3;
  overflow: auto;
  background: var(--paper-2);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 24px rgba(28, 25, 21, 0.06);
  padding: 0.8rem 1rem 1.4rem;
}
.gaps-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.gaps-bar h2 { margin: 0; text-transform: none; letter-spacing: 0; font-size: 1.15rem; color: var(--ink); }
#gaps-close {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 4px;
  font: inherit;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
}
.gap-status {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
}
.gap-status.is-cpra { background: var(--banner); color: var(--banner-ink); }
#inspect-center {
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
}
#inspect-center:disabled { cursor: default; color: var(--muted); }
#inspect-readout { margin-top: 0.45rem; }
#inspect-readout:empty { display: none; }
#inspect-readout h3 { margin: 0.45rem 0 0.15rem; font-size: 0.92rem; text-transform: none; letter-spacing: 0; color: var(--ink); }
#inspect-readout p { margin: 0.12rem 0; }
#center-mark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid #1c1915;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #fffdf8;
  pointer-events: none;
  z-index: 2;
}
#center-mark::before,
#center-mark::after {
  content: "";
  position: absolute;
  background: #1c1915;
}
#center-mark::before { left: 7px; top: 2px; width: 2px; height: 12px; }
#center-mark::after { top: 7px; left: 2px; height: 2px; width: 12px; }
.maplibregl-popup-content {
  font: inherit;
  color: var(--ink);
  border-radius: 6px;
  padding: 0.7rem 0.8rem;
  max-height: min(22rem, 70%);
  overflow-y: auto;
}
.maplibregl-popup-content h3 { margin: 0 0 0.3rem; font-size: 0.95rem; }
.maplibregl-popup-content p { margin: 0.15rem 0; }
.maplibregl-ctrl-attrib a { color: var(--accent); }

@media (max-width: 800px) {
  #shell { grid-template-columns: 1fr; grid-template-rows: minmax(15rem, 48vh) minmax(16rem, 1fr); height: auto; min-height: 100vh; }
  #panel { border-right: 0; border-bottom: 1px solid var(--line); }
  #stage { min-height: 16rem; }
  #gaps { width: 100%; }
}
