* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
  overflow: hidden;
}
#map { position: absolute; inset: 0; }

.panel {
  position: absolute;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}
#panel {
  top: 1rem; left: 1rem;
  width: 22rem; max-height: calc(100% - 2rem);
  overflow-y: auto;
  padding: 1.1rem 1.2rem 0.9rem;
  font-size: 0.92rem; line-height: 1.45;
}
h1 {
  font-family: var(--font-heading);
  font-size: 1.25rem; line-height: 1.25;
  margin: 0 0 0.5rem;
}
.dek { margin: 0 0 0.9rem; }

.stats { display: grid; gap: 0.55rem; margin-bottom: 1rem; }
.stat { display: grid; grid-template-columns: 4.2rem 1fr; gap: 0.6rem; align-items: baseline; }
.stat b { font-family: var(--font-heading); font-size: 1.3rem; text-align: right; }
.stat span { color: var(--color-muted); }

.controls { display: grid; gap: 0.6rem; margin-bottom: 0.9rem; }
.ctl { display: grid; grid-template-columns: 3.4rem 1fr; align-items: center; gap: 0.5rem; }
.ctl > span { font-weight: 700; font-size: 0.82rem; }
select, .seg button { font: inherit; font-size: 0.85rem; }
select { padding: 0.25rem 0.3rem; border: 1px solid var(--color-border); border-radius: var(--radius); background: #fff; }
.seg { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.seg button {
  border: 1px solid var(--color-border); background: #fff; color: var(--color-text);
  padding: 0.25rem 0.55rem; border-radius: var(--radius); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--color-navy); border-color: var(--color-navy); color: #fff; }
.seg button:hover { border-color: var(--color-accent); }

.range { display: flex; align-items: center; gap: 0.5rem; }
.range input { flex: 1; accent-color: var(--color-navy); }
.range output { font-size: 0.85rem; min-width: 2.4rem; }

.method summary { cursor: pointer; font-weight: 700; font-size: 0.85rem; }
.method p { font-size: 0.85rem; color: var(--color-muted); }
.help { margin-bottom: 0.4rem; }
.help ul { font-size: 0.85rem; color: var(--color-muted); padding-left: 1.1rem; margin: 0.5rem 0; }
.help li { margin-bottom: 0.3rem; }
.help b { color: var(--color-text); font-weight: 700; }
kbd {
  font: inherit; font-size: 0.78rem; color: var(--color-text);
  padding: 0 0.3rem; border: 1px solid var(--color-border); border-bottom-width: 2px;
  border-radius: 0.25rem; background: #fff;
}
/* Show mouse or touch instructions to match the device. */
.touch-only { display: none; }
@media (hover: none) and (pointer: coarse) {
  .touch-only { display: block; }
  .pointer-only { display: none; }
}
.credit { font-size: 0.75rem; color: var(--color-muted); margin: 0.8rem 0 0; }
a { color: var(--color-navy); }

.legend {
  right: 1rem; bottom: 2rem;
  padding: 0.6rem 0.8rem; width: 15rem; font-size: 0.78rem;
}
.legend-title { font-weight: 700; margin-bottom: 0.35rem; }
.legend-bar { display: flex; height: 0.7rem; gap: 2px; }
.legend-bar i { flex: 1; border-radius: 2px; }
.legend-ticks { display: flex; justify-content: space-between; color: var(--color-muted); margin-top: 0.2rem; }
.legend-note { color: var(--color-muted); margin-top: 0.3rem; }

.tooltip {
  position: absolute; z-index: 5; pointer-events: none;
  background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  padding: 0.5rem 0.65rem; font-size: 0.8rem; line-height: 1.4; max-width: 17rem;
}
.tooltip .t-head { font-weight: 700; margin-bottom: 0.2rem; }
.tooltip .t-row { display: flex; justify-content: space-between; gap: 1rem; }
.tooltip .t-row span:first-child { color: var(--color-muted); }
.tooltip .swatch { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 2px; margin-right: 0.3rem; }

/* Static-export mode (?static=1): no controls, big title and credit for print. */
.static #panel, .static .maplibregl-ctrl-bottom-right, .static .maplibregl-ctrl-top-right { display: none; }
.static-title { position: absolute; top: 2.5vh; left: 2.5vw; max-width: 50vw; padding: 1.4vh 1.8vh; background: var(--color-panel); border-radius: var(--radius); }
.static-title h1 { font-size: 3.4vh; margin: 0 0 0.4vh; }
.static-title p { font-size: 1.8vh; margin: 0; color: var(--color-muted); }
.static-credit { position: absolute; left: 2.5vw; bottom: 2vh; padding: 0.4vh 0.8vh; background: var(--color-panel); border-radius: var(--radius); font-size: 1.2vh; color: var(--color-muted); }
.static .legend { top: 2.5vh; right: 2.5vw; bottom: auto; width: auto; min-width: 22vh; font-size: 1.4vh; padding: 1.2vh 1.6vh; }
.static .legend-bar { height: 1.4vh; }

@media (max-width: 700px) {
  #panel { width: auto; right: 0.6rem; left: 0.6rem; top: auto; bottom: 0.6rem; max-height: 45%; }
  .legend { top: 0.6rem; right: 0.6rem; bottom: auto; width: 12rem; }
}
