/* ── Mobile usability refinements ─────────────────────────
   Keeps the desktop layout intact and improves the tool on narrow screens. */
@media (max-width: 840px) {
  html, body { height: auto; min-height: 100%; }
  body { display: block; }

  .site-header {
    position: relative;
    gap: 10px;
    padding: 10px 16px;
  }
  .site-logo img { height: 48px; width: auto; }
  .site-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .site-nav a {
    margin-inline-start: 0;
    font-size: 0.9rem;
    line-height: 1.2;
  }

  .app-shell {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
  }
  .panel {
    max-height: none;
    border-inline-end: none;
    border-bottom: 1px solid var(--border);
    padding: 16px 16px 18px;
    overflow: visible;
  }
  .panel .disclaimer,
  .panel .about {
    display: none;
  }
  .map {
    height: 66svh;
    min-height: 460px;
    flex: 0 0 auto;
  }
}

@media (max-width: 640px) {
  .site-header {
    align-items: flex-start;
    padding: 10px 14px;
  }
  .site-logo img { height: 42px; }
  .site-nav {
    gap: 8px 12px;
    max-width: 220px;
  }
  .site-nav a { font-size: 0.84rem; }

  .panel-title {
    font-size: 1.22rem;
    line-height: 1.25;
  }
  .panel-sub {
    font-size: 0.88rem;
    margin-bottom: 14px;
  }
  .tabs { margin-bottom: 12px; }
  .tab {
    min-height: 44px;
    padding: 9px 4px;
    font-size: 0.86rem;
  }
  .field input {
    font-size: 16px; /* prevents iOS zoom on focus */
    min-height: 44px;
  }
  .btn, .btn-secondary {
    min-height: 44px;
    font-size: 0.94rem;
  }

  .result { padding: 14px 12px; }
  .result-main { font-size: 1.7rem; }
  .result-main.multi {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .result-main.multi .stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: start;
    gap: 10px;
  }
  .result-main.multi .stat-label { margin-bottom: 0; }
  .result-meta {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .result-meta dd { margin-bottom: 6px; }

  .map {
    height: 64svh;
    min-height: 420px;
  }
  .leaflet-control-container .leaflet-top,
  .leaflet-control-container .leaflet-bottom {
    z-index: 700;
  }

  .tool-next-steps-links {
    max-width: none !important;
    margin: 20px 12px 0 !important;
    padding: 16px !important;
    border-radius: 12px !important;
    line-height: 1.65 !important;
  }
  .tool-next-steps-links h2 {
    font-size: 1rem !important;
    line-height: 1.35 !important;
  }
  .tool-next-steps-links h3 {
    font-size: 0.96rem !important;
  }
  .tool-next-steps-links p,
  .tool-next-steps-links li,
  .tool-next-steps-links details {
    font-size: 0.92rem !important;
  }
  .tool-next-steps-links > div {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .tool-next-steps-links summary {
    min-height: 42px;
    display: flex;
    align-items: center;
  }

  .site-footer {
    padding: 12px 14px;
    font-size: 0.78rem;
  }
}

@media (max-width: 420px) {
  .site-header { flex-direction: column; align-items: stretch; }
  .site-nav { max-width: none; justify-content: space-between; }
  .map { height: 62svh; min-height: 380px; }
  .panel { padding-inline: 14px; }
}
