.filter-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 1rem;
  font-weight: 900;
}

.nearby-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Active page state: currently viewing this screen */
.nearby-toggle.screen-active,
.filter-toggle.screen-active,
.report-toggle.screen-active,
.settings-toggle.screen-active {
  background: var(--nav);
  border-color: var(--nav);
  color: #fff;
  box-shadow: 0 10px 20px rgba(20, 30, 55, 0.22);
}

/* Filter enabled but NOT viewing the filter screen — subtle tint */
.filter-toggle.active:not(.screen-active) {
  background: #dde7f5;
  border-color: rgba(44, 79, 133, 0.45);
  color: var(--nav);
}

.filter-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
  border: 1px solid currentColor;
  background: rgba(255, 255, 255, 0.92);
  color: inherit;
}

/* Badge when on filter screen (dark bg) */
.filter-toggle.screen-active .filter-count {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.65);
  color: #fff;
}

/* Badge when filter enabled but not on filter screen — make it pop */
.filter-toggle.active:not(.screen-active) .filter-count {
  background: var(--nav);
  border-color: var(--nav);
  color: #fff;
}

/* Filter screen layout */

.filter-body {
  padding: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.filter-actions {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: #f8faf8;
}

.filter-action-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid rgba(47, 111, 78, 0.25);
  background: #fff;
  color: #2f6f4e;
  font-size: 0.88rem;
  font-weight: 750;
  cursor: pointer;
  transition: all 140ms ease;
}

.filter-action-btn:active {
  transform: scale(0.97);
}

.filter-action-btn[hidden] {
  display: none;
}

.filter-groups {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Group cards */

.filter-group-card {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.filter-group-card.active {
  border-color: rgba(47, 111, 78, 0.3);
  box-shadow: 0 2px 8px rgba(47, 111, 78, 0.08);
}

.filter-group-header {
  padding: 14px 16px;
  background: #f9fbf9;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: background 140ms ease;
}

.filter-group-header:active {
  background: #f1f5f1;
}

.filter-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 800;
  color: #2d3b34;
  min-width: 0;
}

.filter-group-icon {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.filter-group-label {
  flex: 1;
  min-width: 0;
}

.filter-group-count {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 800;
  color: #6b7b71;
  background: rgba(107, 123, 113, 0.1);
  padding: 3px 9px;
  border-radius: 999px;
  transition: all 180ms ease;
}

.filter-group-count.has-active {
  background: rgba(47, 111, 78, 0.15);
  color: #2f6f4e;
}

/* Filter grid */

.filter-group-grid {
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

@media (min-width: 500px) {
  .filter-group-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

/* Filter chips */

.filter-chip {
  position: relative;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  color: #3a4a40;
  font-size: 0.85rem;
  font-weight: 750;
  text-align: left;
  cursor: pointer;
  transition: all 140ms ease;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.filter-chip:hover {
  border-color: rgba(47, 111, 78, 0.3);
  background: #fafcfa;
}

.filter-chip:active {
  transform: scale(0.98);
}

.filter-chip-icon {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.filter-chip-label {
  flex: 1;
  min-width: 0;
}

.filter-chip-check {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--tree);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 900;
  opacity: 0;
  transform: scale(0.8);
  transition: all 180ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.filter-chip.active {
  background: #e9f3eb;
  border-color: rgba(47, 111, 78, 0.5);
  color: #1f3f2e;
  box-shadow: 0 2px 4px rgba(47, 111, 78, 0.1);
}

.filter-chip.active .filter-chip-check {
  opacity: 1;
  transform: scale(1);
}

/* Outside radius notice */

.filter-group-outside {
  margin: 0 12px 12px;
  padding: 10px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #557565;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.filter-group-outside-link {
  background: none;
  border: 0;
  padding: 0;
  margin: 0 0 0 6px;
  color: #2f6f4e;
  font: inherit;
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
}

/* Legacy styles for other UI elements */

.tool {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 1.25rem;
  font-weight: 900;
}

.legend {
  left: 14px;
  bottom: 14px;
  max-width: min(560px, calc(100vw - 28px));
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #2d3b34;
  font-size: 0.78rem;
  font-weight: 750;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.swatch {
  width: 14px;
  height: 10px;
  border-radius: 2px;
  background: currentColor;
  border: 2px solid currentColor;
  opacity: 0.75;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px currentColor;
}

@keyframes filter-hint-shake {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  18%       { transform: translateX(-5px) rotate(-4deg); }
  36%       { transform: translateX(5px) rotate(4deg); }
  54%       { transform: translateX(-4px) rotate(-2deg); }
  72%       { transform: translateX(4px) rotate(2deg); }
  86%       { transform: translateX(-2px); }
}

.filter-toggle-hint {
  animation: filter-hint-shake 0.55s ease 1.4s 1 both;
}

@keyframes nav-reselect-bounce {
  0%   { transform: scale(1); }
  38%  { transform: scale(1.18); }
  72%  { transform: scale(0.93); }
  100% { transform: scale(1); }
}

.nav-reselect {
  animation: nav-reselect-bounce 0.34s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
