:root {
  --ink: #1f2328;
  --muted: #59636e;
  --line: #d1d9e0;
  --ground: #f6f8fa;
  --panel: #ffffff;
  --link: #0a58b8;
  --in: #0f5a24;
  --in-bg: #dcf5e3;
  --in-edge: #2f9e55;
  --out: #9b1224;
  --out-bg: #fde8e8;
  --out-edge: #d8434f;
  --warn: #6b4200;
  --warn-bg: #fff4c2;
  --warn-edge: #c99a0e;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--ground);
}

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

/* Phone: search and verdict, then the map straight under them, then the source notes. */
.app {
  display: grid;
  grid-template-areas: "panel" "map" "sources";
  grid-template-rows: auto minmax(320px, 60vh) auto;
  min-height: 100%;
}

.panel {
  grid-area: panel;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

#map { grid-area: map; }

.sources {
  grid-area: sources;
  padding: 12px 16px 16px;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.sources p { margin: 0 0 6px; }

/* Desktop: a fixed left column with the notes at its foot, and the map filling the rest. */
@media (min-width: 900px) {
  html, body { overflow: hidden; }
  .app {
    grid-template-areas: "panel map" "sources map";
    grid-template-columns: 400px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    height: 100%;
  }
  .panel {
    overflow-y: auto;
    padding: 24px;
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }
  .sources {
    padding: 12px 24px 16px;
    border-right: 1px solid var(--line);
  }
  #map { height: 100%; }
}

h1 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  line-height: 1.25;
}

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

.search label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

.combo { position: relative; }

#q {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-size: 1.05rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid #8c959f;
  border-radius: 8px;
}

#q:focus {
  outline: 3px solid var(--link);
  outline-offset: 1px;
  border-color: var(--link);
}

#suggestions {
  position: absolute;
  z-index: 1100;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 320px;
  margin: 0;
  padding: 4px 0;
  overflow-y: auto;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(31, 35, 40, 0.16);
}

#suggestions li {
  padding: 10px 14px;
  line-height: 1.3;
  cursor: pointer;
  overflow-wrap: anywhere;
}

#suggestions li:hover,
#suggestions li[aria-selected="true"] { background: #e3f0ff; }

.hint {
  min-height: 1.5em;
  margin: 8px 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.result {
  padding: 14px 16px;
  background: var(--ground);
  border: 1px solid var(--line);
  border-left-width: 6px;
  border-radius: 8px;
}

.result h2 {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.2;
}

.result p { margin: 8px 0 0; }
.result .matched { margin-top: 6px; font-weight: 600; overflow-wrap: anywhere; }
.result .note { font-size: 0.95rem; color: var(--muted); }

.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 14px;
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid rgba(31, 35, 40, 0.15);
}

.facts dt { font-weight: 600; }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.result[data-status="inside"] { background: var(--in-bg); border-color: var(--in-edge); }
.result[data-status="inside"] h2 { color: var(--in); }

.result[data-status="outside"] { background: var(--out-bg); border-color: var(--out-edge); }
.result[data-status="outside"] h2 { color: var(--out); }

.result[data-status="boundary"],
.result[data-status="check"],
.result[data-status="unknown"] { background: var(--warn-bg); border-color: var(--warn-edge); }

.result[data-status="boundary"] h2,
.result[data-status="check"] h2,
.result[data-status="unknown"] h2 { color: var(--warn); }

.result[data-status="busy"] h2 { font-size: 1.1rem; color: var(--muted); }
