:root {
  --bg: #ffffff;
  --panel: #f7f7f9;
  --text: #222;
  --muted: #5a5a5a;
  --accent: #2a7b5f;
  --border: #e0e0e0;
  --hc: #111; /* high contrast text */
}

/* Base layout */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  color: var(--text);
  background: var(--bg);
}

/* Skip link */
a.skip { position:absolute; left:-9999px; top:auto; width:1px; height:1px; overflow:hidden; }
a.skip:focus { position: static; width: auto; height: auto; padding: 8px; background: #ffd; border: 1px solid #cc0; z-index:9999; }

/* App grid: map + panel column (panel collapsed by default) */
#app { display: grid; grid-template-columns: 1fr 0; height: 100vh; transition: grid-template-columns 260ms ease; }
#app.panel-open { grid-template-columns: 1fr 380px; }

/* Map area */
#map { height: 100%; min-width: 0; }

/* Panel (right column) */
#panel { background: var(--panel); padding: 16px; overflow: auto; min-width: 0; }
#panel h1 { font-size: 1.1rem; margin: 0 0 8px; color: var(--hc); }
#panel h2 { font-size: 1rem; margin: 12px 0 6px; }
#panel p { margin: 6px 0; }

/* Badges & legend */
.badge { display: inline-block; padding: 2px 8px; margin: 2px 4px 2px 0; border-radius: 999px; font-size: 0.8rem; color: #fff; }
.random { background: #6c757d; }
.clumped { background: #2a7b5f; }
.uniform { background: #0d6efd; }
.meta { color: var(--muted); font-size: 0.9rem; }
.factor-list, .note-list { padding-left: 18px; }
.legend { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 10px; font-size: 0.9rem; }
.legend-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dot { width: 16px; height: 16px; border-radius: 50%; border: 1px solid #888; display: inline-block; }
.dot.random { background: repeating-radial-gradient(circle at 6px 6px, #ddd 0 2px, #bbb 2px 4px); }
.dot.clumped { background: radial-gradient(circle at 7px 7px, #7bc5a4 0 6px, transparent 7px), radial-gradient(circle at 12px 10px, #7bc5a4 0 6px, transparent 7px), radial-gradient(circle at 6px 12px, #7bc5a4 0 6px, transparent 7px); }
.dot.uniform { background: linear-gradient(90deg, #9ec5fe 0 2px, transparent 2px 20px), linear-gradient(0deg, #9ec5fe 0 2px, transparent 2px 20px); background-size: 20px 20px; }
canvas { background: #fff; border: 1px solid var(--border); border-radius: 6px; }

.sr-only { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Dataset switcher positioned safely below zoom controls */
.dataset-switcher { position: absolute; top: 140px; left: 12px; z-index: 1100; }
.dataset-switcher select { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); background: #fff; color: var(--text); }

/* Responsive: stack panel under map on small screens */
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 55vh 45vh; }
  #app.panel-open { grid-template-rows: 55vh 45vh; }
  #map { border-right: none; border-bottom: 1px solid var(--border); }
  .dataset-switcher { top: 150px; left: 8px; }
}

/* Small utility */
.panel-close { float: right; background: none; border: none; font-size: 1.2rem; cursor: pointer; }