.nearest-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 5px;
}

.nearest-item {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 7px 12px;
  font: inherit;
  display: grid;
  gap: 2px;
  grid-template-rows: auto auto;
  transition: all 140ms ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.nearest-item:hover {
  background: #f7faf7;
  border-color: rgba(47, 111, 78, 0.2);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.nearest-item:active {
  background: #eff5ee;
  transform: translateY(0);
}

.nearest-item.out-of-radius {
  background: #fafafa;
  border-color: rgba(0, 0, 0, 0.06);
  opacity: 0.85;
}

.nearest-item.out-of-radius:hover {
  background: #f5f5f5;
  border-color: rgba(0, 0, 0, 0.12);
}

.nearest-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.nearest-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
}

.nearest-icon .app-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.nearest-name {
  flex: 1;
  min-width: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: #2d3b34;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nearest-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.nearest-meta {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 600;
  color: #6b7b71;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nearest-arrow {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(47, 111, 78, 0.08);
  color: var(--tree);
  font-size: 1.3rem;
  font-weight: 900;
  line-height: 1;
  transform-origin: 50% 50%;
  transition: transform 40ms linear, background 140ms ease;
}

.nearest-item:hover .nearest-arrow {
  background: rgba(47, 111, 78, 0.12);
}

.nearest-item.out-of-radius .nearest-arrow {
  background: rgba(0, 0, 0, 0.04);
  color: #999;
}

.nearest-kind {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 4px;
  color: #2f4a3c;
  font-weight: 800;
}

.nearest-item small {
  display: block;
  margin-top: 6px;
}

.nearest-address {
  display: block;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 2px;
}

.walk-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.walk-icon {
  width: calc(18px * var(--icon-scale));
  height: calc(18px * var(--icon-scale));
}

.nearest-walk {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

@media (min-width: 761px) {
  .toolbar,
  .legend,
  .bottom-search {
    display: none;
  }
}

/* Phones held in landscape hit the ≥761px breakpoint and get the desktop side-panel layout.
   This overrides that and keeps the portrait bottom-sheet layout on any touch device
   with a small height (phones in landscape: ~360–430 px; tablets: 768 px+). */
@media (orientation: landscape) and (pointer: coarse) and (max-height: 500px) {
  .bottom-search {
    display: block;
    left: auto;
    right: 10px;
    transform: none;
    bottom: 10px;
  }

  .search-toggle { flex: 0 0 auto; }
  .search-panel { flex: 1 1 auto; }
  .search-number { flex: 1 1 auto; width: 100%; }

  .inspector {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    max-height: var(--inspector-height, 48%);
    transition: max-height 120ms ease-out;
  }

  .inspector-drag-handle { display: flex; }
  .inspector-actions { top: 30px; }
  .inspector-back { top: 30px; }

  .inspector-header {
    min-height: calc(36px * var(--icon-scale) + 44px);
    padding-top: 42px;
  }

  .row { grid-template-columns: 1fr; gap: 3px; }
}

@media (max-width: 760px) {
  .button {
    flex: 1;
  }

  .search-shell {
    width: 100%;
  }

  .bottom-search {
    left: auto;
    right: 10px;
    transform: none;
    bottom: 10px;
  }

  .search-toggle {
    flex: 0 0 auto;
  }

  .search-panel {
    flex: 1 1 auto;
  }

  .search-number {
    flex: 1 1 auto;
    width: 100%;
  }

  .inspector {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    max-height: var(--inspector-height, 48%);
    transition: max-height 120ms ease-out;
  }

  .inspector-drag-handle {
    display: flex;
  }

  .inspector-actions {
    top: 30px;
  }

  .inspector-back {
    top: 30px;
  }

  .inspector-header {
    min-height: calc(36px * var(--icon-scale) + 44px);
    padding-top: 42px;
  }

  .toolbar {
    top: 10px;
    left: 10px;
  }

  .legend {
    display: none;
  }

  .row {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}

/* Report screen keyboard avoidance (js/nav.js: handleReportViewportChange). Shifts the bottom
   sheet up and shrinks it to stay above the on-screen keyboard using the live VisualViewport
   inset, on both the portrait and landscape bottom-sheet layouts. */
@media (max-width: 760px),
(orientation: landscape) and (pointer: coarse) and (max-height: 500px) {
  .inspector.keyboard-avoiding {
    bottom: calc(10px + var(--keyboard-inset, 0px));
    max-height: calc(100% - 20px - var(--keyboard-inset, 0px));
  }
}

/* "Move your phone to help find your direction" nudge -- shown by
   showCompassCalibrationPrompt()/hideCompassCalibrationPrompt() in index.html while the
   compass is waiting for readings to settle before it's trusted (see
   registerCompassCalibrationSample). Non-blocking: the map stays fully interactive
   underneath, north-up-anchored on the user, until calibration completes or the user
   dismisses it. Positioned top-left to stay clear of both the desktop inspector
   (top-right) and the mobile bottom-sheet inspector. */
.compass-calibration-banner {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 3;
  max-width: min(320px, calc(100vw - 84px));
  transition: opacity 0.32s ease;
}

.compass-calibration-banner[hidden] {
  display: none;
}

.compass-calibration-banner.fading-out {
  opacity: 0;
  pointer-events: none;
}

.compass-calibration-banner-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid rgba(36, 56, 47, 0.15);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 10px 8px 10px 14px;
}

.compass-calibration-banner-icon {
  flex: 0 0 auto;
  font-size: 1.3rem;
  line-height: 1;
  animation: compass-calibration-wiggle 1.6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .compass-calibration-banner-icon {
    animation: none;
  }
}

.compass-calibration-banner-text {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--ink);
  line-height: 1.3;
}

.compass-calibration-banner-dismiss {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
}

.compass-calibration-banner-dismiss:hover,
.compass-calibration-banner-dismiss:active {
  background: rgba(0, 0, 0, 0.06);
  color: var(--ink);
}

@keyframes compass-calibration-wiggle {
  0%, 100% { transform: rotate(-18deg); }
  50% { transform: rotate(18deg); }
}
