.rl-tool {
  max-width: 900px;
  margin: auto;
}
.rl-panel,
.rl-card,
#rl-actions {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  margin: 1rem 0;
}
.rl-start,
.rl-panel fieldset {
  display: grid;
  gap: 0.65rem;
  margin: 0 0 1rem;
}
.rl-panel label {
  font-weight: 600;
}
.rl-panel input[type="text"],
.rl-panel input[type="number"] {
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  padding: 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font: inherit;
}
.rl-panel button,
.rl-actions button,
.rl-start button,
.rl-presets button,
.rl-units button,
.rl-card {
  min-height: 48px;
  padding: 0.65rem 0.9rem;
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
}
.rl-panel fieldset {
  border: 0;
  padding: 0;
}
.rl-panel legend {
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.rl-panel fieldset label {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.rl-panel input[type="checkbox"] {
  width: 22px;
  height: 22px;
}
.rl-presets,
.rl-units,
.rl-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.rl-presets button,
.rl-units button {
  flex: 1;
}
.rl-panel > button {
  width: 100%;
  background: var(--color-accent);
  color: var(--color-on-accent);
  border: 0;
  font-weight: 700;
}
.rl-panel button:disabled {
  opacity: 0.55;
}
#rl-map {
  height: 55vh;
  min-height: 390px;
  border-radius: 12px;
  overflow: hidden;
}
.rl-cards {
  display: grid;
  gap: 0.6rem;
}
.rl-card {
  width: 100%;
  display: grid;
  text-align: left;
  gap: 0.25rem;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
}
.rl-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-accent);
  color: var(--color-on-accent) !important;
  padding: 0.75rem 1rem;
  min-height: 48px;
  border-radius: 8px;
  text-decoration: none;
}
.rl-actions > * {
  min-height: 48px;
}
.rl-actions button {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
}
.rl-cards strong {
  font-size: 1.1rem;
}
@media (min-width: 700px) {
  .rl-cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Leaflet overlays the shared header unless the map has its own stacking context. */
#rl-map { isolation: isolate; }
.rl-actions [hidden] { display: none; }

.rl-card:not(:disabled):hover,
.rl-actions button:not(:disabled):hover {
  background: var(--color-surface-raised);
  color: var(--color-text);
}

/* Show the picked distance, unit and loop: dark theme, so mark with a light ring. */
.rl-presets button[aria-pressed="true"],
.rl-units button[aria-pressed="true"],
.rl-card[aria-pressed="true"] {
  outline: 3px solid var(--color-text);
  outline-offset: 2px;
}

#rl-map[hidden], .rl-combobox [hidden] { display: none; }
.rl-location-row { display: flex; gap: 0.65rem; align-items: center; flex-wrap: wrap; }
.rl-location-row span { flex: 1; min-width: 160px; }
.rl-panel select { min-height: 48px; padding: 0.65rem; font: inherit; }
.rl-combobox { position: relative; }
.rl-combobox ul { list-style: none; padding: 0; margin: 0.25rem 0 0; border: 1px solid var(--color-border); border-radius: 8px; background: var(--color-surface); }
.rl-combobox [role="option"] { padding: 0.75rem; min-height: 44px; box-sizing: border-box; cursor: pointer; border-bottom: 1px solid var(--color-border); }
.rl-combobox [role="option"][aria-selected="true"], .rl-combobox [role="option"]:hover { background: var(--color-surface-raised); outline: 2px solid var(--color-text); outline-offset: -2px; }

.rl-stop-marker {
  box-sizing: border-box;
  border-radius: 50%;
  border: 2px solid white;
  background: #167d65;
  color: white;
  font: bold 16px/28px sans-serif;
  text-align: center;
  box-shadow: 0 1px 5px #0008;
}
.rl-stop-selected, .rl-stop-marker:focus-visible {
  background: #854d0e;
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
}
.rl-outside-target { color: #d99b32; }
.leaflet-popup-content button { min-height: 32px; cursor: pointer; }
