.legend {
  margin-top: 10px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}
.legend-box {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
}
:root {
  --safe-top: env(safe-area-inset-top);
  --safe-right: env(safe-area-inset-right);
  --safe-bottom: env(safe-area-inset-bottom);
  --safe-left: env(safe-area-inset-left);
}

body {
  margin: 0;
  padding-top: var(--safe-top);
  padding-right: var(--safe-right);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
}
.app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

#map {
  flex: 1;
  min-width: 0; /* IMPORTANT: prevents overflow/squish bugs */
}

.sidebar {
  width: min(380px, 42vw);
  min-width: 260px;
  max-width: 520px;
  overflow-y: auto;
  padding: 14px;
  box-sizing: border-box;
}
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
*, *::before, *::after { box-sizing: inherit; }

header {
  background: #1f2933;
  color: #f9fafb;

  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;

  padding: 10px 16px;
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
}

header h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;

  max-width: 50%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

header div {
  font-size: 12px;
  opacity: 0.85;

  max-width: 50%;
  text-align: right;
  white-space: normal;
}

.topbar {
  background: #1f2933;
  color: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  padding: 10px 16px;
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
}

.brand {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;

  /* Prevent title from being forced off-screen */
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hint {
  font-size: 12px;
  opacity: 0.85;

  /* IMPORTANT so it can shrink/wrap instead of pushing off-screen */
  max-width: 50%;
  text-align: right;
  white-space: normal;
}

.app {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  top: calc(44px + env(safe-area-inset-top));
  display: flex;
  width: 100%;
  height: calc(100% - (44px + env(safe-area-inset-top)));
  overflow: hidden;
}

#map {
  flex: 1;
  min-width: 0;
  height: 100%;
}

#sidebar {
  width: min(380px, 44vw);
  min-width: 260px;
  height: 100%;
  overflow-y: auto;
  background: white;
  padding: 12px;
  border-left: 1px solid #e5e7eb;
}

.legend { margin-top: 10px; }
.legend-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.legend-box { width: 22px; height: 22px; border-radius: 6px; border: 1px solid #d1d5db; }

@media (max-width: 820px) {
  .app { flex-direction: column; }

  #sidebar {
    width: 100%;
    min-width: 0;
    height: 42%;
    border-left: none;
    border-top: 1px solid #e5e7eb;
  }

  #map { height: 58%; }
}

#zip-input {
  font-size: 16px;   /* prevents iOS zoom */
}
