/* Give the map the space left after the compact header and controls. */
body { height: 100vh; height: 100dvh; min-height: 0; }
.statusbar { flex: none; padding-top: 0.45rem; padding-bottom: 0.45rem; }
.shell {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 0.65rem;
  padding: 0.85rem clamp(1rem, 2.5vw, 2.5rem) 0.65rem;
}
.shell > .footer { margin: 0; padding: 0; font-size: 0.65rem; gap: 0.35rem 1rem; }
.head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.65rem 1.5rem;
  margin: 0;
}
.head > div { min-width: 0; }
.head h1 { font-size: clamp(1.7rem, 2.8vw, 2.5rem); line-height: 1.1; }
.back { display: inline-block; margin-bottom: 0.25rem; font-size: 0.7rem; color: var(--accent-2); }
.back:hover { color: var(--accent); }
.lede { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.8rem; }

/* big numbers, mono captions */
.stats { display: flex; gap: clamp(0.85rem, 2vw, 2rem); margin: 0; }
.stats div { display: flex; flex-direction: column-reverse; }
.stats dt { font-family: var(--font-mono); font-size: 0.65rem; color: var(--muted); }
.stats dd {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.4rem, 2.3vw, 2rem);
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.stats div:first-child dd { color: var(--accent); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0;
}
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line-strong); border-radius: 0.5rem; overflow: hidden; }
.seg button {
  border: 0;
  border-right: 1px solid var(--line);
  padding: 0.45rem 0.9rem;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.year-filter { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--muted); font-size: 0.8rem; }
.year-filter select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.5rem;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(14rem, 19rem);
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  gap: 1rem;
}
.map-panel { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 0.35rem; }
.map {
  height: 100%;
  min-height: 0;
  border: 1px solid var(--line-strong);
  border-radius: 1rem;
  overflow: hidden;
}

.boundary-status { margin: 0; color: var(--muted); font-size: 0.65rem; }
.places-panel {
  min-height: 0;
  overflow-y: auto;
  padding: 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 1rem;
  background: var(--panel);
}
.places-panel > h2 { margin: 0 0 0.65rem; color: var(--ink); font-size: 0.85rem; letter-spacing: 0; text-transform: none; }
.places-panel > h2 span { margin-left: 0.4rem; color: var(--muted); font-size: 0.7rem; font-weight: 400; }
.places { border-top: 1px solid var(--line); }
.country {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
}
.country h2 { color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 0.8rem; }
.country h2 small { margin-left: 0.5rem; color: var(--accent); font-weight: 400; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.4rem;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 150ms, color 150ms;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip .count { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); }
.empty { color: var(--muted); padding: 1.5rem; font-family: var(--font-mono); font-size: 0.85rem; }

@media (max-width: 900px) {
  .map-layout { grid-template-columns: minmax(0, 1fr) 14rem; }
}

@media (max-width: 640px) {
  .statusbar { padding-left: 0.75rem; padding-right: 0.75rem; gap: 0.35rem; }
  .statusbar .right { flex-wrap: wrap; gap: 0.35rem 0.75rem; max-width: 100%; }
  .shell { padding: 0.6rem 0.75rem; gap: 0.5rem; }
  .head { gap: 0.5rem; }
  .head h1 { font-size: 1.65rem; }
  .stats { gap: 1.2rem; }
  .stats dd { font-size: 1.25rem; }
  .map-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 0.4fr); gap: 0.5rem; }
  .places-panel { padding: 0.6rem; }
  .seg button { padding: 0.35rem 0.5rem; font-size: 0.7rem; }
  .year-filter { font-size: 0.7rem; }
  .country { grid-template-columns: 1fr; gap: 0.5rem; }
}
