:root {
  --ink: #1d2a33;
  --paper: #eef2f0;
  --line: #c9d3d0;
  --muted: #56666d;
  --water: #2f6f9f;
  --cut: #b3261e;
  --site: #2e7d4f;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Public Sans", system-ui, -apple-system, sans-serif;
  color: var(--ink); background: var(--paper);
  display: flex; flex-direction: column;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--water); outline-offset: 2px; }

/* ---------- Header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand h1 { margin: 0; font-size: 1.7rem; font-weight: 800; }
.brand p { margin: 2px 0 0; color: var(--muted); max-width: 62ch; }
.toggle { display: flex; border: 1px solid var(--ink); }
.toggle button { border: none; background: transparent; padding: 9px 18px; cursor: pointer; font-weight: 600; }
.toggle button + button { border-left: 1px solid var(--ink); }
.toggle button.on { background: var(--ink); color: white; }

/* ---------- Layout ---------- */
.app { flex: 1; display: grid; grid-template-columns: 400px 1fr; min-height: 0; }
aside { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 8px; }
.tabs button {
  flex: 1; padding: 11px 6px; border: none; background: none; cursor: pointer;
  font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent;
}
.tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.panel { padding: 16px 20px 24px; overflow-y: auto; flex: 1; line-height: 1.5; }
h2 { font-size: 1.05rem; margin: 22px 0 8px; }
.tiny { font-size: 0.8rem; color: var(--muted); }
.reasons, .steps { padding-left: 20px; margin: 0; }
.reasons li, .steps li { margin-bottom: 8px; }

/* ---------- Numbers and lists ---------- */
.stat { padding: 10px 0; border-bottom: 1px solid var(--line); }
.stat:first-child { padding-top: 0; }
.stat strong { font-size: 1.6rem; font-weight: 800; display: block; line-height: 1.2; }
.stat.bad strong { color: var(--cut); }
.stat.good strong { color: var(--site); }
.row { padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:hover strong { text-decoration: underline; }
.row strong { display: block; }
.row span { color: var(--muted); font-size: 0.9rem; }
.num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--site); color: white; font-weight: 800; font-size: 0.85rem; margin-right: 6px; }

/* ---------- Popup ---------- */
.pop h3 { margin: 0 0 4px; font-size: 1rem; }
.pop table { border-collapse: collapse; margin: 6px 0; }
.pop td { padding: 2px 10px 2px 0; }
.pop .bad { color: var(--cut); font-weight: 700; }
.pop button { margin-top: 4px; padding: 5px 10px; border: 1px solid var(--ink); background: white; cursor: pointer; }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; }
#chatLog { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-bottom: 10px; }
.msg { padding: 10px 12px; max-width: 92%; line-height: 1.45; }
.msg.bot { background: white; border-left: 3px solid var(--water); }
.msg.user { background: var(--ink); color: white; align-self: flex-end; }
.msg.error { background: #fbeaea; border-left: 3px solid var(--cut); }
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.suggestions button { border: 1px solid var(--line); background: white; padding: 6px 10px; cursor: pointer; font-size: 0.85rem; }
#chatForm { display: flex; gap: 6px; }
#chatForm input { flex: 1; padding: 9px; border: 1px solid var(--line); background: white; }
#chatForm button { background: var(--ink); color: white; border: none; padding: 0 16px; cursor: pointer; font-weight: 600; }

/* ---------- Map ---------- */
.mapwrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; }
.layerbox, .legend {
  position: absolute; z-index: 1000; background: white; border: 1px solid var(--line);
  padding: 10px 12px; font-size: 0.88rem;
}
.layerbox { top: 10px; right: 10px; display: grid; gap: 4px; }
.legend { bottom: 22px; right: 10px; min-width: 190px; }
.legend div { margin: 3px 0; }
.swatch { display: inline-block; width: 18px; height: 12px; margin-right: 6px; vertical-align: middle; border: 1px solid rgba(0,0,0,0.2); }
.banner {
  position: absolute; z-index: 1001; top: 10px; left: 50%; transform: translateX(-50%);
  background: white; border-left: 4px solid var(--cut); padding: 12px 16px; max-width: 520px; line-height: 1.45;
}
.site-pin {
  background: var(--site); color: white; font-weight: 800; border: 2px solid white;
  border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center;
  box-shadow: 0 0 0 1px var(--site);
}

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 55vh auto; }
  .mapwrap { order: 1; min-height: 55vh; }
  aside { order: 2; border-right: none; }
  .layerbox { font-size: 0.8rem; max-width: 60%; }
  .legend { display: none; }
}
